Create from Goland

Overview

Having completed the Golang installation, we can formally enter golang for development, and the two currently mainstream editors are Goland VSCode, which will describe how to create a golang project using Golan.

Goland download please refer to Goland Web Site.

:::Note a reminder The Goland version of the current document presentation is GoLand 2022.1.4, this may be different if your Goland version does not match. :::

Create project

Open Goland, click New Project, select Go, fill in the project name, click Create.

New main.go

Right-click on helloworld to select New, choose Go File, enter file name mainto enter.

Enter the following code in main.go:

  1. package main
  2. import "fmt"
  3. func main() {
  4. fmt.Println("hello world!")
  5. }

Run program

In Golin, there are several ways to start the program:

  1. Right click on main.go file, select Run go build main.go.

  2. In the main.go file content panel, the fifth line code was found func main() on the left triangle, click running.

  3. Right-click on main.go file, select Open In, then select Terminalto open the terminal, and then enter the following instructions to run.

    1. $ go run main.go