当前位置:网站首页>[Yugong series] go teaching course in July 2022 004 go code Notes
[Yugong series] go teaching course in July 2022 004 go code Notes
2022-07-05 20:25:00 【Hua Weiyun】
Preface
1. The definition of annotation
Annotation is the interpretation and explanation of the code . The purpose is to make it easy for others and themselves to understand , You can see at a glance what this code is for . Correct program annotation generally includes preamble annotation and functional annotation . The main content of the preamble note includes the interface of the module 、 Description of data and function of modules . The main content of the functional annotation of the module includes the function of the program segment 、 The function of the statement and the state of the data .
2. The function of annotation
Comments are just for readability , Will not be compiled by the computer .
One 、Go code annotation
Go Language annotations are mainly divided into two categories , These are single line comments and multi line comments .
1. Single-line comments
Single line notes are abbreviated as line notes , Is the most common form of annotation , Can be used anywhere to //
The opening single line comment ;
Shortcut key :ctrl+c
// Add Addition of two numbers ( This line will be intercepted as a brief introduction )// Precautions and principle of adding two numbers ( This line is a super detailed introduction )func Add(n1,n2 int)int{ return n1+n2}
2. Multiline comment
Multiline annotation is abbreviated as block annotation , With /*
start , And */
ending , And it can't be nested , Multiline annotations are generally used for package document description or block code fragments .
Shortcut key :shift+ctrl+c
/*regexp The package implements a simple library for regular expressions . The regular expression syntax accepted by the library is : regexp: concatenation { '|' concatenation } concatenation: { closure } closure: term [ '*' | '+' | '?' ] term: '^' '$' '.' character '[' [ '^' ] character-ranges ']' '(' regexp ')'*/package regexp
summary
The function of annotation in the program is to annotate and explain the program , Easy to read the source code . The compilation system will automatically ignore the comments when compiling the source code , Therefore, annotations have no effect on the function realization of the program . Add appropriate comments to the source code , It can improve the readability of the source code .
边栏推荐
- Introduction to dead letter queue (two consumers, one producer)
- 2.8、项目管理过程基础知识
- How to retrieve the root password of MySQL if you forget it
- CTF reverse Foundation
- [quick start of Digital IC Verification] 9. Finite state machine (FSM) necessary for Verilog RTL design
- DP:树DP
- ByteDance dev better technology salon was successfully held, and we joined hands with Huatai to share our experience in improving the efficiency of web research and development
- 【c语言】归并排序
- 处理文件和目录名
- 【数字IC验证快速入门】3、数字IC设计全流程介绍
猜你喜欢
微信小程序正则表达式提取链接
Informatics Orsay all in one 1339: [example 3-4] find the post order traversal | Valley p1827 [usaco3.4] American Heritage
计算lnx的一种方式
2022北京眼睛健康用品展,护眼产品展,中国眼博会11月举办
Introduction to dead letter queue (two consumers, one producer)
Rainbow 5.7.1 supports docking with multiple public clouds and clusters for abnormal alarms
Classic implementation method of Hongmeng system controlling LED
Hong Kong stocks will welcome the "best ten yuan store". Can famous creative products break through through the IPO?
14、Transformer--VIT TNT BETR
Scala basics [HelloWorld code parsing, variables and identifiers]
随机推荐
零道云新UI设计中
Mongodb/ document operation
CTF逆向基础
微信小程序正则表达式提取链接
什么是pyc文件
Bzoj 3747 poi2015 kinoman segment tree
Leetcode(695)——岛屿的最大面积
E. Singhal and Numbers(质因数分解)
Scala basics [HelloWorld code parsing, variables and identifiers]
c语言oj得pe,ACM入门之OJ~
关于BRAM IP复位的优先级
Unity编辑器扩展 UI控件篇
物联网智能家居基本方法实现之经典
- Oui. Net Distributed Transaction and Landing Solution
Mysql频繁操作出现锁表问题
资源道具化
C language OJ gets PE, OJ of ACM introduction~
【数字IC验证快速入门】9、Verilog RTL设计必会的有限状态机(FSM)
Notes on key vocabulary in the English original of the biography of jobs (12) [chapter ten & eleven]
PyTorch 1.12发布,正式支持苹果M1芯片GPU加速,修复众多Bug