设为首页 加入收藏

TOP

exported function xxx should have comment or be unexported
2019-08-04 00:07:22 】 浏览:76
Tags:exported function xxx should have comment unexported

0x00 问题

exported function xxx should have comment or be unexported。

11

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 才会抛出这条警告,声明你写的代码不符合规范。

符合规范的修改:

11

在方法调用中,能看到注释信息:

11

】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇Go调用Delphi编写的DLL 下一篇go golang 笔试题 面试题 笔试 面..

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目