Let’s Download Go installed from official site
- Go to the official Go website and download the appropriate installation file for your operating system.
- Run the installer and follow the instructions to complete the installation.
Hello World Program in Go Language
1. Create a Folder in Desktop or anywhere.
2. Open the Folder in any Text Editor (Sublime Text or VSCode).
3. Create a file names “hello_world.go”, Here go is golang file extension.
paste below hello world code
package main import "fmt" func main() { fmt.Println("Hello World!") }
you name get error near package main saying “go.mod file not found”, It’s because go language module is not initialized to hello_world.go file, To add the file into go.mod run below cmd as shown in step 4.
4. Open Terminal in IDE
go mod init hello_world.go
This will create a go.mod file and add the file into it.
run go program go run hello.go
create a executable file go build hello_world.go
run the exe file .\hello_world.exe