Skip to content

Go:Warnings

Go 코드에서 나는 고약한 냄새 지우는 방법. 주로 coc-go 에서 출력되거나 GoLand 에서 출력됨.

should use for range instead of for { select {} }

[S1000 default] [W] should use for range instead of for { select {} }

Select statements with a single case can be replaced with a simple send or receive.

Before:

select {
case x := <-ch:
    fmt.Println(x)
}

After:

x := <-ch
fmt.Println(x)

error strings should not be capitalized

error strings should not be capitalized (ST1005)

regex 사용이 편하다, 에러 체인에 일관성이 생긴다 등 여러 의견이 있음.

for loop can be modernized using range over int

[modernize rangeint] [H] for loop can be modernized using range over int

Before:

for i := 0; i < 6; i++ {
}

After:

for i := range 6 {
}

See also