Go 中如何写注释
译者:baiyutang
原文:https://www.digitalocean.com/community/tutorials/how-to-write-comments-in-go
介绍
注释语法
复制代码
块注释
复制代码
复制代码
复制代码
行注释
一般,行注释看起来如下:
复制代码
为测试而注释掉代码
复制代码
总结
Using comments within your Go programs helps to make your programs more readable for humans, including your future self. Adding appropriate comments that are relevant and useful can make it easier for others to collaborate with you on programming projects and make the value of your code more obvious.
Commenting your code properly in Go will also allow for you to use the Godoc tool. Godoc is a tool that will extract comments from your code and generate documentation for your Go program.
版权声明: 本文为 InfoQ 作者【baiyutang】的原创文章。
原文链接:【http://xie.infoq.cn/article/0ac31fa02f6aa1322d566a5ff】。
本文遵守【CC-BY 4.0】协议,转载请保留原文出处及本版权声明。
评论