Skip to content

Commit 5a103c5

Browse files
author
Jamie Tanna
committed
Add linting with golangci-lint
To give a bit more consistency across the project with the Go ecosystem, as well as picking up on some common errors that new contributions can bring, enable golangci-lint, with default configuration.
1 parent 0ee106e commit 5a103c5

2 files changed

Lines changed: 32 additions & 0 deletions

File tree

.github/workflows/lint.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: Lint project
2+
on: [push, pull_request]
3+
jobs:
4+
build:
5+
name: Build
6+
runs-on: ubuntu-latest
7+
steps:
8+
- name: Check out source code
9+
uses: actions/checkout@v3
10+
11+
- name: Set up Go
12+
uses: actions/setup-go@v3
13+
with:
14+
go-version-file: 'go.mod'
15+
16+
- name: golangci-lint
17+
uses: golangci/golangci-lint-action@v3
18+
with:
19+
# Make sure this matches the version we've got in our `Makefile`
20+
version: v1.50.1

Makefile

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
GOBASE=$(shell pwd)
2+
GOBIN=$(GOBASE)/bin
3+
14
help:
25
@echo "This is a helper makefile for oapi-codegen"
36
@echo "Targets:"
@@ -6,6 +9,15 @@ help:
69
@echo " gin_example generate gin example server code"
710
@echo " tidy tidy go mod"
811

12+
$(GOBIN)/golangci-lint:
13+
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(GOBIN) v1.50.1
14+
15+
.PHONY: tools
16+
tools: $(GOBIN)/golangci-lint
17+
18+
lint: tools
19+
$(GOBIN)/golangci-lint run ./...
20+
921
generate:
1022
go generate ./...
1123

0 commit comments

Comments
 (0)