https://github.com/daichitakahashi/modlist
Utility for listing packages of Go module and workspaces
https://github.com/daichitakahashi/modlist
go golang gomodules goworkspace unittest
Last synced: 4 months ago
JSON representation
Utility for listing packages of Go module and workspaces
- Host: GitHub
- URL: https://github.com/daichitakahashi/modlist
- Owner: daichitakahashi
- License: mit
- Created: 2023-06-16T07:29:51.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2023-06-19T13:13:03.000Z (almost 2 years ago)
- Last Synced: 2025-01-16T02:36:21.896Z (5 months ago)
- Topics: go, golang, gomodules, goworkspace, unittest
- Language: Go
- Homepage:
- Size: 29.3 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# modlist
`modlist` command lists your go modules/packages.## How it works
`modlist` loads `go.work` and list Go modules. And load module names from each `go.mod` files of modules.If `--packages` option is enabled, list all packages from your modules instead of module name.
It uses `go list` command## Usage
```shell
$ cat go.work
go 1.20use (
.
./module1
./module2
)
$ tree .
.
├── go.mod
├── go.work
├── module1
│ ├── go.mod
│ ├── package1
│ │ └── source.go
│ ├── package2
│ │ └── source.go
│ └── source.go
├── module2
│ ├── go.mod
│ ├── internal
│ │ └── pkg
│ │ └── source.go
│ └── source.go
├── package1
│ └── source.go
├── package2
│ └── source.go
└── source.go9 directories, 12 files
```List your modules.
```shell
$ modlist
example.com/multi
example.com/multi/module1
example.com/multi/module2
```List your packages.
```shell
$ modlist --packages
example.com/multi
example.com/multi/module1
example.com/multi/module1/package1
example.com/multi/module1/package2
example.com/multi/module2
example.com/multi/module2/internal/pkg
example.com/multi/package1
example.com/multi/package2
```Test your all packages and get coverages without internal package.
```shell
$ go test -coverpkg=`modlist -p -e="*internal*" --separator=","` `modlist -p -s`
ok example.com/multi/module2 0.115s coverage: [no statements]
ok example.com/multi/package1 0.221s coverage: [no statements]
ok example.com/multi/module1/package2 0.325s coverage: [no statements]
ok example.com/multi 0.429s coverage: [no statements]
ok example.com/multi/module1 0.815s coverage: [no statements]
ok example.com/multi/module2/internal/pkg 0.928s coverage: [no statements]
ok example.com/multi/package2 1.333s coverage: [no statements]
ok example.com/multi/module1/package1 1.446s coverage: [no statements]
```## Options
|option|shorthand|default|description|
|---|---|---|---|
|`--packages`|`-p`|false|List all packages instead of modules|
|`--shuffle`|`-s`|false|Shuffle output|
|`--match`|`-m`||Exclude unmatch items|
|`--exclude`|`-e`||Exclude match items|
|`--separator`||"\n"|Output separator|
|`--directory`|`-d`|false|Show module/package paths instead of their names|
|`--golangci-lint-skip-dirs`||false|If configuration file of [golangci-lint](https://golangci-lint.run/usage/configuration/) exists, read `run.skip-dirs` and `run.skip-dirs-use-default` option|