Go does not flag unused global variables, it is intended functionality. I've personally found that unused global variables have a higher chance at being benign than local variables, but there's probably an argument to be made for flagging globals, too.
On Sat, Apr 21, 2018, 06:30 <zpsyhap...@gmail.com> wrote: > #### What did you do? > https://play.golang.org/p/aryK9Btv5kH > > #### What did you expect to see? > There should be a error "declared and not used" > > #### What did you see instead? > It seems work fine. > > #### System details > > ``` > go version go1.10.1 windows/amd64 > GOARCH="amd64" > GOBIN="" > GOCACHE="C:\Users\zps\AppData\Local\go-build" > GOEXE=".exe" > GOHOSTARCH="amd64" > GOHOSTOS="windows" > GOOS="windows" > GOPATH="C:\Users\zps\go" > GORACE="" > GOROOT="C:\Go" > GOTMPDIR="" > GOTOOLDIR="C:\Go\pkg\tool\windows_amd64" > GCCGO="gccgo" > CC="gcc" > CXX="g++" > CGO_ENABLED="1" > CGO_CFLAGS="-g -O2" > CGO_CPPFLAGS="" > CGO_CXXFLAGS="-g -O2" > CGO_FFLAGS="-g -O2" > CGO_LDFLAGS="-g -O2" > PKG_CONFIG="pkg-config" > GOGCCFLAGS="-m64 -mthreads -fno-caret-diagnostics -Qunused-arguments > -fmessage-length=0 > -fdebug-prefix-map=C:\Users\zps\AppData\Local\Temp\go-build846935694=/tmp/go-build > -gno-record-gcc-switches" > GOROOT/bin/go version: go version go1.10.1 windows/amd64 > GOROOT/bin/go tool compile -V: compile version go1.10.1 > ``` > > -- > You received this message because you are subscribed to the Google Groups > "golang-nuts" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to golang-nuts+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.