官方文档:https://beego.me/docs/install/env.md
# 搭建go环境:
请参考:【GO教程-3】Mac搭建go环境 https://blog.csdn.net/weixin_41827162/article/details/115612993
如果不想使用以上搭建go的教程,则可用下面教程:
1. Mac直接安装go安装包:
https://golang.google.cn/dl/go1.16.3.darwin-amd64.pkg
2. 写入自定义参数:
进入Mac用户根目录:
cd ~
创建 .bash_profile:
touch .bash_profile
打开.bash_profile:
open .bash_profile
然后写入如下内容:
export GOROOT=/usr/local/go
export GOPATH=/Users/fyonecon/workspace/gowork # 这是我的项目工作目录gowork,自定义
export GOBIN=$GOPATH/bin
export PATH=$PATH:$GOROOT/bin:$GOBIN
export GO111MODULE=on
export GOPROXY=https://goproxy.cn,direct
直接在用户根目录编译上面文件:
source ~/.bash_profile
# 搭建beego环境:
0. 安装beego依赖,进入gowork目录:
当前目录:$GOPATH(也就是GOPATH=/Users/fyonecon/workspace/gowork目录)。
go get -u github.com/astaxie/beego
go get -u github.com/beego/bee
1. 在gowork目录下新建/src/目录,并进入src目录;
当前目录:$GOPATH/src/
2. 在src目录新建一个beego项目:
创建一个模版项目: bee new demo2
(或创建一个api项目:bee api demo2 )
然后进入demo2目录,
当前目录:$GOPATH/src/demo2/
3. 初始化go.mod:
go mod init
4. 初始化go.sum:
go build -mod=mod
5. 运行beego:
bee run
-