Go言語
Go言語でソースコードにコメントを埋め込む
ソースコード中にコメントを埋め込みます。//は、//以降の文字列をコメントとして扱います。
//は、関数や変数への代入など、プログラム文の後ろに続けて書くことができます。
/* 〜 */は、囲まれた部分(〜)をコメントとして扱います。
/* */では複数行のコメントを書くことができます。
関数や変数への代入など、プログラム文の中に埋め込むこともできます。
/* */の中に/* */を入れ子にして書くことはできません。
comment.go
package main
import "fmt"
// one line comment
func main() {
// one line comment
fmt.Println("one line comment can write after statement") // one line comment
/* This comment style can be written in multi lines like the following */
/*
line 1
line 2
*/
/* This comment style can be embedded in statement */
fmt.Println("This Println() statement line includes " + /* comment */ "comment")
}
実行結果
$ go run comment.go
one line comment can write after statement
This Println() statement line includes comment