Home  >  Article  >  Backend Development  >  What are multi-line comments in go language?

What are multi-line comments in go language?

王林
王林Original
2021-01-07 13:55:486922browse

Multi-line comments in the Go language start with [/*] and end with [*/], and cannot be nested, such as [/*multi-line comments*/]. Multi-line comments are typically used to document package descriptions or to comment code snippets into blocks.

What are multi-line comments in go language?

The operating environment of this article: windows10 system, Go 1.11.2, thinkpad t480 computer.

(Learning video sharing: Programming video)

Comments in Go language are mainly divided into two categories, namely single-line comments and multi-line comments.

Single-line comments are referred to as line comments, which are the most common form of comments. Single-line comments starting with // can be used anywhere;

Multi-line comments are referred to as block comments, starting with /*. And ends with */, and cannot be nested. Multi-line comments are generally used for package documentation descriptions or code snippets that are commented into blocks.

The format of single-line comments is as follows

//单行注释

The format of multi-line comments is as follows

/*
第一行注释
第二行注释
...
*/

Each package should have related comments, and use the package statement to declare the package Add corresponding comments before the name to briefly explain the functions and functions of the package.

Related recommendations: golang tutorial

The above is the detailed content of What are multi-line comments in go language?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn