vscode-go-comment
vscode-go-comment copied to clipboard
vscode plugin , auto generate comment for golang.
GoComment
GoComment is a plugin for vscode, auto generate for golang function, variable, struct comments.
使用默认模版可以生成满足golint要求的注释。可在vscode扩展插件中搜索 GoComment。
本仓库(https://github.com/0x00b/vscode-go-comment
)是vscode版本,对应的goland版本地址 https://github.com/0x00b/golandanno 。
How to use
- control + command + / (For windows: control + alt + /)
config template
-
- shift+command+p -> open setting (
json)
- shift+command+p -> open setting (
-
- add line
"functionTemplate": "// ${func_name} \n// @receiver ${receiver_name} \n// @param ${param_name} \n// @return ${return_name} ",
- add line
-
- add line
"typeTemplate": "// ${type_name} "
- add line
推荐使用默认注释,满足Golang godoc注释规范,满足golint默认扫描规则。

使用godoc查看注释效果如下:
godoc -http=localhost:6060


Getting started
How to install
1.vscode plugins marketplace(search GoComment)
special tag, represent beginning of a special line.
- @receiver : golang function receiver
- @param : golang function parameter
- @return : golang function return parameter
- @author : author name, or use ${git_name}
- @date : use ${date}, if not set, use current date
- @update : update tag, maybe config as
"${git_name} ${date}", update"${date}"always
support variable
func (r receiver)Foo(i interface{}) (e error)
* ${func_name} : function name is "Foo".
* ${receiver_name} : will be replaced by "r".
* ${receiver_type} : will be replaced by "receiver".
* ${receiver_name_type} : will be replaced by "r receiver".
* ${param_name} : "i"
* ${param_type} : "interface{}"
* ${param_name_type} : "i interface{}"
* ${return_name} : "e"
* ${return_type} : "error"
* ${return_name_type} : "e error"
* ${package_name} : package name
* ${type_name} : type Int int64, ${type_name} is "Int"
* ${var_name} : var n int, ${var_name} is "n"
* ${var_type} : var n int, ${var_type} is "int"
* ${date} : date
* ${git_name}: git config name
how to build and publish
vsce login publisher #login first, if need
vsce package
vsce publish