len(ansiCode) == 0
with ansiCode == ""
213 }
214
215 ansiCode = ansiCode[2 : len(ansiCode)-1]
216 if len(ansiCode) == 0 {217 init()
218 }
219 for _, code := range strings.Split(ansiCode, ";") {
len(key) == 0
with key == ""
53}
54
55func (cc *ChunkCache) Search(chunk *Chunk, key string) []Result {
56 if len(key) == 0 || !chunk.IsFull() {57 return nil
58 }
59
len(key) == 0
with key == ""
18
19// Add adds the list to the cache
20func (cc *ChunkCache) Add(chunk *Chunk, key string, list []Result) {
21 if len(key) == 0 || !chunk.IsFull() || len(list) > queryCacheMax {22 return
23 }
24
len(key) == 0
with key == ""
35
36// Lookup is called to lookup ChunkCache
37func (cc *ChunkCache) Lookup(chunk *Chunk, key string) []Result {
38 if len(key) == 0 || !chunk.IsFull() {39 return nil
40 }
41
len(line) == 0
with line == ""
53
54func (h *History) append(line string) error {
55 // We don't append empty lines
56 if len(line) == 0 {57 return nil
58 }
59
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.