当前位置:网站首页>[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 .
边栏推荐
- Solve the problem that the database configuration information under the ThinkPHP framework application directory is still connected by default after modification
- sun. misc. Base64encoder error reporting solution [easy to understand]
- [Yugong series] go teaching course in July 2022 004 go code Notes
- DP: tree DP
- 信息学奥赛一本通 1339:【例3-4】求后序遍历 | 洛谷 P1827 [USACO3.4] 美国血统 American Heritage
- 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
- [quick start of Digital IC Verification] 9. Finite state machine (FSM) necessary for Verilog RTL design
- CVPR 2022 | common 3D damage and data enhancement
- 【数字IC验证快速入门】8、数字IC中的典型电路及其对应的Verilog描述方法
- Unity编辑器扩展 UI控件篇
猜你喜欢
【数字IC验证快速入门】9、Verilog RTL设计必会的有限状态机(FSM)
关于BRAM IP复位的优先级
A way to calculate LNX
Hong Kong stocks will welcome the "best ten yuan store". Can famous creative products break through through the IPO?
【刷题记录】1. 两数之和
港股将迎“最牛十元店“,名创优品能借IPO突围?
基础篇——配置文件解析
Leetcode brush questions: binary tree 18 (largest binary tree)
Oracle-表空间管理
1、强化学习基础知识点
随机推荐
Introduction to dead letter queue (two consumers, one producer)
Mysql频繁操作出现锁表问题
无卷积骨干网络:金字塔Transformer,提升目标检测/分割等任务精度(附源代码)...
ffplay文档[通俗易懂]
资源道具化
基金网上开户安全吗?去哪里开,可以拿到低佣金?
处理文件和目录名
信息学奥赛一本通 1339:【例3-4】求后序遍历 | 洛谷 P1827 [USACO3.4] 美国血统 American Heritage
[quick start of Digital IC Verification] 3. Introduction to the whole process of Digital IC Design
When JS method passes long type ID value, precision loss will occur
Dry goods navigation in this quarter | Q2 2022
B站UP搭建世界首个纯红石神经网络、基于深度学习动作识别的色情检测、陈天奇《机器学编译MLC》课程进展、AI前沿论文 | ShowMeAI资讯日报 #07.05
3.3、项目评估
mongodb文档间关系
A way to calculate LNX
2022 Beijing eye health products exhibition, eye care products exhibition, China eye Expo held in November
C language OJ gets PE, OJ of ACM introduction~
CTF逆向基础
How to retrieve the root password of MySQL if you forget it
1: Citation;