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 main
to enter.
Enter the following code in main.go
:
package main
import "fmt"
func main() {
fmt.Println("hello world!")
}
Run program
In Golin, there are several ways to start the program:
- Right click on
main.go
file, selectRun go build main.go
.
- In the
main.go
file content panel, the fifth line code was foundfunc main()
on the left triangle, click running.
Right-click on
main.go
file, selectOpen In
, then selectTerminal
to open the terminal, and then enter the following instructions to run.$ go run main.go