pkgdep
checks if package dependency follows rule.
config
(required)- Path to the configuration file (e.g.
.pkgdep.yaml
) - Supported file extensions:
.yaml
,.yml
- Path to the configuration file (e.g.
log.level
(optional)- Controls logging verbosity
- Valid values:
DEBUG
,INFO
,WARN
,ERROR
- Default:
INFO
log.file
(optional)- Path to write log output
- If unspecified, logs to stdout
- Note: When using with golangci-lint, a log file must be specified since stdout is captured
log.format
(optional)- Controls log output format
- Valid values:
json
,text
- Default:
json
inspector.file
(optional, experimental)- Path to write inspector output
- If unspecified, inspector output is not saved
- Inspector output contains information about which dependency rules were used
- Warning: The inspector feature is experimental and may change or be removed in future versions without notice.
You can configure via commandline option or golangci setting.
$ go install github.com/cloverrose/pkgdep/cmd/pkgdep@latest
$ make build/pkgdep
See .pkgdep.yaml as example.
We can use regexp.
Detailed Information
dependencies
is unmarshalled into an ordered map. Package dependencies are validated in order, starting from the first entry.
config file path should be absolute.
$ go vet -vettool=`which pkgdep` -pkgdep.config=$(PWD)/.pkgdep.yaml ./...
https://golangci-lint.run/plugins/module-plugins/
Here are reference settings
.custom-gcl.yml
version: v1.64.8
name: custom-golangci-lint
destination: bin
plugins:
- module: 'github.com/cloverrose/pkgdep'
import: 'github.com/cloverrose/pkgdep'
version: v0.6.4
.golangci.yml
config file path can be relative.
linters-settings:
custom:
pkgdep:
type: "module"
description: pkgdep validates if package dependency follows rule.
settings:
config: "./.pkgdep.yaml"
log:
level: "INFO"
file: "./log.txt"
format: "json"
inspector:
file: "./used_rules.csv"
pkgdep-tidy
is a command-line tool that helps clean up and optimize your .pkgdep.yaml
configuration by:
- Removing unused dependency rules
- Cleaning up empty configuration keys
- Maintaining clean, consistent formatting
For detailed usage instructions and examples, see the pkgdep-tidy documentation.