sonyflake icon indicating copy to clipboard operation
sonyflake copied to clipboard

New Sonyflake MachineID error

Open kevinmiao opened this issue 9 months ago • 3 comments

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

`

kevinmiao avatar Apr 29 '24 10:04 kevinmiao