gomodctl - search, check and update go modules.
Currently supported commands:
- search - search for Go packages by the given term
- info - search by the given term and show information about the matched package
- check - check project dependencies for the version information and shows outdated packages
- update - automatically sync project dependencies with their latest version
- license - fetch license of a module with/without version
Execute:
$ go get github.com/beatlabs/gomodctl
Or using Homebrew 🍺
brew tap beatlabs/gomodctl https://github.com/beatlabs/gomodctl
brew install gomodctl
Search in Go registry and return matched results.
Command:
gomodctl search patron
Result:
NAME | STARS | IMPORT COUNT | SCORE
------------------------------------------+-------+-------------------+-----------
github.com/beatlabs/patron/log | 44 | 26 | 0.940500
github.com/beatlabs/patron/trace | 43 | 19 | 0.940500
github.com/mantzas/patron/log | 26 | 12 | 0.940500
github.com/mantzas/patron/errors | 9 | 12 | 0.940500
github.com/beatlabs/patron | 44 | 9 | 1.000000
github.com/beatlabs/patron/async | 43 | 10 | 0.940500
github.com/mantzas/patron/trace | 26 | 8 | 0.940500
github.com/beatlabs/patron/examples | 44 | 8 | 0.940500
github.com/beatlabs/patron/sync | 46 | 6 | 0.940500
github.com/beatlabs/patron/sync/http | 46 | 6 | 0.931095
github.com/mantzas/patron/encoding | 20 | 5 | 0.940500
github.com/mantzas/patron | 24 | 4 | 1.000000
github.com/mantzas/patron/encoding/json | 9 | 5 | 0.931095
github.com/mantzas/patron/examples | 26 | 4 | 0.940500
github.com/mantzas/patron/async | 24 | 4 | 0.940500
github.com/beatlabs/patron/trace/http | 46 | 4 | 0.931095
github.com/mantzas/patron/sync | 26 | 3 | 0.940500
github.com/mantzas/patron/sync/http | 26 | 3 | 0.931095
github.com/mantzas/patron/info | 13 | 2 | 0.940500
github.com/beatlabs/patron/async/kafka | 44 | 2 | 0.931095
------------------------------------------+-------+-------------------+-----------
NUMBER OF MODULES | 20
--------------------+-----------
Add --json
parameter to the command to print result as a JSON.
Command:
gomodctl search github --json
Result:
...
{
"Name": "gomock",
"Path": "github.com/golang/mock/gomock",
"ImportCount": 3900,
"Stars": 3844,
"Score": 0.99,
"Synopsis": "Package gomock is a mock framework for Go."
},
{
"Name": "uuid",
"Path": "github.com/pborman/uuid",
"ImportCount": 3579,
"Stars": 318,
"Score": 1,
"Synopsis": "The uuid package generates and inspects UUIDs."
},
{
"Name": "distribution",
"Path": "github.com/docker/distribution",
"ImportCount": 3549,
"Stars": 5219,
"Score": 1,
"Synopsis": "Package distribution will define the interfaces for the components of docker distribution."
},
{
"Name": "state",
"Path": "github.com/juju/juju/state",
"ImportCount": 3851,
"Stars": 1614,
"Score": 0.99,
"Synopsis": ""
},
...
Detailed information about the package with fetched documentation.
Command:
gomodctl info patron
Result:
PATH | STARS | IMPORT COUNT | SCORE
-----------------------------------+-------+--------------+-----------
github.com/beatlabs/patron/trace | 43 | 19 | 0.940500
Documentation:
PACKAGE
package trace
import "github.com/beatlabs/patron/trace"
...
Use --imports
and --importers
flags to see list of imports in the package or importers using the package.
Check module versions in the given Go project.
Command:
gomodctl check
Result:
MODULE | CURRENT | LATEST
----------------------------------+---------------------+----------------------
github.com/stretchr/testify | v1.3.0 | v1.4.0
go.mongodb.org/mongo-driver | v1.1.1 | v1.2.1
github.com/mitchellh/go-homedir | v1.1.0 | v1.1.0
github.com/ory/dockertest | v3.3.5+incompatible | v3.3.5+incompatible
github.com/pkg/errors | v0.8.1 | v0.9.1
github.com/spf13/cobra | v0.0.5 | v0.0.5
github.com/spf13/viper | v1.4.0 | v1.6.2
----------------------------------+---------------------+----------------------
NUMBER OF MODULES | 7
----------------------+----------------------
Add --json
parameter to the command to print result as a JSON.
Add --path
parameter to the command to run command on another directory.
gomodctl check --json --path ~/projects/gomodctl
Scan for vulnerabilities using the tool gosec
Command:
gomodctl scan
Result
MODULE | CONFIDENCE | SEVERITY | CWE | LINE,COLUMN
--------------------------------------+------------+----------+-------------------------------------------------+------------------------------------------------------------------------------------
github.com/mitchellh/go-homedir | HIGH | MEDIUM | https://cwe.mitre.org/data/definitions/78.html | /go/pkg/mod/github.com/mitchellh/go-homedir@v1.1.0/homedir.go
| | | | ln:114 | col:10 exec.Command("getent", "passwd", strconv.Itoa(os.Getuid()))
--------------------------------------+------------+----------+-------------------------------------------------+------------------------------------------------------------------------------------
github.com/olekukonko/tablewriter | HIGH | MEDIUM | https://cwe.mitre.org/data/definitions/22.html | /go/pkg/mod/github.com/olekukonko/tablewriter@v0.0.4/csv.go
| | | | ln:19 | col:15 os.Open(fileName)
--------------------------------------+------------+----------+-------------------------------------------------+------------------------------------------------------------------------------------
github.com/olekukonko/tablewriter | HIGH | LOW | https://cwe.mitre.org/data/definitions/703.html | /go/pkg/mod/github.com/olekukonko/tablewriter@v0.0.4/table.go
| | | | ln:782 | col:3 tmpWriter.WriteTo(t.out)
--------------------------------------+------------+----------+-------------------------------------------------+------------------------------------------------------------------------------------
github.com/stretchr/testify | HIGH | MEDIUM | https://cwe.mitre.org/data/definitions/22.html | /Users/thomaschavakis/go/pkg/mod/github.com/stretchr/testify@v1.4.0/_codegen/main.go
| | | | ln:184 | col:15 ioutil.ReadFile(path.Join(pd.SrcRoot, pd.ImportPath, fname))
--------------------------------------+------------+----------+-------------------------------------------------+------------------------------------------------------------------------------------
Update module versions to latest minor
Command:
gomodctl update
Result:
Your dependencies updated to latest minor and go.mod.backup created
MODULE | PREVIOUS | NOW
----------------------------------+---------------------+----------------------
github.com/ory/dockertest | v3.3.5+incompatible | v3.3.5+incompatible
github.com/pkg/errors | v0.8.1 | v0.9.1
github.com/spf13/cobra | v0.0.5 | v0.0.5
github.com/spf13/viper | v1.4.0 | v1.6.2
github.com/stretchr/testify | v1.3.0 | v1.4.0
go.mongodb.org/mongo-driver | v1.1.1 | v1.2.1
github.com/mitchellh/go-homedir | v1.1.0 | v1.1.0
----------------------------------+---------------------+----------------------
NUMBER OF MODULES | 7
----------------------+----------------------
Add --json
parameter to the command to print result as a JSON.
Add --path
parameter to the command to run command on another directory.
gomodctl update --json --path ~/projects/gomodctl
Fetch licenses of the all dependencies of the current module. If module name provided, it will fetch license of specific module, version is optional.
Command:
gomodctl license
Result:
MODULE | VERSION | LICENSE
--------------------------------------+------------------------------------+---------------
github.com/go-resty/resty/v2 | v2.1.0 | MIT
github.com/olekukonko/tablewriter | v0.0.4 | MIT
github.com/securego/gosec | v0.0.0-20200129084146-17df5b370244 | Apache-2.0
github.com/stretchr/testify | v1.4.0 | MIT
github.com/Masterminds/semver | v1.5.0 | MIT
github.com/google/licenseclassifier | v0.0.0-20200108231022-9dfa8d8474eb | Apache-2.0
github.com/mholt/archiver/v3 | v3.3.0 | MIT
github.com/mitchellh/go-homedir | v1.1.0 | MIT
github.com/spf13/cobra | v0.0.6 | Apache-2.0
github.com/spf13/viper | v1.5.0 | MIT
golang.org/x/mod | v0.2.0 | BSD-3-Clause
--------------------------------------+------------------------------------+---------------
NUMBER OF MODULES | 11
-------------------------------------+---------------
Add --json
parameter to the command to print result as a JSON.
Command:
gomodctl license github.com/beatlabs/patron
gomodctl license github.com/beatlabs/patron v0.30.0
Result:
Apache-2.0
Create a gomodctl.yaml
which has following structure which contains modules you want to ignore.
ignored_modules:
- github.com/x/y
- github.com/a/b
gomodctl checks directories for gomodctl.yaml
in given order.
path
parameter- current working directory
- home directory
Since check and update rely on go toolchain, if you have any private module that isn't publicly accessible, don't forget to set up your environment variables. For more information and how to configure, please check Module configuration for non-public modules.
Please note that this project is released with a Contributor Code of Conduct. By participating in this project and its community you agree to abide by those terms.