beego环境安装
1.安装go语言环境
先安装epel源
yum install -y epel-release (CentOS)
安装golang
1.yum provides go (搜索golang属于哪个包)
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
golang-1.11.5-1.el7.x86_64 : The Go Programming Language
Repo : epel
Matched from:
Provides : go = 1.11.5-1.el7
2.yum install -y golang-1.11.5-1.el7.x86_64 (安装go及其依赖)
2.安装beego
go get github.com/astaxie/beego
3.升级beego
go get -u github.com/astaxie/beego
4.使用beego输出Hello
vim beego.go 写入以下内容
package main import ( "github.com/astaxie/beego" ) func main() { beego.Info("Hello,beego") }
5.执行beego.go
有两种方法:
1.编译执行
go build beego.go ./beego (推荐,编译好之后依赖的包是linux最基础的包,静态可执行程序)
2.不编译执行
go run beego.go