Golang Quick Start


Let’s create our first Go program.

  • Launch the VS Code editor
  • Open the extension manager or alternatively, press Ctrl + Shift + x
  • In the search box, type “go” and hit enter
  • Find the Go extension by the GO team at Google and install the extension
  • After the installation is complete, open the command palette by pressing Ctrl + Shift + p
  • Run the Go: Install/Update Tools command
  • Select all the provided tools and click OK

VS Code is now configured to use Go.

Open up a terminal window and type:

go mod init example.com/hello

Do not worry if you do not understand why we type the above command. Just think of it as something that you always do, and that you will learn more about in a later chapter.

Create a new file (File > New File). Copy and paste the following code and save the file as helloworld.go (File > Save As):


package main
import (“fmt”)

func main() {
fmt.Println(“Hello World!”)

Now, run the code: Open a terminal in VS Code and type:

go run .\helloworld.go
Hello World!

Congratulations! You have now written and executed your first Go program.

If you want to save the program as an executable, type and run:

go build .\helloworld.go
Secured By miniOrange