- 創建目錄
mkdir hello
cd hello
- 創建項目
go mod init example/hello
go: creating new go.mod: module example/hello
- 編寫code
package main
import "fmt"
func main() {
fmt.Println("Hello, World!")
}
- 運行項目
go run .
- 下載外部包
go mod tidy
mkdir hello
cd hello
go mod init example/hello
go: creating new go.mod: module example/hello
package main
import "fmt"
func main() {
fmt.Println("Hello, World!")
}
go run .
go mod tidy