2022-12-03
This commit is contained in:
18
chapter-2/04_unused_variables.go
Normal file
18
chapter-2/04_unused_variables.go
Normal file
@@ -0,0 +1,18 @@
|
||||
// variables must be read at least once
|
||||
// golangci-lint will warn but the compiler will allow it
|
||||
|
||||
// package level vars do not need to be read (another reason not to use them)
|
||||
|
||||
// constants do not need to be read, if they are not used they are excluded from the build
|
||||
|
||||
package main
|
||||
|
||||
import "fmt"
|
||||
|
||||
func main() {
|
||||
x := 10
|
||||
x = 20
|
||||
|
||||
fmt.Println(x)
|
||||
x = 30
|
||||
}
|
||||
Reference in New Issue
Block a user