How to write and run a basic "Hello, World!" program in Go?

To write and run a basic "Hello, World!" program in Go, you can follow these steps:

  1. Open a text editor and create a new file with a .go extension, such as hello.go.

  2. In the hello.go file, write the following code:

package main import "fmt" func main() { fmt.Println("Hello, World!") }
  1. Save the file.

  2. Open your terminal or command prompt and navigate to the directory where you saved the hello.go file.

  3. Run the program using the go run command followed by the name of the Go file:

go run hello.go
  1. The output will be printed in the terminal:
Hello, World!

Congratulations! You have successfully written and executed a basic "Hello, World!" program in Go.