Learnmonkey Learnmonkey Logo

Go Comments

What are Comments?

When we are writing our code, we often want to make comments or notes about our code. This is what comments are for. We make Go ignore some lines of our code using comments. We can also use comments for remove old code, but not completely removing it. With comments, you can do whatever you want.

Making Comments In Go

To make comments, simply write // in front of the text you want to "comment out" (programming talk for making a text a comment). For example, we could have:

// hi
// there
// Learnmonkey!

Single-line comments can also go at the end of code like this:

fmt.Println("Learnmonkey is awesome!") // It's true!

Multi-Line Comments

We can also make multi-line comments in Go by putting /* in front of the first line of the comment and then putting */ at the end of the multi-line comment. For example, we could have:

/* Some Text Here
    More Text
    Share Learnmonkey With Your Friends!!
    Go Is Great! */