当我尝试使用 uint64 类型的命令行参数时,当我将默认值设置为有效的无符号 64 位数字时,出现以下编译错误。
编译错误: 表达式类型不匹配,预期类型少 uint64 ... 它在此处突出显示数字 5000,表示该值 Not Acceptable 。
代码:
var golferInstance uint64
flag.Uint64Var(&golferInstance, "inst", 5000, "Golfer Instance ID, this should be Globaly Unique ")
flag.Parse()
我没有看到上面的声明有什么问题,那为什么会编译错误??
我在这里错过了什么? (我相信一定是我没弄明白的傻事) 感谢您的帮助。
谢谢
最佳答案
go-lang-idea-plugin 中的检查类型关于某些类型的不匹配检测有一些问题。
参见 issue 348 (应该在该插件的最新版本中解决)
您可以取消选择该检查器。
In the interface it's called '
Highlight mismatched types
', I believe this is the one.
The message from inspection is: 'Expression type mismatch, expected type is ...
'It also seems it has problems in detecting that '
1 * time.Second
' in the construct 'time.Sleep(1 * time.Second)
' is a proper 'Duration
' type and it tries to fix it like this 'time.Sleep((time.Duration)(1 * time.Second))
'.
回到命令行,和/或确保所有组件都是最新的(golang IntelliJ 插件,Go 本身),可以提供帮助。
关于command-line - 默认命令行参数值的编译错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26942654/