0x00 問題
exported function xxx should have comment or be unexported。
0x01 解決
https://golang.org/s/style 在這個頁面中有提到
Comment SentencesSee https://golang.org/doc/effective_go.html#commentary. Comments documenting declarations should be full sentences, even if that seems a little redundant. This approach makes them format well when extracted into godoc documentation. Comments should begin with the name of the thing being described and end in a period:
記錄聲明的注釋應該是完整的句子,即使這看起來有點多余。這種方法使它們在提取到 godoc 文檔時格式良好。注釋應以所述物品的名稱開始,並以句號結束:
// Request represents a request to run a command. type Request struct { ... // Encode writes the JSON encoding of req to w. func Encode(w io.Writer, req *Request) { ...
正是如此,golint 才會拋出這條警告,聲明你寫的代碼不符合規范。
符合規范的修改:
在方法調用中,能看到注釋信息:
分類:
疑難雜症