Go的安装

GoMSI
go version
C:\Users\86199>go version
go version go1.16 windows/amd64
C:\Users\86199>go env
set GO111MODULE=on
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\86199\AppData\Local\go-build
set GOENV=C:\Users\86199\AppData\Roaming\go\env
set GOEXE=.exe
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GOMODCACHE=E:\downLoad-Package\GoWorks\pkg\mod
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=E:\downLoad-Package\GoWorks
set GOPRIVATE=
set GOPROXY=https://goproxy.cn,direct
set GOROOT=E:\downLoad-Package\Go
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLDIR=E:\downLoad-Package\Go\pkg\tool\windows_amd64
set GOVCS=
set GOVERSION=go1.16
set GCCGO=gccgo
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=NUL
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -fmessage-length=0 -fdebug-prefix-map=C:\Users\86199\AppData\Local\Temp\go-build4267479971=/tmp/go-build -gno-record-gcc-switches

C:\Users\86199>

配置环境变量

GOPATH
GOPATH
E:\downLoad-Package\GoWorks
GOROOT
GOROOT
E:\downLoad-Package\Go

在到编辑环境变量中设置进行添加

Gin 框架的配置

go get
GO111MODULE
on
GOPROXY
https://goproxy.cn,direct
GoLand 
Web

编写代码

package main

import "github.com/gin-gonic/gin"

func main() {
	r := gin.Default()
	r.GET("/hello", func(context *gin.Context) {
		context.JSON(200, gin.H{
			"message": "hello,my first go gin framework",
		})
	})
	r.Run()
}
go.mod
localhost:8080/hello

Go的历史

Gogopher [ˈɡoʊfər]Rob PikeGoUNIXUTF-8
GoRob PikeKen ThompsonRobert Griesemer
Go2009Go20158Go1.5Docker、KubernetesGo
Go
  • 简介,快速,安全

  • 并行,开源

  • 内存管理,数组安全,编译快

hello,world
package main

import "fmt"

func main() {
    fmt.Println("Hello, World!")
}
go run 
PS E:\downLoad-Package\GoWorks\src\awesomeProject> go run .\Hello.go
hello
go build 
PS E:\downLoad-Package\GoWorks\src\awesomeProject> go build .\Hello.go
PS E:\downLoad-Package\GoWorks\src\awesomeProject> .\Hello.exe
hello