Skip to content

Commit

Permalink
Add golangci-lint and goimports installation to Makefile (#7)
Browse files Browse the repository at this point in the history
- Add golangci-lint and goimports installation to Makefile
- Bump golangci-lint version in GH lint workflow
  • Loading branch information
afritzler authored Dec 30, 2023
1 parent a141121 commit 719f805
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ jobs:
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: v1.54.2
version: v1.55.2
23 changes: 19 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ help: ## Display this help.
##@ Development

.PHONY: fmt
fmt: ## Run go fmt against code.
go fmt ./...
fmt: goimports ## Run goimports against code.
$(GOIMPORTS) -w .

.PHONY: vet
vet: ## Run go vet against code.
Expand All @@ -52,8 +52,9 @@ add-license: addlicense ## Add license headers to all go files.
check-license: addlicense ## Check that every file has a license header present.
find . -name '*.go' -exec $(ADDLICENSE) -c 'Andreas Fritzler' {} +

lint: ## Run golangci-lint against code.
golangci-lint run ./...
.PHONY: lint
lint: golangci-lint ## Run golangci-lint on the code.
$(GOLANGCI_LINT) run ./...

check: add-license lint test

Expand All @@ -66,11 +67,25 @@ $(LOCALBIN):

## Tool Binaries
ADDLICENSE ?= $(LOCALBIN)/addlicense
GOIMPORTS ?= $(LOCALBIN)/goimports
GOLANGCI_LINT ?= $(LOCALBIN)/golangci-lint

## Tool Versions
ADDLICENSE_VERSION ?= v1.1.1
GOIMPORTS_VERSION ?= v0.13.0
GOLANGCI_LINT_VERSION ?= v1.55.2

.PHONY: addlicense
addlicense: $(ADDLICENSE) ## Download addlicense locally if necessary.
$(ADDLICENSE): $(LOCALBIN)
test -s $(LOCALBIN)/addlicense || GOBIN=$(LOCALBIN) go install github.com/google/addlicense@$(ADDLICENSE_VERSION)

.PHONY: goimports
goimports: $(GOIMPORTS) ## Download goimports locally if necessary.
$(GOIMPORTS): $(LOCALBIN)
test -s $(LOCALBIN)/goimports || GOBIN=$(LOCALBIN) go install golang.org/x/tools/cmd/goimports@$(GOIMPORTS_VERSION)

.PHONY: golangci-lint
golangci-lint: $(GOLANGCI_LINT) ## Download golangci-lint locally if necessary.
$(GOLANGCI_LINT): $(LOCALBIN)
test -s $(LOCALBIN)/golangci-lint || GOBIN=$(LOCALBIN) go install github.com/golangci/golangci-lint/cmd/golangci-lint@$(GOLANGCI_LINT_VERSION)
1 change: 1 addition & 0 deletions example/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package main

import (
"errors"

"github.com/afritzler/streetlogr"
"github.com/go-logr/zapr"
"go.uber.org/zap"
Expand Down

0 comments on commit 719f805

Please sign in to comment.