Skip to main content

Go Get Started

Two tools are all you need before you can begin working with Go:

  • A text editor such as VS Code, where you write your code
  • A compiler such as GCC, which turns Go code into a form your computer can understand

Plenty of editors and compilers exist, so you have lots of options. Here we will work with an IDE, which is explained further down the page.


Go Install

Go's installation files are available for download at https://golang.org/dl/.

Pick the file for your operating system and follow its instructions. Once that is done, open a terminal window and run this command to confirm that the installation worked:

Go Version syntax

main.go
go version

Go Install IDE

IDE stands for Integrated Development Environment: a single tool that lets you both edit and compile your code.

Visual Studio Code (VS Code), Vim, Eclipse and Notepad are all common choices. Each is free, and you can use any of them for editing and debugging Go.

Note: There are also IDEs that run in the browser. They work too, but they can do less.

This tutorial uses VS Code, because we think it is a good tool for beginners.

Download its newest release from https://code.visualstudio.com/.


Go Quickstart

Time to write your first Go program! Start by setting up the editor.

Open VS Code and go to the extension manager, or use the shortcut Ctrl + Shift + x. Search for "go", press enter, and install the Go extension published by the Go team at Google. When it has finished installing, press Ctrl + Shift + p to bring up the command palette, then run Go: Install/Update Tools. Tick every tool in the list and click OK.

That completes the Go setup in VS Code.

Next, type this command in a terminal window:

Go Mod Init syntax

main.go
go mod init example.com/hello

Example

Prompt
Print "Hello World!" using the fmt package to show Go output at PromptCookbook.
Output: Go program and captured output