Hello, World
Here is a simple "Hello World" program in Go:
package main
import "fmt"
func main() {
fmt.Println("Hello, World!")
}
Steps to Compile and Build
Save the code: Save the above code in a file named
hello.go
.Open a terminal: Navigate to the directory where
hello.go
is saved.Compile the code: Use the
go
command to compile the code. Run the following command:go build hello.goRun the executable: After compilation, an executable file named
hello
(orhello.exe
on Windows) will be created. Run it using:./hello
This will output:
Hello, World!
Last modified: 01 January 2025