Open plutoyty opened 1 year ago
I'm not sure what line your referring to.
Connect is the primary way to create a connection and has a default logger. if you are referring to a private method somewhere, its ok to not handle nil if its an invariant in the implementation. As far as i'm aware no public method in this library will panic if there is no logger specified.
I see your panic stack from https://github.com/go-zookeeper/zk/issues/114 as well and it does point to logger since c.Server()
is not in the backtrace.
From this I would ask what your code setup is. By default the Logger is always set before running any goroutines. a case can be if you use SetLogger to a nil value. or even WithLogger.
If you have a code snippet, or reproduction in tests it would be very helpful to debug.
im going to close the panic report and put it in here.
c.logger.Printf("connected to %s", c.Server())
is line 392 here.
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x18 pc=0x8dc9cc]
goroutine 16 [running]:
github.com/go-zookeeper/zk.(*Conn).connect(0xc000506180)
/root/go/pkg/mod/github.com/go-zookeeper/zk@v1.0.3/conn.go:392 +0x30c
github.com/go-zookeeper/zk.(*Conn).loop(0xc000506180, {0xe2a5a8?, 0x13ceea0})
/root/go/pkg/mod/github.com/go-zookeeper/zk@v1.0.3/conn.go:428 +0x3c
github.com/go-zookeeper/zk.Connect.func1()
/root/go/pkg/mod/github.com/go-zookeeper/zk@v1.0.3/conn.go:224 +0x25
created by github.com/go-zookeeper/zk.Connect in goroutine 1
/root/go/pkg/mod/github.com/go-zookeeper/zk@v1.0.3/conn.go:223 +0x3d7
FAIL command-line-arguments 0.039s
FAIL
Whether to add a default value to the log, make a few more judgments