You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
an error occurred when I new Sonyflake.
the file is github.com/sony/[email protected]/sonyflake.go.
i'm use MacOs 14.4.1.
After debugging, I found that the isPrivateIPv4() check ip error under lower16BitPrivateIP() method.
i not init MachineID when i new Sonyflake, so it will run this code : var err error if st.MachineID == nil { sf.machineID, err = lower16BitPrivateIP(defaultInterfaceAddrs) } else { sf.machineID, err = st.MachineID() } if err != nil { return nil, err }
// NewSonyflake returns nil in the following cases:
// - Settings.StartTime is ahead of the current time.
// - Settings.MachineID returns an error.
// - Settings.CheckMachineID returns false.
So, if you would like to check the error, you should use func New(st Settings) (*Sonyflake, error) instead of NewSonyflake.
an error occurred when I new Sonyflake.
the file is github.com/sony/[email protected]/sonyflake.go.
i'm use MacOs 14.4.1.
After debugging, I found that the isPrivateIPv4() check ip error under lower16BitPrivateIP() method.
i not init MachineID when i new Sonyflake, so it will run this code :
var err error if st.MachineID == nil { sf.machineID, err = lower16BitPrivateIP(defaultInterfaceAddrs) } else { sf.machineID, err = st.MachineID() } if err != nil { return nil, err }
error Info
`
panic: runtime error: invalid memory address or nil pointer dereference [recovered]
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x11a1e92]
goroutine 6 [running]:
testing.tRunner.func1.2({0x1265300, 0x14d52d0})
/usr/local/go/src/testing/testing.go:1545 +0x238
testing.tRunner.func1()
/usr/local/go/src/testing/testing.go:1548 +0x397
panic({0x1265300?, 0x14d52d0?})
/usr/local/go/src/runtime/panic.go:914 +0x21f
github.com/sony/sonyflake.(*Sonyflake).NextID(0x0)
/Users/pkg/mod/github.com/sony/[email protected]/sonyflake.go:116 +0x32
`
The text was updated successfully, but these errors were encountered: