Skip to content

Go Comments

In computer programming, comments are hints that are used to describe a piece of code. For example,

// declare a variable
age := 24

// print variable
fmt.Println(age)

Here, // declare a variable and // print variables are two comments used in the code.

Comments have nothing to do with code logic. They are meant for fellow programmers and are completely ignored by the compiler.

Types of Go Comments

In Go, there are two types of comments:

  • // - Single Line comments

  • /*...*/ - Multiline Comments