Go项目开发流程
开发流程
export GO111MODULE=on export GOPROXY=https://goproxy.cn go env -w GO111MODULE=on go env -w GOPROXY=https://goproxy.cn,direct go mod tidy go run main.go go build -o log2metric main.go
包管理流程
1.下载远程包
go mod tidy 会动态修改go.mod文件
1.从远端下载包到本地
2.把项目中没有被引入的包的名称从go.mod文件中删除
2.导入本地包
本地包和本项目设置的包名在go.mod文件中
//module github.com/redtoolskobe/scaninfo //在go.mod定义了自己项目的包名 //在项目中所有go源文件需要导入包的时候必须以github.com/redtoolskobe/scaninfo为前缀 //自己开发的源码包是不会拷贝到GOROOT目录或者GOPATH目录中去的 //import ( // _ "github.com/redtoolskobe/scaninfo/pkg/log" // "github.com/redtoolskobe/scaninfo/pkg/common" // "github.com/redtoolskobe/scaninfo/run" //) module yxh/scan //import ( // _ "yxn/scan/pkg/log" // "yxh/scan/pkg/common" // "yxh/scan/run" //) go 1.17 require ( github.com/PuerkitoBio/goquery v1.7.1 github.com/denisenkom/go-mssqldb v0.11.0 github.com/fatih/color v1.13.0 github.com/go-sql-driver/mysql v1.6.0 github.com/jlaffaye/ftp v0.0.0-20210307004419-5d4190119067 github.com/lib/pq v1.10.3 github.com/pkg/errors v0.9.1 github.com/projectdiscovery/clistats v0.0.8 github.com/projectdiscovery/gologger v1.1.4 github.com/pterm/pterm v0.12.33 github.com/shiena/ansicolor v0.0.0-20200904210342-c7312218db18 github.com/stacktitan/smb v0.0.0-20190531122847-da9a425dceb8 github.com/twmb/murmur3 v1.1.6 github.com/xuri/excelize/v2 v2.4.1 go.uber.org/ratelimit v0.2.0 golang.org/x/crypto v0.0.0-20210921155107-089bfa567519 golang.org/x/net v0.0.0-20210928044308-7d9f5e0b762b golang.org/x/text v0.3.7 ) require ( github.com/andres-erbsen/clock v0.0.0-20160526145045-9e14626cd129 // indirect github.com/andybalholm/cascadia v1.2.0 // indirect github.com/atomicgo/cursor v0.0.1 // indirect github.com/goinggo/mapstructure v0.0.0-20140717182941-194205d9b4a9 // indirect github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe // indirect github.com/gookit/color v1.4.2 // indirect github.com/json-iterator/go v1.1.10 // indirect github.com/logrusorgru/aurora v2.0.3+incompatible // indirect github.com/mattn/go-colorable v0.1.9 // indirect github.com/mattn/go-isatty v0.0.14 // indirect github.com/mattn/go-runewidth v0.0.13 // indirect github.com/mitchellh/mapstructure v1.4.2 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.2 // indirect github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 // indirect github.com/richardlehane/mscfb v1.0.3 // indirect github.com/richardlehane/msoleps v1.0.1 // indirect github.com/rivo/uniseg v0.2.0 // indirect github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778 // indirect github.com/xuri/efp v0.0.0-20210322160811-ab561f5b45e3 // indirect go.uber.org/atomic v1.7.0 // indirect go.uber.org/multierr v1.6.0 // indirect go.uber.org/zap v1.19.1 // indirect golang.org/x/sys v0.0.0-20211013075003-97ac67df715c // indirect golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 // indirect )
执行go mod tidy命令
编译流程
1.把项目上传到linux服务器
2.下载依赖包
在项目的子目录中执行go mod tidy
3.设置下载地址代理
export GO111MODULE=on
export GOPROXY=https://goproxy.cn
打包流程
go build -o log2metrics main.go
调试代码流程
运行三方项目
配置到prometheus中
配置到grafana
本文来自博客园,作者:不懂123,转载请注明原文链接:https://www.cnblogs.com/yxh168/p/15992589.html