beego入门

beego的官方仓库地址是 https://github.com/beego/beego

为什么要特别说明这个事情呢?因为我们引入的包地址,有可能是从官方fork的,特别是beego,有的教程上通过go get引入的包就是fork的,比如:

github.com/astaxie/beego

,而不是官方渠道的,虽然这关系不大,还是有必要提前说明一下,以免因为这个细节导致其他问题。

 

mkdir hello

cd hello

go mod init hello

go get github.com/beego/beego/v2@latest

新建hello.go,填写如下内容:

package main

import "github.com/astaxie/beego"

func main() {
beego.Run()
}

启动 go run hello.go
此时,打开浏览器,访问http://localhost:8080即可看到beego的页面,如果出现错误,可以尝试执行go mod tidy后再运行!

 

 
posted @ 2022-12-30 20:26  jamstack  阅读(132)  评论(0编辑  收藏  举报