forked from open-telemetry/opentelemetry-collector-contrib
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add goimports and golangci-lint (#17)
goimports for import rewritting golangci-lint as the configurable linting swiss army knife. These tools are recorded in [tools.go](https://github.com/golang/go/wiki/Modules#how-can-i-track-tool-dependencies-for-a-module). This records them as a dependency to make sure we're all using the same tool versions. To make sure this project's tool's versions don't stomp over versions from other projects, they are installed in ./.tools, which is .gitignored. goimports was run and fixed up a single file: plugin/httptrace/httptrace.go I prefer to group local packages below external packages, hence the use of goimports -local option. .golangci.yml contains nothing but an incomplete set of defaults ATM. I expect those to change over time though. ;-) To use, run: $ make precommit Fixes #15
- Loading branch information
Showing
7 changed files
with
230 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
.tools/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# See https://github.com/golangci/golangci-lint#config-file | ||
run: | ||
issues-exit-code: 1 #Default | ||
tests: true #Default |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
.PHONY: precommit | ||
|
||
TOOLS_DIR := ./.tools | ||
|
||
$(TOOLS_DIR)/golangci-lint: go.mod go.sum tools.go | ||
go build -o $(TOOLS_DIR)/golangci-lint github.com/golangci/golangci-lint/cmd/golangci-lint | ||
|
||
$(TOOLS_DIR)/goimports: go.mod go.sum tools.go | ||
go build -o $(TOOLS_DIR)/goimports golang.org/x/tools/cmd/goimports | ||
|
||
precommit: $(TOOLS_DIR)/goimports $(TOOLS_DIR)/golangci-lint | ||
$(TOOLS_DIR)/goimports -d -local github.com/open-telemetry/opentelemetry-go -w . | ||
$(TOOLS_DIR)/golangci-lint run |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
// +build tools | ||
|
||
package tools | ||
|
||
import ( | ||
_ "github.com/golangci/golangci-lint/cmd/golangci-lint" | ||
_ "golang.org/x/tools/cmd/goimports" | ||
) |