What is go
package main
import "fmt"
func main() {
fmt.Println("Hello, Go!")
}
package main
: Specifies that this Go file is part of themain
package, which is the entry point for the executable program.import "fmt"
: Imports thefmt
package, which provides functions for formatted I/O, such as printing to the console.func main() {
: Defines themain
function, the entry point of the Go program.fmt.Println("Hello, Go!")
: Calls thePrintln
function from thefmt
package to print the string "Hello, Go!" to the console.}
: Closes themain
function.
Note: The indentation is used for code readability and is not mandatory in Go. It is a common convention to use the gofmt
tool to automatically format Go code according to the official style guide.