2014-11-15 33 views
1

當我嘗試使用uint64類型的命令行參數時,將默認值設置爲有效的無符號64位數時,出現以下編譯錯誤。使用默認命令行參數值編譯錯誤

編譯錯誤: 表達式類型不匹配,期望的類型爲UINT64少... 它突出表明這裏這不是一個可接受值的數量5000。

代碼:

var golferInstance uint64 

flag.Uint64Var(&golferInstance, "inst", 5000, "Golfer Instance ID, this should be Globaly Unique ") 
flag.Parse() 

我看不出什麼毛病上面的聲明,那麼爲什麼編譯錯誤?

缺少什麼我在這裏? (我相信一定是愚蠢的,我未能發現) 任何幫助表示讚賞。

感謝

+0

您使用的是哪個版本的Go?似乎在操場上正常工作.. –

+0

去版本go1.2.2 linux/amd64 – Yogi

+0

你是如何編譯這個?如果您使用的是IDE,可以嘗試直接使用go工具進行編譯? – Logiraptor

回答

0

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插件,轉到本身),可以提供幫助。