欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

[Go] 使用go mod安装beego

程序员文章站 2022-10-25 15:26:34
需要go升级到1.12或以上 创建一个server.go 生成go.mod文件 ......

需要go升级到1.12或以上

mkdir gomodtest
cd gomodtest
go mod init gomodtest

创建一个server.go

package main
import "github.com/astaxie/beego"
func main() {
    beego.run()
}
go run server.go
自动查找依赖并且下载依赖的包到$gopath/pkg/mod/github.com/astaxie
go run server.go
go: finding github.com/astaxie/beego v1.12.0
go: downloading github.com/astaxie/beego v1.12.0
go: extracting github.com/astaxie/beego v1.12.0
go: downloading golang.org/x/crypto v0.0.0-20181127143415-eb0de9b17e85
go: downloading gopkg.in/yaml.v2 v2.2.1
go: finding github.com/shiena/ansicolor latest
go: extracting gopkg.in/yaml.v2 v2.2.1
go: downloading github.com/shiena/ansicolor v0.0.0-20151119151921-a422bbe96644
go: extracting golang.org/x/crypto v0.0.0-20181127143415-eb0de9b17e85
go: extracting github.com/shiena/ansicolor v0.0.0-20151119151921-a422bbe96644
go: finding gopkg.in/yaml.v2 v2.2.1
go: finding golang.org/x/crypto v0.0.0-20181127143415-eb0de9b17e85

生成go.mod文件

module gomodtest

go 1.13

require (
    github.com/astaxie/beego v1.12.0 // indirect
    github.com/shiena/ansicolor v0.0.0-20151119151921-a422bbe96644 // indirect
)