Go 的HelloWorld

GoLand uses Go

1. Installation

  1. Visit the official website

https://golang.google.cn/

2) Click Download Go and select the package for the corresponding platform.

If you are using a Mac here, choose Apple macOS.

3) Double click to install directly

4) Verify that the installation is complete

Input go versionoutput corresponding version, the installation is completed

➜  ~ go version
go version go1.13.1 darwin/amd64

2. Use

  1. Recommend to use GoLand

Official website download address:

http://www.jetbrains.com/go/

  1. Choose Go Modules(vgo)to create to project.

figure 1

3) Create hello.go file

Enter the code:

Note the first line, the package name must be main

package main

import (
	"fmt"
)

func main() {
	fmt.Println("Hello World!")
}

3. Run

Compile: Generate executable file

go build hello.go 

Cleanup: Delete the executable file generated by compilation

go clean hello.go

Run: run the code

go run hello.go 
Published 420 original articles · 143 thumbs up · 890,000 views

Guess you like

Origin blog.csdn.net/jeikerxiao/article/details/102618627