Go Language Tutorial
Comment is used to explain how to work on the code.
To write the comment in the code, we can use // and /* */ syntax.
// syntax is used to write the single line comment in the code.
// declare variables Var name = “name1”
/* */ syntax is used to write the multiple line comment in the code.
/* print the result and variables value in a line. */ fmt.Println("name: ", name) fmt.Println("id: ", id) fmt.Println("salary: ", salary)
package main import "fmt" func main() { // declare variables var name string var id int var salary float32 // assign values name = "name1" id = 10 salary = 25000.500 /* prints the variables in a line */ fmt.Println("name: ", name) fmt.Println("id: ", id) fmt.Println("salary: ", salary) }Output:
]$ go build comments.go $ ./comments name: name1 id: 10 salary: 25000.5« Previous Next »