Fix missing enum types in declaration
const (
First byte = 1
Second = 2
)
will be replaced with
const (
First byte = 1
Second byte = 2
)
Remove unsafe printf
fmt.Printf("10")
will be replaced with
fmt.Print("10")
Replace string comparison using case-conversion with EqualFold
if strings.ToLower(s1) == strings.ToLower(s2) {}
will be replaced with
if strings.EqualFold(s1, s2) {}
Remove empty default branch in for { select {...}}
loop
for {
select ch {
case <-ch: // some code
default:
}
}
will be replaced with
for {
select ch {
case <-ch: // some code
}
}
Canonicalize headers in http.Header
map
const hdr = "foo"
h := http.Header{}
_ = h["header"]
_ = h[hdr]
will be replaced with
const hdr = "foo"
h := http.Header{}
_ = h["Header"]
_ = h[http.CanonicalHeaderKey(hdr)]
Remove unnecessary guard around maps
var m = map[string][]string{}
if _, ok := m["k1"]; ok {
m["k1"] = append(m["k1"], "v1", "v2")
} else {
m["k1"] = []string{"v1", "v2"}
}
will be replaced with
var m = map[string][]string{}
m["k1"] = append(m["k1"], "v1", "v2")
Fix select-case
way of sleeping
select {
case <-time.After(0):
}
will be replaced with
time.Sleep(0)
Remove unnecessary use of Sprint
/Sprintf
_ = fmt.Sprint("foo")
will be replaced with
_ = "foo"
Remove zero-width and control characters
a = "a" // this is unicode U+0007
will be replaced with
a = "\a"