1、到官网下载安装包,地址是:https://golang.org/dl/ ,自选对应环境;
2、在任意目录,新建文件夹E:\work\code\go,cmd进入该目录,执行 go env 查看环境配置;
3、设置golang的GOPATH环境
set GOARCH=amd64 set GOBIN= set GOCACHE=C:\Users\Administrator\AppData\Local\go-build set GOEXE=.exe set GOFLAGS= set GOHOSTARCH=amd64 set GOHOSTOS=windows set GOOS=windows set GOPATH=C:\Users\Administrator\go set GOPROXY= set GORACE= set GOROOT=C:\Go set GOTMPDIR= set GOTOOLDIR=C:\Go\pkg\tool\windows_amd64 set GCCGO=gccgo set CC=gcc set CXX=g++ set CGO_ENABLED=1 set GOMOD= 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 -fno-caret-diagnostics -Qunused-arguments -fmessag e-length=0 -fdebug-prefix-map=C:\Users\ADMINI~1\AppData\Local\Temp\go-build05377 4846=/tmp/go-build -gno-record-gcc-switches
单次配置:执行 set GOPATH=E:\work\code\go
永久配置GOPATH,需要在系统环境变量中新增一个GOPATH的配置项,由此可以通过go将beego与bee的包下到该GOPATH目录中的src目录中来
4、在E:\work\code\go下执行
go get github.com/beego/bee
go get github.com/astaxie/beego下载bee,下载beego
5、配置bee环境变量,将E:\work\code\go\bin配置到系统path环境变量中,用于全局使用bee
6、使用bee创建一个新项目
bee new webApp
此时,会发现在E:\work\code\go\src目录下会多出一个webApp的Go项目
7、bee run webApp
如果报如下错误,别慌
2018/12/26 11:18:03 WARN ▶ 0001 Running application outside of GOPATH
2018/12/26 11:18:03 INFO ▶ 0002 Using 'webApp' as 'appname'
2018/12/26 11:18:03 INFO ▶ 0003 Initializing watcher...
can't load package: package .: no Go files in E:\work\code\go\src
2018/12/26 11:18:03 ERROR ▶ 0004 Failed to build the application: can't load
package: package .: no Go files in E:\work\code\go\src
直接到webApp目录底下,执行go run main.go
打开浏览器输入 http://localhost:8080/ 可以看到欢迎页面
来源:https://www.cnblogs.com/quepq/p/10178143.html