beego框架的 bee run 运行失败解决方法

1、在使用bee new 创建一个beego项目后,进入项目目录 执行 bee run 启动失败,下面大概记录一下解决方法。

bee new 新建项目成功;
在这里插入图片描述
进入到项目中,执行bee run 失败
报错内容如下:

G:\GoWorkspace\src\mybeego>bee run
______
| ___ \
| |_/ /  ___   ___
| ___ \ / _ \ / _ \
| |_/ /|  __/|  __/
\____/  \___| \___| v1.11.0
2020/07/19 22:47:01 INFO     ▶ 0001 Using 'mybeego' as 'appname'
2020/07/19 22:47:01 INFO     ▶ 0002 Initializing watcher...
..\github.com\astaxie\beego\app.go:33:2: cannot find package "golang.org/x/crypto/acme/autocert" in any of:
        G:\Go\src\golang.org\x\crypto\acme\autocert (from $GOROOT)
        G:\GoWorkspace\src\golang.org\x\crypto\acme\autocert (from $GOPATH)
        G:\GoWorkspace\bin\src\golang.org\x\crypto\acme\autocert
..\github.com\prometheus\client_golang\prometheus\process_collector_windows.go:20:2: cannot find package "golang.org/x/sys/windows
" in any of:
        G:\Go\src\golang.org\x\sys\windows (from $GOROOT)
        G:\GoWorkspace\src\golang.org\x\sys\windows (from $GOPATH)
        G:\GoWorkspace\bin\src\golang.org\x\sys\windows
2020/07/19 22:47:01 ERROR    ▶ 0003 Failed to build the application: ..\github.com\astaxie\beego\app.go:33:2: cannot find package
 "golang.org/x/crypto/acme/autocert" in any of:
        G:\Go\src\golang.org\x\crypto\acme\autocert (from $GOROOT)
        G:\GoWorkspace\src\golang.org\x\crypto\acme\autocert (from $GOPATH)
        G:\GoWorkspace\bin\src\golang.org\x\crypto\acme\autocert
..\github.com\prometheus\client_golang\prometheus\process_collector_windows.go:20:2: cannot find package "golang.org/x/sys/windows
" in any of:

解决方法:

对比了一下成功运行的beego项目,发现新建的项目缺少go.mod文件,.刚刚生成的beego项目没有依赖管理包的文件,所有需要生成一个。
于是使用 go mod init 命令初始化一个go.mod文件到当前目录。

在新建项目下执行: go mod init

G:\GoWorkspace\src\mybeego>go mod init
go: creating new go.mod: module mybeego

G:\GoWorkspace\src\mybeego>

再次运行 bee run:

G:\GoWorkspace\src\mybeego>bee run
______
| ___ \
| |_/ /  ___   ___
| ___ \ / _ \ / _ \
| |_/ /|  __/|  __/
\____/  \___| \___| v1.11.0
2020/07/19 22:55:48 INFO     ▶ 0001 Using 'mybeego' as 'appname'
2020/07/19 22:55:48 INFO     ▶ 0002 Initializing watcher...
mybeego/controllers
mybeego/routers
mybeego
2020/07/19 22:56:08 SUCCESS  ▶ 0003 Built Successfully!
2020/07/19 22:56:08 INFO     ▶ 0004 Restarting 'mybeego.exe'...
2020/07/19 22:56:08 SUCCESS  ▶ 0005 './mybeego.exe' is running...
2020/07/19 22:56:08.646 [I] [asm_amd64.s:1357]  http server Running on http://:8080

哈,beego项目成功跑起来了!
浏览器访问:http://localhost:8080/
在这里插入图片描述
搞定。。。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值