[Go] 使用go mod安装beego

需要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.
go: extracting github.com/astaxie/beego v1.
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.
go: downloading github.com/shiena/ansicolor v0.20151119151921-a422bbe96644
go: extracting golang.org/x/crypto v0.eb0de9b17e85
go: extracting github.com/shiena/ansicolor v0.a422bbe96644
go: finding gopkg.
go: finding golang.org/x/crypto v0.20181127143415-eb0de9b17e85

生成go.mod文件

module gomodtest

go 1.13

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

 

相关文章

什么是Go的接口? 接口可以说是一种类型,可以粗略的理解为他...
1、Golang指针 在介绍Golang指针隐式间接引用前,先简单说下...
1、概述 1.1 Protocol buffers定义 Protocol buffe...
判断文件是否存在,需要用到"os"包中的两个函数: os.Stat(...
1、编译环境 OS :Loongnix-Server Linux release 8.3 CPU指...
1、概述 Golang是一种强类型语言,虽然在代码中经常看到i:=1...