aristanetworks / goarista

Fairly general building blocks used in Arista Go code and open-sourced for the benefit of all.
Apache License 2.0
213 stars 68 forks source link

-v flag redefined when using with github.com/golang/glog #63

Closed biplamal closed 2 years ago

biplamal commented 3 years ago

/tmp/go-build149476797/b001/tests.test flag redefined: v panic: /tmp/go-build149476797/b001/tests.test flag redefined: v goroutine 1 [running]: flag.(*FlagSet).Var(0xc00007e180, 0x12ab2f8, 0x1b49c88, 0x1151007, 0x1, 0x116e1e8, 0x14) /usr/local/go/src/flag/flag.go:871 +0x485 flag.Var(...) /usr/local/go/src/flag/flag.go:886 github.com/golang/glog.init.0() /home/go/pkg/mod/github.com/golang/glog@v0.0.0-20160126235308-23def4e6c14b/glog.go:401 +0x127 Further investigating we discovered that go test module has its own glog module and again goarista package is redefining the same glog module with same flags, which is conflicting and Its expected to fail [go language behavior]

aaronbee commented 3 years ago

What commands did you run to hit this panic? What is your go version?

biplamal commented 3 years ago

go test -run testcaseName -tags tagName -v

biplamal commented 3 years ago

I am using go 1.16.5

aaronbee commented 3 years ago

I see your stack trace includes github.com/golang/glog. It is not supported to use a combination of github.com/golang/glog and github.com/aristanetworks/glog as dependencies of your code.

Packages in github.com/aristanetworks/goarista depend on github.com/aristanetworks/glog, so if you use these libraries you cannot use github.com/golang/glog.

biplamal commented 3 years ago

But goarista shouldn't overwrite this flags (provided by golang glog) or there should be a way so that we can use both

aaronbee commented 2 years ago

Commit https://github.com/aristanetworks/goarista/commit/35110c587616aa060483fc4fa4a4cb5a6cdda055 should help. This removes the use of github.com/aristanetworks/glog from our gnmi library, so you can use it with other libraries that depend on github.com/golang/glog.