beego 安装并创建项目

bee安装并创建项目

1.下载bee源码
下载地址为:
https://github.com/beego/bee

2.解压
将下载的文件解压到
最后的目录如下(相应目录的需要事先创建好,解压生产的目录名为bee-develop,重命名为bee):
../src/github.com/beego/bee

3.编译安装
cd C:\Go\src\github.com\beego\bee
go build

4.将生产的bee.exe拷贝到$GOPATH/bin

5.查看
C:\Go\src\github.com\beego\bee>bee version
______
| ___ \
| |_/ / ___ ___
| ___ \ / _ \ / _ \
| |_/ /| __/| __/
\____/ \___| \___| v1.10.0

├── Beego : Beego is not installed. Please do consider installing it first: https://github.com/astaxie/beego
├── GoVersion : go1.10.3
├── GOOS : windows
├── GOARCH : amd64
├── NumCPU : 8
├── GOPATH : C:\Users\huangxueliang\go
├── GOROOT : C:\Go\
├── Compiler : gc
└── Date : Monday, 9 Sep 2019

6.创建项目
在src目录下执行,我这里的目录是C:\Users\huangxueliang\go\src
新建一个 Web 项目,我们在命令行下执行 bee new <项目名> 就可以创建一个新的项目。
但是注意该命令必须在 $GOPATH/src 下执行。最后会在 $GOPATH/src 相应目录下生成如下目录结构的项目.

cd C:\Users\huangxueliang\go\src
bee new beegoprj
C:\Users\huangxueliang\go\src>bee new beegoprj
______
| ___ \
| |_/ / ___ ___
| ___ \ / _ \ / _ \
| |_/ /| __/| __/
\____/ \___| \___| v1.10.0
2019/09/09 14:18:29 INFO ? 0001 Creating application...
create C:\Users\huangxueliang\go\src\beegoprj\
create C:\Users\huangxueliang\go\src\beegoprj\conf\
create C:\Users\huangxueliang\go\src\beegoprj\controllers\
create C:\Users\huangxueliang\go\src\beegoprj\models\
create C:\Users\huangxueliang\go\src\beegoprj\routers\
create C:\Users\huangxueliang\go\src\beegoprj\tests\
create C:\Users\huangxueliang\go\src\beegoprj\static\
create C:\Users\huangxueliang\go\src\beegoprj\static\js\
create C:\Users\huangxueliang\go\src\beegoprj\static\css\
create C:\Users\huangxueliang\go\src\beegoprj\static\img\
create C:\Users\huangxueliang\go\src\beegoprj\views\
create C:\Users\huangxueliang\go\src\beegoprj\conf\app.conf
create C:\Users\huangxueliang\go\src\beegoprj\controllers\default.go
create C:\Users\huangxueliang\go\src\beegoprj\views\index.tpl
create C:\Users\huangxueliang\go\src\beegoprj\routers\router.go
create C:\Users\huangxueliang\go\src\beegoprj\tests\default_test.go
create C:\Users\huangxueliang\go\src\beegoprj\main.go
2019/09/09 14:18:29 SUCCESS ? 0002 New application successfully created!

7.运行
cd C:\Users\huangxueliang\go\src\beegoprj
C:\Users\huangxueliang\go\src\beegoprj>bee run
______
| ___ \
| |_/ / ___ ___
| ___ \ / _ \ / _ \
| |_/ /| __/| __/
\____/ \___| \___| v1.10.0
2019/09/09 14:21:14 INFO ? 0001 Using 'beegoprj' as 'appname'
2019/09/09 14:21:14 INFO ? 0002 Initializing watcher...
C:\Go\src\github.com\astaxie\beego\logs\console.go:23:2: cannot find package "github.com/shiena/ansicolor" in any of:
C:\Go\src\github.com\astaxie\beego\vendor\github.com\shiena\ansicolor (vendor tree)
C:\Go\src\vendor\github.com\shiena\ansicolor
C:\Go\src\github.com\shiena\ansicolor (from $GOROOT)
C:\Users\huangxueliang\go\src\github.com\shiena\ansicolor (from $GOPATH)
2019/09/09 14:21:15 ERROR ? 0003 Failed to build the application: C:\Go\src\github.com\astaxie\beego\logs\console.go:23:2: cannot find package "github.com/shiena/ansicolor" in any of:
C:\Go\src\github.com\astaxie\beego\vendor\github.com\shiena\ansicolor (vendor tree)
C:\Go\src\vendor\github.com\shiena\ansicolor
C:\Go\src\github.com\shiena\ansicolor (from $GOROOT)
C:\Users\huangxueliang\go\src\github.com\shiena\ansicolor (from $GOPATH)
解决办法:
下载ansicolor
下载地址:https://github.com/shiena/ansicolor
下载完成后解压到go path下的scr目录,我这里如下:
C:\Go\src\github.com\shiena

再次运行
C:\Users\huangxueliang\go\src\beegoprj>bee run
______
| ___ \
| |_/ / ___ ___
| ___ \ / _ \ / _ \
| |_/ /| __/| __/
\____/ \___| \___| v1.10.0
2019/09/09 14:24:33 INFO ? 0001 Using 'beegoprj' as 'appname'
2019/09/09 14:24:33 INFO ? 0002 Initializing watcher...
github.com/shiena/ansicolor
github.com/astaxie/beego/config
github.com/astaxie/beego/vendor/gopkg.in/yaml.v2
github.com/astaxie/beego/toolbox
github.com/astaxie/beego/utils
github.com/astaxie/beego/grace
github.com/astaxie/beego/vendor/golang.org/x/crypto/acme
github.com/astaxie/beego/logs
github.com/astaxie/beego/session
github.com/astaxie/beego/vendor/golang.org/x/crypto/acme/autocert
github.com/astaxie/beego/context
github.com/astaxie/beego/context/param
github.com/astaxie/beego
beegoprj/controllers
beegoprj/routers
beegoprj
2019/09/09 14:24:59 SUCCESS ? 0003 Built Successfully!
2019/09/09 14:24:59 INFO ? 0004 Restarting 'beegoprj.exe'...
2019/09/09 14:24:59 SUCCESS ? 0005 './beegoprj.exe' is running...
2019/09/09 14:25:02.340 [I] [asm_amd64.s:2361] http server Running on http://:8080

9.浏览器查看
http://localhost:8080/

beego 安装并创建项目_第1张图片

你可能感兴趣的:(beego 安装并创建项目)