Your first Go program
After installing the Go tools successfully on your local machine, you are now ready to write and execute your first Go program. For that, simply open your favorite text editor and type in the simple Hello World program shown in the following code:
package main import "fmt" func main() { fmt.Println("Hello, World!") }
golang.fyi/ch01/helloworld.go
Save the source code in a file called helloworld.go
anywhere inside your GOPATH. Then use the following Go command to compile and run the program:
$> go run helloworld.go
Hello, World!
If all goes well, you should see the message Hello, World! output on your screen. Congratulations, you have just written and executed your first Go program. Now, let us explore the attributes and characteristics of the Go language at a high level.