From 7dd5f1168b23978b93bff534f10eab43ce600123 Mon Sep 17 00:00:00 2001 From: lpmatos Date: Tue, 4 Oct 2022 01:10:57 -0300 Subject: [PATCH] fix: brew setup, golangci and make commands --- .golangci.yml | 2 ++ .goreleaser.yaml | 2 ++ Makefile | 33 ++++++++++++++++++++++++++++++--- internal/log/logger.go | 1 + 4 files changed, 35 insertions(+), 3 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 4b8d496..f2f2eda 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -9,6 +9,7 @@ run: linters: enable-all: false enable: + - bodyclose - errcheck - gosimple - govet @@ -18,6 +19,7 @@ linters: - typecheck - stylecheck - unused + - nilerr - misspell - whitespace disable: diff --git a/.goreleaser.yaml b/.goreleaser.yaml index a6d835a..a0204d6 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -66,6 +66,8 @@ brews: homepage: "https://github.com/ci-monk/loli" description: "Install Loli CLI with brew and find animes passing images" license: "MIT" + install: | + bin.install "loli" release: github: owner: ci-monk diff --git a/Makefile b/Makefile index c4bee25..b86d822 100644 --- a/Makefile +++ b/Makefile @@ -39,6 +39,13 @@ endif GO := go GOOS := $(shell go env GOOS) GOARCH := $(shell go env GOARCH) +ifeq (,$(shell go env GOBIN)) +GOBIN=$(shell go env GOPATH)/bin +else +GOBIN=$(shell go env GOBIN) +endif + +GOLANGCILINT_VERSION ?= v1.46.2 # NOTE: '-race' requires cgo; enable cgo by setting CGO_ENABLED=1 BUILD_FLAG := -race @@ -68,12 +75,15 @@ help: @echo "make setup" @echo "make build" @echo "make install" - @echo "make lint" - @echo "make test" - @echo "make misspell" @echo "make clean" + @echo "make lint" + @echo "make verify-goreleaser" + @echo "make snapshot" + @echo "make release" @echo "" + + ################################################## # GOLANG SHORTCUTS ################################################## @@ -105,6 +115,23 @@ clean: rm -rf ./bin/* ./vendor ./dist *.tar.gz @echo "" +golangci: +ifeq (, $(shell which golangci-lint)) + @{ \ + set -e ;\ + echo 'installing golangci-lint-$(GOLANGCILINT_VERSION)' ;\ + curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(GOBIN) $(GOLANGCILINT_VERSION) ;\ + echo 'Install succeed' ;\ + } +GOLANGCILINT=$(GOBIN)/golangci-lint +else +GOLANGCILINT=$(shell which golangci-lint) +endif + +.PHONY: lint +lint: golangci + $(GOLANGCILINT) run ./... + .PHONY: verify-goreleaser verify-goreleaser: ifeq (, $(shell which goreleaser)) diff --git a/internal/log/logger.go b/internal/log/logger.go index cce22e3..2621527 100644 --- a/internal/log/logger.go +++ b/internal/log/logger.go @@ -1,3 +1,4 @@ +//nolint:errcheck package log func applyOptions(opts []Option) *options {