About Go
Go began at Google and is now developed as an open-source project. It is a statically typed, compiled language. Go supports pointers, but not pointer arithmetic. Its runtime includes a garbage collector.
Install Go
Open the official download and installation guide and choose the instructions for your operating system (Windows, macOS, or Linux) and CPU architecture. Follow the official steps, then open a new terminal and run:
| |
If the command prints a version, the go command is available. When updating Go, follow the official replacement instructions instead of unpacking a new version over an existing installation. See Managing Go installations for version management.
Run Hello, World
Create a working directory and initialize a module inside it:
| |
Create hello.go in that directory and save this code:
| |
Run the program with:
| |
It prints Hello, World!. To build an executable, run go build. The output name and extension depend on the operating system; Windows executables normally use .exe.
Continue learning
- Official Go tutorial: Getting started
- Go FAQ
- Go Playground (try code in a browser)
The official introductory materials are primarily available in English.
