当前位置:网站首页>[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 .
边栏推荐
猜你喜欢

Solve the problem that the database configuration information under the ThinkPHP framework application directory is still connected by default after modification

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

如何形成规范的接口文档

零道云新UI设计中

港股将迎“最牛十元店“,名创优品能借IPO突围?

【数字IC验证快速入门】9、Verilog RTL设计必会的有限状态机(FSM)

Introduction to dead letter queue (two consumers, one producer)

Oracle tablespace management

关于BRAM IP复位的优先级

鸿蒙os第四次学习
随机推荐
Pytorch 1.12 was released, officially supporting Apple M1 chip GPU acceleration and repairing many bugs
2022北京眼睛健康用品展,护眼产品展,中国眼博会11月举办
【刷题记录】1. 两数之和
欢迎来战,赢取丰厚奖金:Code Golf 代码高尔夫挑战赛正式启动
Cocos2d-x项目总结中的一些遇到的问题
BZOJ 3747 POI2015 Kinoman 段树
【数字IC验证快速入门】2、通过一个SoC项目实例,了解SoC的架构,初探数字系统设计流程
[quick start of Digital IC Verification] 7. Basic knowledge of digital circuits necessary for verification positions (including common interview questions)
About the priority of Bram IP reset
How to select the Block Editor? Impression notes verse, notation, flowus
怎么挑选好的外盘平台,安全正规的?
Mongodb/ document operation
走入并行的世界
How to retrieve the root password of MySQL if you forget it
Informatics Olympiad 1340: [example 3-5] extended binary tree
2.8、项目管理过程基础知识
插值查找的简单理解
A solution to PHP's inability to convert strings into JSON
MySql的root密码忘记该怎么找回
B站UP搭建世界首个纯红石神经网络、基于深度学习动作识别的色情检测、陈天奇《机器学编译MLC》课程进展、AI前沿论文 | ShowMeAI资讯日报 #07.05