OpenPeeDeeP / depguard

Go linter that checks if package imports are in a list of acceptable packages.
GNU General Public License v3.0
138 stars 15 forks source link

fallback to pkg root when locating config #78

Closed ardnew closed 9 months ago

ardnew commented 9 months ago

When searching for a config file, only the current working directory is considered.

This change adds a fallback to search the root of the target package when no config file was found.

This allows users to use a single config file at the root of their project to configure all sub-packages, but it does not aggressively go searching for files in any arbitrary parent directory.

Some examples when your working directory is ./cmd/depguard:

.
├── cmd/
│   └── depguard/
│   ├   ├── testfiles/
│   ├   ├── .depguard.yml        # <------ selected
│   ├   ├── depguard*
│   ├   ├── main.go
│   ├   └── main_test.go
│   └   .depguard.yml            # <------ ignored
├── internal/
│   └── utils/
│       ├── .depguard.yml        # <------ ignored
│       ├── errors.go
│       ├── variables.go
│       └── variables_test.go
├── .depguard.yml                # <------ ignored
├── LICENSE
├── README.md
├── depguard.go
├── go.mod
├── go.sum
├── settings.go
└── settings_test.go
.
├── cmd/
│   └── depguard/
│   ├   ├── testfiles/
│   ├   ├── depguard*
│   ├   ├── main.go
│   ├   └── main_test.go
│   └   .depguard.yml            # <------ ignored
├── internal/
│   └── utils/
│       ├── .depguard.yml        # <------ ignored
│       ├── errors.go
│       ├── variables.go
│       └── variables_test.go
├── .depguard.yml                # <------ selected
├── LICENSE
├── README.md
├── depguard.go
├── go.mod
├── go.sum
├── settings.go
└── settings_test.go