文档:https://beego.me/docs/quickstart/new.md
go version:go1.16 linux/amd64
beego version: v1.12.3
docker环境搭建:
go version go1.16 linux/amd64
docker run -it -v /Users/gowork/:/go/src/ -p 8000:8080 golang:latest
安装beego和bee工具
由于默认下载的为国外源,众所周知的原因,安装过程会很慢,甚至timeout,所以先修改配置
go env -w GOPROXY = https://goproxy.cn,direct
然后安装
-
go get github.com/astaxie/beego
-
-
go get github.com/beego/bee
快速创建项目
-
root@dd59085ad403:/go/src
# bee new test
-
2021/02/25 02:18:14 INFO ▶ 0001 generate new project support go modules.
-
2021/02/25 02:18:14 INFO ▶ 0002 Creating application...
-
create /
go/src/
test/go.mod
-
create /
go/src/
test/
-
create /
go/src/
test/conf/
-
create /
go/src/
test/controllers/
-
create /
go/src/
test/models/
-
create /
go/src/
test/routers/
-
create /
go/src/
test/tests/
-
create /
go/src/
test/
static/
-
create /
go/src/
test/
static/js/
-
create /
go/src/
test/
static/css/
-
create /
go/src/
test/
static/img/
-
create /
go/src/
test/views/
-
create /
go/src/
test/conf/app.conf
-
create /
go/src/
test/controllers/default.go
-
create /
go/src/
test/views/index.tpl
-
create /
go/src/
test/routers/router.go
-
create /
go/src/
test/tests/default_test.go
-
create /
go/src/
test/main.go
-
2021/
02/
25
02:
18:
14
SUCCESS ▶
0003
New application successfully created!
跑bee run是出现了报错
-
root@dd59085ad403
:/go/src/test
# bee run
-
_____
_
-
| ___ \
-
|
|_/ / ___ ___
-
| __
_ \ /
_ \ /
_ \
-
| |
_/
/| __/
| __/
-
\____/ \___| \__
_
| v1.12.0
-
2021/02/25 02:21:14 INFO ▶ 0001 Using 'test' as 'appname'
-
2021/02/25 02:21:14 INFO ▶ 0002 Initializing watcher...
-
go: github.com/astaxie/beego@v1.12.1: missing go.sum entry; to add it:
-
go mod download github.com/astaxie/beego
-
2021/02/25 02:21:15 ERROR ▶ 0003 Failed to build the application: go: github.com/astaxie/beego@v1.12.1: missing go.sum entry; to add it:
-
go mod download github.com/astaxie/beego
翻了下资料,缺少对应的引入文件`github.com/astaxie/beego`,重新`go get github.com/astaxie/beego`即可
-
root@dd59085ad403
:/go/src/test
# go get github.com/astaxie/beego
-
-
go
get: upgraded github.com/astaxie/beego v1.
12.1 => v1.
12.3
然后再次运行
-
root@dd59085ad403:/go/src/test#
bee
run
-
______
-
|
___
\
-
|
|_/
/
___
___
-
|
___
\
/
_
\
/
_
\
-
|
|_/
/|
__/|
__/
-
\____/
\___|
\___|
v1.12.0
-
2021
/02/25
02
:24:50
INFO
▶
0001
Using
'test'
as
'appname'
-
2021
/02/25
02
:24:50
INFO
▶
0002
Initializing
watcher...
-
test/controllers
-
test/routers
-
test
-
2021
/02/25
02
:24:53
SUCCESS
▶
0003
Built
Successfully!
-
2021
/02/25
02
:24:53
INFO
▶
0004
Restarting
'test'
...
-
2021
/02/25
02
:24:53
SUCCESS
▶
0005
'./test'
is
running...
-
2021
/02/25
02
:24:53.182 [
I] [
asm_amd64.s:1371]
http
server
Running
on
http://:8080
这样提示表名运行成功了。go是可以不用依赖nginx的,打开浏览器输入http://localhost:8080检查一下,有页面输出,bingo!!
转载:https://blog.csdn.net/u014043168/article/details/114065616
查看评论