Skip to content

Conversation

@yeldiRium
Copy link

golangci-lint always searches the cwd upwards for the closest go.mod and .golangci.yaml file. This means that when linting a .go file, we can safely run golangci-lint from the directory in which the file is contained. In projects with a single go.mod in its root, golangci-lint will find it. In monorepos with a go.mod closer to the file under lint, golangci-lint will find it as well.

The rootDir prefix has to be stripped from the file, since otherwise it will not match the filename reported by golangci-lint.

This is a competing implementation to #66 and resolves #67.
I've commented on the other PR why I think that this approach is simpler and achieves the same thing

golangci-lint always searches the cwd upwards for the closest go.mod and
.golangci.yaml file. This means that when linting a .go file, we can
safely run golangci-lint from the directory in which the file is
contained. In projects with a single go.mod in its root, golangci-lint
will find it. In monorepos with a go.mod closer to the file under lint,
golangci-lint will find it as well.

The rootDir prefix has to be stripped from the file, since otherwise it
will not match the filename reported by golangci-lint.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support multiple go.mod files (monorepo)

1 participant