Comments are used to explain code, make notes, or temporarily disable parts of code. They are ignored by the Go compiler.
Use // for single-line comments. Everything after // on the same line is treated as a comment:
// This is a single-line comment
fmt.Println("Hello, Go!")
Use /* */ to write multi-line or block comments:
/*
This is a multi-line comment.
It can span multiple lines.
Useful for longer explanations.
*/
fmt.Println("Hello, Go!")
Click the button below to toggle a sample comment on/off (simulated):
// This comment is now visible! // Comments help you and others understand your code better.
Help others discover Technorank Learning by sharing your honest experience.
Your support inspires us to keep building!