Skip to content

Commit e28d129

Browse files
committed
Updated makefile and linter version
1 parent 4f2a6bf commit e28d129

File tree

1 file changed

+25
-13
lines changed

1 file changed

+25
-13
lines changed

.make/go.mk

+25-13
Original file line numberDiff line numberDiff line change
@@ -65,19 +65,31 @@ install-go: ## Install the application (Using Native Go)
6565

6666
.PHONY: lint
6767
lint: ## Run the golangci-lint application (install if not found)
68-
@echo "installing golangci-lint..."
69-
@#Travis (has sudo)
70-
@if [ "$(shell command -v golangci-lint)" = "" ] && [ $(TRAVIS) ]; then curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s v1.55.2 && sudo cp ./bin/golangci-lint $(go env GOPATH)/bin/; fi;
71-
@#AWS CodePipeline
72-
@if [ "$(shell command -v golangci-lint)" = "" ] && [ "$(CODEBUILD_BUILD_ID)" != "" ]; then curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.55.2; fi;
73-
@#GitHub Actions
74-
@if [ "$(shell command -v golangci-lint)" = "" ] && [ "$(GITHUB_WORKFLOW)" != "" ]; then curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sudo sh -s -- -b $(go env GOPATH)/bin v1.55.2; fi;
75-
@#Brew - MacOS
76-
@if [ "$(shell command -v golangci-lint)" = "" ] && [ "$(shell command -v brew)" != "" ]; then brew install golangci-lint; fi;
77-
@#MacOS Vanilla
78-
@if [ "$(shell command -v golangci-lint)" = "" ] && [ "$(shell command -v brew)" != "" ]; then curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- v1.55.2; fi;
79-
@echo "running golangci-lint..."
80-
@golangci-lint run --verbose
68+
@if [ "$(shell which golangci-lint)" = "" ]; then \
69+
if [ "$(shell command -v brew)" != "" ]; then \
70+
echo "Brew detected, attempting to install golangci-lint..."; \
71+
if ! brew list golangci-lint &>/dev/null; then \
72+
brew install golangci-lint; \
73+
else \
74+
echo "golangci-lint is already installed via brew."; \
75+
fi; \
76+
else \
77+
echo "Installing golangci-lint via curl..."; \
78+
GOPATH=$$(go env GOPATH); \
79+
if [ -z "$$GOPATH" ]; then GOPATH=$$HOME/go; fi; \
80+
echo "Installation path: $$GOPATH/bin"; \
81+
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $$GOPATH/bin v1.56.2; \
82+
fi; \
83+
fi; \
84+
if [ "$(TRAVIS)" != "" ]; then \
85+
echo "Travis CI environment detected."; \
86+
elif [ "$(CODEBUILD_BUILD_ID)" != "" ]; then \
87+
echo "AWS CodePipeline environment detected."; \
88+
elif [ "$(GITHUB_WORKFLOW)" != "" ]; then \
89+
echo "GitHub Actions environment detected."; \
90+
fi; \
91+
echo "Running golangci-lint..."; \
92+
golangci-lint run --verbose
8193

8294
.PHONY: test
8395
test: ## Runs lint and ALL tests

0 commit comments

Comments
 (0)