if
statement for single bool judgment GO-R1004219 ffi.Name = fmt.Sprintf("%s%d", mi.Name, cnt)
220 ffi.Column = ffi.Name
221 ffi.FullName = rmi.FullName + "." + ffi.Name
222 if added = rmi.Fields.Add(ffi); added {223 break
224 }
225 }
376 wildcardValues = append(wildcardValues, pattern[start:i])
377 }
378 for _, l := range t.leaves {
379 if ok := l.match(treePattern, wildcardValues, ctx); ok {380 return l.runObject
381 }
382 }
308 }
309 if t.wildcard != nil {
310 for _, l := range t.wildcard.leaves {
311 if ok := l.match(treePattern, wildcardValues, ctx); ok {312 return l.runObject
313 }
314 }
302 // Handle leaf nodes:
303 if pattern == "" {
304 for _, l := range t.leaves {
305 if ok := l.match(treePattern, wildcardValues, ctx); ok {306 return l.runObject
307 }
308 }
62
63func TestDelete(t *testing.T) {
64 safeMap.Delete("astaxie")
65 if exists := safeMap.Check("astaxie"); exists {66 t.Error("expected element to be deleted")
67 }
68}
if
statement can be simplified where only a single bool judgment is happening. It is more
idiomatic not to store the result of a function returning a bool and compare that in if
statement's conditional. It is better to skip the initialization expression.
if ok := fn(); ok {
// body
}
if fn() {
// body
}