本文主要是介绍said goodbye to gopath let's go mod,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
Go来进行web开发,在其他编程语言中都有对应的开发框架,当然在Go中也有,就是即将要介绍的——iris,它号称为速度最快的Go后端开发框架。在iris的网站文档上,列出该框架具备的一些特点和框架特性,列举如下:
1)聚焦高性能
2)健壮的静态路由支持和通配符子域名支持
3)视图系统支持超过5以上模板
4)支持定制事件的高可扩展性Websocket API
5)带有GC, 内存 & redis 提供支持的会话
6)方便的中间件和插件
7)完整 REST API
8)能定制 HTTP 错误
9)源码改变后自动加载
官网地址:https://iris-go.com/
感谢jetbrain 家族提供的各种编译器,具体的编译器下载安装可以参考如下链接let’s go
本人按照教程下载安装go ide goland
如下是本人基于go mod 实现外部依赖包的导入
1)新建go 项目,选择 goModules 选择项目的根路径,设置对应的代理
2)新建完项目后会在项目根目录下生成go.mod文件
该文件内容
module item
go 1.13
新建文件main.go
package main
import ("github.com/kataras/iris"
)
func main() {app := iris.New()app.Get("/hello", func(ctx iris.Context) {ctx.JSON(iris.Map{"message": "Hello Iris!"})})app.Run(iris.Addr(":8080")) //8080 监听端口
}
此时编译器爆红,因为原生sdk没有对应的包,鼠标指向iris 会有一个 sync packages of item
点击该链接
依赖下载完毕
点开之前的go.mod 文件会发现配置修改如下
module itemgo 1.13require (github.com/BurntSushi/toml v0.3.1 // indirectgithub.com/Joker/jade v1.0.0 // indirectgithub.com/Shopify/goreferrer v0.0.0-20181106222321-ec9c9a553398 // indirectgithub.com/ajg/form v1.5.1 // indirectgithub.com/aymerick/raymond v2.0.2+incompatible // indirectgithub.com/eknkc/amber v0.0.0-20171010120322-cdade1c07385 // indirectgithub.com/fatih/structs v1.1.0 // indirectgithub.com/flosch/pongo2 v0.0.0-20190707114632-bbf5a6c351f4 // indirectgithub.com/gavv/monotime v0.0.0-20190418164738-30dba4353424 // indirectgithub.com/google/go-querystring v1.0.0 // indirectgithub.com/gorilla/schema v1.1.0 // indirectgithub.com/imkira/go-interpol v1.1.0 // indirectgithub.com/iris-contrib/blackfriday v2.0.0+incompatible // indirectgithub.com/iris-contrib/formBinder v5.0.0+incompatible // indirectgithub.com/iris-contrib/go.uuid v2.0.0+incompatible // indirectgithub.com/iris-contrib/httpexpect v0.0.0-20180314041918-ebe99fcebbce // indirectgithub.com/json-iterator/go v1.1.9 // indirectgithub.com/k0kubun/colorstring v0.0.0-20150214042306-9440f1994b88 // indirectgithub.com/kataras/golog v0.0.10 // indirectgithub.com/kataras/iris v11.1.1+incompatiblegithub.com/klauspost/compress v1.9.7 // indirectgithub.com/mattn/go-colorable v0.1.4 // indirectgithub.com/microcosm-cc/bluemonday v1.0.2 // indirectgithub.com/moul/http2curl v1.0.0 // indirectgithub.com/onsi/ginkgo v1.11.0 // indirectgithub.com/onsi/gomega v1.8.1 // indirectgithub.com/ryanuber/columnize v2.1.0+incompatible // indirectgithub.com/sergi/go-diff v1.1.0 // indirectgithub.com/shurcooL/sanitized_anchor_name v1.0.0 // indirectgithub.com/smartystreets/goconvey v1.6.4 // indirectgithub.com/xeipuuv/gojsonschema v1.2.0 // indirectgithub.com/yalp/jsonpath v0.0.0-20180802001716-5cc68e5049a0 // indirectgithub.com/yudai/gojsondiff v1.0.0 // indirectgithub.com/yudai/golcs v0.0.0-20170316035057-ecda9a501e82 // indirectgithub.com/yudai/pp v2.0.1+incompatible // indirectgolang.org/x/crypto v0.0.0-20200109152110-61a87790db17 // indirectgopkg.in/yaml.v2 v2.2.7 // indirect
)
而且生成gosum文件,内容
github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/Joker/hpp v0.0.0-20180418125244-6893e659854a h1:PiDAizhfJbwZMISZ1Itx1ZTFeOFCml89Ofmz3V8rhoU=
github.com/Joker/hpp v0.0.0-20180418125244-6893e659854a/go.mod h1:MzD2WMdSxvbHw5fM/OXOFily/lipJWRc9C1px0Mt0ZE=
github.com/Joker/jade v1.0.0 h1:lOCEPvTAtWfLpSZYMOv/g44MGQFAolbKh2khHHGu0Kc=
github.com/Joker/jade v1.0.0/go.mod h1:efZIdO0py/LtcJRSa/j2WEklMSAw84WV0zZVMxNToB8=
github.com/Shopify/goreferrer v0.0.0-20181106222321-ec9c9a553398 h1:WDC6ySpJzbxGWFh4aMxFFC28wwGp5pEuoTtvA4q/qQ4=
github.com/Shopify/goreferrer v0.0.0-20181106222321-ec9c9a553398/go.mod h1:a1uqRtAwp2Xwc6WNPJEufxJ7fx3npB4UV/JOLmbu5I0=
github.com/ajg/form v1.5.1 h1:t9c7v8JUKu/XxOGBU0yjNpaMloxGEJhUkqFRq0ibGeU=
github.com/ajg/form v1.5.1/go.mod h1:uL1WgH+h2mgNtvBq0339dVnzXdBETtL2LeUXaIv25U
这篇关于said goodbye to gopath let's go mod的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!