len(w.GardenAddr) == 0
with w.GardenAddr == ""
66 return ErrInvalidWorkerVersion
67 }
68
69 if len(w.GardenAddr) == 0 {70 return ErrMissingWorkerGardenAddress
71 }
72
len(param) != 0
with param != ""
167func parseIntParam(r *http.Request, name string) (int, error) {
168 var val int
169 param := r.URL.Query().Get(name)
170 if len(param) != 0 {171 var err error
172 val, err = strconv.Atoi(param)
173 if err != nil {
len(configVersionStr) != 0
with configVersionStr != ""
29 }
30
31 var version db.ConfigVersion
32 if configVersionStr := r.Header.Get(atc.ConfigVersionHeader); len(configVersionStr) != 0 { 33 _, err := fmt.Sscanf(configVersionStr, "%d", &version)
34 if err != nil {
35 session.Error("malformed-config-version", err)
len(value) == 0
with value == ""
48 labelSet[chunkKey] = value[:valueLen]
49 value = value[valueLen:]
50
51 if len(value) == 0 { 52 break
53 }
54
len(token) == 0
with token == ""
296 }
297 tokenBytes, err := pty.ReadLine(os.Stdin)
298 token := strings.TrimSpace(string(tokenBytes))
299 if len(token) == 0 && err == io.EOF {300 return
301 }
302 if err != nil && err != io.EOF {
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.