[daily] gocron source reading - use go mod to manage and start gocron depending on source code

Keywords: Go github Google SQL MySQL

Starting from Go1.11, golang officially supports the new dependency management tool, go mod
go mod download: download the dependent module s to the local cache
go mod edit: edit go.mod
go mod graph: print module dependency graph
go mod init: initialize go.mod in the current directory (that is, a new go.mod file will be created)
Go module tidy: reorganize the dependency relationship, add lost modules and delete unnecessary modules
Go mod vendor: copy dependency to vendor
go mod verify: verify dependencies
go mod why: explain why dependency is needed

Take gocron for example, go get downloads the code and executes go mod tidy in the code directory
Will download dependent files in my $GOPATH/pkg/mod/cache /

Go to the directory src/github.com/ouqiang/gocron/cmd/gocron downloaded by gocron
Run go run gocron.go to run gocron of the source code

Content of go.mod file in gocron

module github.com/ouqiang/gocron

go 1.12

require (
    github.com/Tang-RoseChild/mahonia v0.0.0-20131226213531-0eef680515cc
    github.com/Unknwon/com v0.0.0-20190321035513-0fed4efef755 // indirect
    github.com/cihub/seelog v0.0.0-20170130134532-f561c5e57575
    github.com/dgrijalva/jwt-go v3.2.0+incompatible
    github.com/go-gomail/gomail v0.0.0-20160411212932-81ebce5c23df
    github.com/go-macaron/binding v0.0.0-20170611065819-ac54ee249c27
    github.com/go-macaron/gzip v0.0.0-20160222043647-cad1c6580a07
    github.com/go-macaron/inject v0.0.0-20160627170012-d8a0b8677191 // indirect
    github.com/go-macaron/toolbox v0.0.0-20180818072302-a77f45a7ce90
    github.com/go-sql-driver/mysql v1.4.1
    github.com/go-xorm/builder v0.3.4 // indirect
    github.com/go-xorm/core v0.6.2
    github.com/go-xorm/xorm v0.7.1
    github.com/golang/protobuf v1.3.1
    github.com/jakecoffman/cron v0.0.0-20190106200828-7e2009c226a5
    github.com/klauspost/compress v1.5.0 // indirect
    github.com/klauspost/cpuid v1.2.1 // indirect
    github.com/lib/pq v1.1.1
    github.com/ouqiang/goutil v1.1.1
    github.com/rakyll/statik v0.1.6
    github.com/sirupsen/logrus v1.4.2
    github.com/urfave/cli v1.20.0
    golang.org/x/crypto v0.0.0-20190530122614-20be4c3c3ed5 // indirect
    golang.org/x/net v0.0.0-20190522155817-f3200d17e092
    golang.org/x/text v0.3.2 // indirect
    google.golang.org/genproto v0.0.0-20190530194941-fb225487d101 // indirect
    google.golang.org/grpc v1.21.0
    gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc // indirect
    gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df // indirect
    gopkg.in/ini.v1 v1.42.0
    gopkg.in/macaron.v1 v1.3.2
)

Posted by dineshthakur on Wed, 13 Nov 2019 06:44:41 -0800