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 == ""
295 }
296 tokenBytes, err := pty.ReadLine(os.Stdin)
297 token := strings.TrimSpace(string(tokenBytes))
298 if len(token) == 0 && err == io.EOF {299 return
300 }
301 if err != nil && err != io.EOF {
len(w.GardenAddr) == 0
with w.GardenAddr == ""
66 return ErrInvalidWorkerVersion
67 }
68
69 if len(w.GardenAddr) == 0 {70 return ErrMissingWorkerGardenAddress
71 }
72
len(row.BuildStatus) != 0
with row.BuildStatus != ""
815 }
816
817 buildStatus := "succeeded"
818 if len(row.BuildStatus) != 0 {819 buildStatus = row.BuildStatus
820 }
821
len(input.Version.Pinned) != 0
with input.Version.Pinned != ""
170 JobID: setup.jobIDs.ID(CurrentJobName),
171 }
172
173 if len(input.Version.Pinned) != 0 {174 inputConfigs[i].PinnedVersion = atc.Version{"ver": input.Version.Pinned}
175
176 setup.insertPinned(setup.resourceIDs.ID(input.Resource), atc.Version{"ver": input.Version.Pinned})
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.