当前位置:网站首页>[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 regexpsummary
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 .
边栏推荐
- Codeforces Round #804 (Div. 2) - A, B, C
- How to choose a good external disk platform, safe and formal?
- js方法传Long类型id值时会出现精确损失
- 14、Transformer--VIT TNT BETR
- Station B up builds the world's first pure red stone neural network, pornographic detection based on deep learning action recognition, Chen Tianqi's course progress of machine science compilation MLC,
- 1: Citation;
- [quick start of Digital IC Verification] 9. Finite state machine (FSM) necessary for Verilog RTL design
- Bzoj 3747 poi2015 kinoman segment tree
- A way to calculate LNX
- Leetcode skimming: binary tree 12 (all paths of binary tree)
猜你喜欢

- Oui. Net Distributed Transaction and Landing Solution

B站UP搭建世界首个纯红石神经网络、基于深度学习动作识别的色情检测、陈天奇《机器学编译MLC》课程进展、AI前沿论文 | ShowMeAI资讯日报 #07.05

Unity编辑器扩展 UI控件篇

Scala基础【HelloWorld代码解析,变量和标识符】

A solution to PHP's inability to convert strings into JSON

Enter the parallel world
![Scala basics [HelloWorld code parsing, variables and identifiers]](/img/75/1d89581b9b8299ffb55d95514e6df4.png)
Scala basics [HelloWorld code parsing, variables and identifiers]
![[quick start of Digital IC Verification] 6. Quick start of questasim (taking the design and verification of full adder as an example)](/img/6d/110b87747f0a4be52da9fd49a05b82.png)
[quick start of Digital IC Verification] 6. Quick start of questasim (taking the design and verification of full adder as an example)

港股将迎“最牛十元店“,名创优品能借IPO突围?
![[quick start to digital IC Verification] 8. Typical circuits in digital ICs and their corresponding Verilog description methods](/img/3a/7eaff0bf819c129b4f866388e57b87.png)
[quick start to digital IC Verification] 8. Typical circuits in digital ICs and their corresponding Verilog description methods
随机推荐
How to choose a good external disk platform, safe and formal?
[Yugong series] go teaching course in July 2022 004 go code Notes
Informatics Orsay all in one 1339: [example 3-4] find the post order traversal | Valley p1827 [usaco3.4] American Heritage
1、强化学习基础知识点
【数字IC验证快速入门】6、Questasim 快速上手使用(以全加器设计与验证为例)
1: Citation;
Mongodb/ document operation
鸿蒙os第四次学习
DP:树DP
CVPR 2022 | common 3D damage and data enhancement
信息学奥赛一本通 1340:【例3-5】扩展二叉树
CVPR 2022 | 常见3D损坏和数据增强
Leetcode skimming: binary tree 12 (all paths of binary tree)
欢迎来战,赢取丰厚奖金:Code Golf 代码高尔夫挑战赛正式启动
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
Is it safe for CICC fortune to open an account online?
c語言oj得pe,ACM入門之OJ~
中金财富在网上开户安全吗?
Leetcode(695)——岛屿的最大面积
ROS2专题【01】:win10上安装ROS2