当前位置:网站首页>[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 .
边栏推荐
- y57.第三章 Kubernetes从入门到精通 -- 业务镜像版本升级及回滚(三十)
- 1. Strengthen learning basic knowledge points
- ROS2专题【01】:win10上安装ROS2
- 资源道具化
- Leetcode (347) - top k high frequency elements
- 无卷积骨干网络:金字塔Transformer,提升目标检测/分割等任务精度(附源代码)...
- CVPR 2022 | 常见3D损坏和数据增强
- Leetcode skimming: binary tree 12 (all paths of binary tree)
- Document method
- 小程序代码的构成
猜你喜欢
【刷题记录】1. 两数之和
Introduction to dead letter queue (two consumers, one producer)
. Net distributed transaction and landing solution
关于BRAM IP复位的优先级
解决php无法将string转换为json的办法
小程序事件绑定
B站UP搭建世界首个纯红石神经网络、基于深度学习动作识别的色情检测、陈天奇《机器学编译MLC》课程进展、AI前沿论文 | ShowMeAI资讯日报 #07.05
无卷积骨干网络:金字塔Transformer,提升目标检测/分割等任务精度(附源代码)...
2022北京眼睛健康用品展,护眼产品展,中国眼博会11月举办
Ros2 topic [01]: installing ros2 on win10
随机推荐
2.8、项目管理过程基础知识
E. Singhal and Numbers(质因数分解)
1. Strengthen learning basic knowledge points
Informatics Olympiad 1340: [example 3-5] extended binary tree
基金网上开户安全吗?去哪里开,可以拿到低佣金?
CTF逆向基础
处理文件和目录名
Leetcode brush questions: binary tree 18 (largest binary tree)
Go language learning tutorial (XV)
【数字IC验证快速入门】3、数字IC设计全流程介绍
sort和投影
Leetcode skimming: binary tree 10 (number of nodes of a complete binary tree)
小程序页面导航
【c语言】快速排序的三种实现以及优化细节
JS implementation prohibits web page zooming (ctrl+ mouse, +, - zooming effective pro test)
信息学奥赛一本通 1340:【例3-5】扩展二叉树
解决Thinkphp框架应用目录下数据库配置信息修改后依然按默认方式连接
Is it safe for CICC fortune to open an account online?
什么是pyc文件
[quick start of Digital IC Verification] 7. Basic knowledge of digital circuits necessary for verification positions (including common interview questions)