We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
用的一个项目使用了这个包,启动的时候异常了,排查到问题是本地ip可能转换得到负数,除余1023仍然得到负数,然后snowflake约定初始值是0-1023导致panic项目直接启动不了。
// localIp得到负数情况下panic代码 Node, err = snowflake.NewNode(int64(localIp) % 1023) if err != nil { panic(err) } // 雪花算法抛出error逻辑 if n.node < 0 || n.node > n.nodeMax { return nil, errors.New("Node number must be between 0 and " + strconv.FormatInt(n.nodeMax, 10)) }
如果确认是负数引起的问题,考虑解决方案
func GetLocalIpToInt() (uint32, error)
The text was updated successfully, but these errors were encountered:
No branches or pull requests
用的一个项目使用了这个包,启动的时候异常了,排查到问题是本地ip可能转换得到负数,除余1023仍然得到负数,然后snowflake约定初始值是0-1023导致panic项目直接启动不了。
如果确认是负数引起的问题,考虑解决方案
func GetLocalIpToInt() (uint32, error)
参考The text was updated successfully, but these errors were encountered: