当前位置:网站首页>[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 21:52:00 【Yugong move code】
List of articles
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 .
边栏推荐
- EBS Oracle 11g cloning steps (single node)
- Comprehensive optimization of event R & D workflow | Erda version 2.2 comes as "7"
- Implementing Lmax disruptor queue from scratch (IV) principle analysis of multithreaded producer multiproducersequencer
- kingbaseES V8R3数据安全案例之---审计记录清除案例
- QML reported an error expected token ";", expected a qualified name ID
- Kingbasees v8r3 data security case - audit record clearing case
- 力扣------经营摩天轮的最大利润
- MMAP
- 2.2.3 output of documents
- 123456
猜你喜欢

Parker驱动器维修COMPAX控制器维修CPX0200H

Making global exception handling classes with aspect

Uni app Bluetooth communication

Cross end solution to improve development efficiency rapidly

Shell script, awk uses if, for process control

The Blue Bridge Cup web application development simulation competition is open for the first time! Contestants fast forward!

MMAP learning

Recursive query of multi-level menu data

每日刷题记录 (十四)

K210学习笔记(四) K210同时运行多个模型
随机推荐
MATLAB | App Designer·我用MATLAB制作了一款LATEX公式实时编辑器
Two ways to realize video recording based on avfoundation
ESP32
每日刷题记录 (十四)
How to prepare for the algorithm interview and answer the algorithm interview questions
Three components of openpyxl
The primary key is set after the table is created, but auto increment is not set
SecureCRT使用提示
阿里云有奖体验:用PolarDB-X搭建一个高可用系统
Robot framework setting variables
MMAP learning
Huawei cloud modelarts text classification - takeout comments
从零开始实现lmax-Disruptor队列(四)多线程生产者MultiProducerSequencer原理解析
EL与JSTL注意事项汇总
Incentive mechanism of Ethereum eth
Kingbasees v8r3 cluster maintenance case -- online addition of standby database management node
2022-07-03-cka- latest feedback from fans
QML reported an error expected token ";", expected a qualified name ID
Postgres establish connection and delete records
SQL common syntax records