4 ms·
I maintain a modified compiler (https://github.com/kstenerud/go/blob/master/README.md#the-go-programming-language https://github.com/kstenerud/go/blob/master/RE
by kstenerud 6y ago
I maintain a modified compiler (https://github.com/kstenerud/go/blob/master/README.md#the-go-programming-language https://github.com/kstenerud/go/blob/master/README.md#the-go...) that can issue warnings instead for unused things.
I use it as my daily driver for go development.
main.go:
package main
import "fmt"
func main() {
var start int = 1
breakOuter:
// for x := start; x < 10; x++ {
for x := 3; x < 10; x++ {
for y := 0; y < 10; y++ {
result := y * 10 + x
// fmt.Printf("Result: %d\n", result)
// if result == 42 {
// fmt.Printf("Breaking")
// break breakOuter
// }
}
}
}
Building:
$ go build
# example
./main.go:3:8: imported and not used: "fmt"
./main.go:8:5: label breakOuter defined and not used
(compilation fails)
$ go build -gcflags=-warnunused
# example
./main.go:8:5: Warning: label breakOuter defined and not used
./main.go:3:8: Warning: imported and not used: "fmt"
./main.go:6:9: Warning: start declared and not used
./main.go:12:13: Warning: result declared and not used
(compilation succeeds)
- rat9988 6y agoThat's cool! It is so annoying to just try to try something fast, and then the compiler stops you...