Skip to content
New issue

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

nil与interface无法进行比较 #44

Closed
younglifestyle opened this issue Dec 2, 2020 · 6 comments
Closed

nil与interface无法进行比较 #44

younglifestyle opened this issue Dec 2, 2020 · 6 comments

Comments

@younglifestyle
Copy link

https://github.com/stack-labs/stack-rpc/blob/8087580622499aa3f49420d4e4831ed11bc76e4c/pkg/config/config.go#L231

这是micro之前代码的问题,nil与interface直接进行比较,两者是比较不了的

@printfcoder
Copy link
Member

不是很理解这个问题,当变量声明为指针但没有赋值,是可以用nil判空的。

@younglifestyle
Copy link
Author

但其为一个接口,接口赋值为nil,只是其value被赋值为nil,结构体其他成员不为nil,所以接口不等于nil,两者比较是不等的

@younglifestyle
Copy link
Author

@printfcoder
Copy link
Member

明白了,是指config被其它方法赋值[nil, nil]时造成的问题。确实会有这个情况。不过config模块是要初始化才能用,这个值也永远不会空。

晚点修复。点赞!

@printfcoder
Copy link
Member

@younglifestyle 要不你来修?

@younglifestyle
Copy link
Author

这里估计不用改,按照代码的逻辑感觉确实是不会出现问题,打扰了打扰了

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants