Restrict imports in your go project
Перейти к файлу
Djordje Lukic 7e04b6301b Remove duplicate error line 2020-08-20 17:44:56 +02:00
.github/workflows Add CI 2020-08-19 12:22:22 +02:00
e2e Add tests 2020-08-19 12:09:39 +02:00
.dockerignore Containerize build 2020-08-18 17:53:51 +02:00
.gitignore Containerize build 2020-08-18 17:53:51 +02:00
Dockerfile Add tests 2020-08-19 12:09:39 +02:00
LICENSE Initial commit 2020-08-18 15:57:14 +02:00
Makefile Add CI 2020-08-19 12:22:22 +02:00
NOTICE Initial commit 2020-08-18 15:57:14 +02:00
README.md Update readme, add why and explain the configuration 2020-08-18 17:20:51 +02:00
builder.Makefile Add tests 2020-08-19 12:09:39 +02:00
go.mod Add tests 2020-08-19 12:09:39 +02:00
go.sum Add tests 2020-08-19 12:09:39 +02:00
main.go Remove duplicate error line 2020-08-20 17:44:56 +02:00

README.md

import-restrictions

Restrict imports in your go project.

This tools helps maintainers keep dependencies clean when they have multiple packages inside the same repo that shouldn't depend on each other.

Usage

By default this tool will search for a configuration file named import-restrictions.yaml in the current directory, you can give it another configuration file with the flag --configuration.

$ import-restrictions
$ import-restrictions --configuration my-configuration-file.yaml

Configuration

The configuration file is a yaml file with an array of objects that must contain:

  • dir the base directory of the package
  • forbiddenImports a list of packages that are forbidden for all the packages inside dir.

For example:

- dir: ./cmd
  forbiddenImports:
    - bytes
    - github.com/account/repo

The configuration is pretty self-explanatory, with a configuration file like the one above all the packages inside the directory cmd cannot import any of the bytes and github.com/account/repo packages.