Open
Description
What version of Badger are you using?
v4.0.1
What version of Go are you using?
Not relevant
Have you tried reproducing the issue with the latest release?
Yes
What is the hardware spec (RAM, CPU, OS)?
Not relevant
What steps will reproduce the bug?
Use badger in an app that has -v
flag.
Expected behavior and actual result.
Expected: program does not panic.
Actual: program panics.
marko@daemons3 ~/foobar badger ± ./foobar
./foobar flag redefined: v
panic: ./foobar flag redefined: v
goroutine 1 [running]:
flag.(*FlagSet).Var(0xc000168120, {0x1943150, 0x2396f01}, {0x1939880, 0x1}, {0x17ec0d9, 0xd})
/home/marko/go/src/flag/flag.go:1005 +0x2c5
flag.BoolVar(...)
/home/marko/go/src/flag/flag.go:732
foobar/service.initialize({0x17eeb64, 0x10}, {0x1774800, 0xc00013c660}, {0x0, 0x0}, 0x1850638)
/home/marko/pkg/mod/foobar@v4.0.20/service/service.go:326 +0x3a5
foobar/service.Initialize(...)
/home/marko/pkg/mod/foobar@v4.0.20/service/service.go:302
main.main()
/home/marko/foobar/main.go:42 +0x331
This is because glog library pollutes flags and adds -v
flag. This breaks every program that has -v
flag.
Library should not pollute global flags.
Dependency graph
go mod why github.com/golang/glog
# github.com/golang/glog
foobar/ukv/db
github.com/dgraph-io/badger/v4
github.com/dgraph-io/ristretto/z
github.com/golang/glog
See relevant issues:
DataDog/dd-trace-go#1153
hypermodeinc/ristretto#293
Additional information
Ristretto is abandoned and they will not remove glog dependency. Consider moving to ristretto fork.