首先需要在官网Golang.google.cn下载.msi 后缀(在下载列表中可以找到该文件,如go1.4.2.windows-amd64.msi)的安装包来安装。
默认情况下 .msi 文件会安装在 c:Go 目录下。你可以将 c:Gobin 目录添加到 Path 环境变量中。添加后你需要重启命令窗口才能生效。
安装成功后在命令行窗口执行命令
go
将会出现go的命令信息
Go is a tool for managing Go source code. Usage: go <command> [arguments] The commands are: bug start a bug report build compile packages and dependencies clean remove object files and cached files doc show documentation for package or symbol env print Go environment information fix update packages to use new APIs fmt gofmt (reformat) package sources generate generate Go files by processing source get add dependencies to current module and install them install compile and install packages and dependencies list list packages or modules mod module maintenance run compile and run Go program test test packages tool run specified go tool version print Go version vet report likely mistakes in packages Use "go help <command>" for more information about a command. Additional help topics: buildmode build modes c calling between Go and C cache build and test caching environment environment variables filetype file types go.mod the go.mod file gopath GOPATH environment variable gopath-get legacy GOPATH go get goproxy module proxy protocol importpath import path syntax modules modules, module versions, and more module-get module-aware go get module-auth module authentication using go.sum module-private module configuration for non-public modules packages package lists and patterns testflag testing flags testfunc testing functions Use "go help <topic>" for more information about that topic.
环境变量GO111MODULE的修改
在安装第三方包的时候,由于网络问题golang.org在国内无法正常使用,导致我们无法使用第三方包管理工具,因此可以通过修改系统环境变量将golang.org切换至国内CDN。
windows下,执行如下命令
$env:GO111MODULE="on"
autoonoffautoonoff ononauto
国内CDN的切换
可以通过设定GOPROXY环境变量来实现国内CDN的切换,可以通过执行下面任一命令切换至七牛云,阿里云或是官方
$env:GOPROXY="https://goproxy.cn,direct" #七牛云
$env:GOPROXY="https://mirrors.aliyun.com/goproxy/,direct" #阿里云
$env:GOPROXY="https://goproxy.io,direct" #官方
Gin的安装
执行命令来完成Gin的安装
go get -u -v github.com/gin-gonic/gin
你还在原价购买阿里云、腾讯云、华为云、天翼云产品?那就亏大啦!现在申请成为四大品牌云厂商VIP用户,可以3折优惠价购买云服务器等云产品,并且可享四大云服务商产品终身VIP优惠价,还等什么?赶紧点击下面对应链接免费申请VIP客户吧: