当前位置:网站首页>[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 .
边栏推荐
- Leetcode (695) - the largest area of an island
- 插值查找的简单理解
- Classic implementation of the basic method of intelligent home of Internet of things
- [quick start of Digital IC Verification] 3. Introduction to the whole process of Digital IC Design
- 1、强化学习基础知识点
- C language OJ gets PE, OJ of ACM introduction~
- leetcode刷题:二叉树10(完全二叉树的节点个数)
- 炒股开户最低佣金,低佣金开户去哪里手机上开户安全吗
- 本季度干货导航 | 2022年Q2
- 信息学奥赛一本通 1340:【例3-5】扩展二叉树
猜你喜欢
死信队列入门(两个消费者,一个生产者)
js实现禁止网页缩放(Ctrl+鼠标、+、-缩放有效亲测)
解决Thinkphp框架应用目录下数据库配置信息修改后依然按默认方式连接
1、强化学习基础知识点
Leetcode brush question: binary tree 14 (sum of left leaves)
微信小程序正则表达式提取链接
解决php无法将string转换为json的办法
计算lnx的一种方式
[quick start to digital IC Verification] 8. Typical circuits in digital ICs and their corresponding Verilog description methods
零道云新UI设计中
随机推荐
July 4, 2022 - July 10, 2022 (UE4 video tutorial MySQL)
IC科普文:ECO的那些事儿
Leetcode skimming: binary tree 12 (all paths of binary tree)
Classic implementation method of Hongmeng system controlling LED
解决Thinkphp框架应用目录下数据库配置信息修改后依然按默认方式连接
[C language] three implementations of quick sorting and optimization details
CTF reverse Foundation
Go language learning tutorial (XV)
Ffplay document [easy to understand]
实操演示:产研团队如何高效构建需求工作流?
Guidelines for application of Shenzhen green and low carbon industry support plan in 2023
Informatics Olympiad 1338: [example 3-3] hospital setting | Luogu p1364 hospital setting
物联网智能家居基本方法实现之经典
Scala basics [HelloWorld code parsing, variables and identifiers]
Some problems encountered in cocos2d-x project summary
2022年7月4日-2022年7月10日(ue4视频教程mysql)
Leetcode(695)——岛屿的最大面积
【愚公系列】2022年7月 Go教学课程 004-Go代码注释
[quick start of Digital IC Verification] 7. Basic knowledge of digital circuits necessary for verification positions (including common interview questions)
Mysql频繁操作出现锁表问题