len(shell) == 0
with shell == ""
11// ExecCommand executes the given command with $SHELL
12func ExecCommand(command string, setpgid bool) *exec.Cmd {
13 shell := os.Getenv("SHELL")
14 if len(shell) == 0 {15 shell = "sh"
16 }
17 return ExecCommandWith(shell, command, setpgid)
len(env) == 0
with env == ""
254
255func getEnv(name string, defaultValue int) int {
256 env := os.Getenv(name)
257 if len(env) == 0 {258 return defaultValue
259 }
260 return atoi(env, defaultValue)
len(cmd) == 0
with cmd == ""
100 // The default command for *nix requires bash
101 shell := "bash"
102 cmd := os.Getenv("FZF_DEFAULT_COMMAND")
103 if len(cmd) == 0 {104 success = r.readFromCommand(&shell, defaultCommand)
105 } else {
106 success = r.readFromCommand(nil, cmd)
len(opts.JumpLabels) == 0
with opts.JumpLabels == ""
1326 errorExit("tab stop must be a positive integer")
1327 }
1328
1329 if len(opts.JumpLabels) == 0 {1330 errorExit("empty jump labels")
1331 }
1332
len(spec) == 0
with spec == ""
1090 parseKeymap(opts.Keymap, nextString(allArgs, &i, "bind expression required"))
1091 case "--color":
1092 spec := optionalNextString(allArgs, &i)
1093 if len(spec) == 0 {1094 opts.Theme = tui.EmptyTheme()
1095 } else {
1096 opts.Theme = parseTheme(opts.Theme, spec)
It is not recommended to use len
for empty string test.
A string can be tested for its emptiness either by treating it as a slice and calculating the length of the slice, or by treating it as a string and directly comparing the value. While both produce identical code when compiled, it makes more sense to treat a string as itself, than a slice, for the sake of comparison of values.
len(s) == 0
s == ""
The recommended practice is considered more idiomatic in Go.