"Go foundation" Section 6 comments

In the previous section, we learned how to write a Hello Go. However, we may not understand why there is so written, let's take a look through the comments.

Notes the importance of not too much to say, do not write some code to read the comment really hard. So comment Go language should be how to write it?

1. Single-line comments

Note that a single line of code annotating line. By //showing

单行注释: // 注释的内容

2. Multi-line comments

Multi-line comments in the code that is more than two lines of code and comments. By /* */representation

多行注释:
/*
注释
的
内容*/

Knowing the content of the comment, we have to explain on a code via comments.

// 导入主函数的包
package main

// Goland会自动导入所需要的包(一系列功能和函数的集合), format: 标准输入输出格式包
import "fmt"

// 注释: 注释不参与程序编译, 可以帮助理解程序
// main 主函数, 是程序的主入口, 程序有且只有一个主函数
func main() {
    // 在屏幕中打印 Hello Go  
    fmt.Println("Hello Go")  // ln表示换行
}

By reading the comments, is not on the section of the code have a more clear understanding of it?

So this section will first come here.

Guess you like

Origin www.cnblogs.com/BlameKidd/p/11620183.html