From 112d146ece63641620beeb6bd4eeb8b1cbaa9af5 Mon Sep 17 00:00:00 2001 From: Dennis Jekubczyk Date: Mon, 24 May 2021 11:30:49 +0200 Subject: [PATCH] add linter --- Taskfile.yml | 13 +++++++++++++ third_party/golangci-lint/.gitignore | 1 + third_party/golangci-lint/download.sh | 21 +++++++++++++++++++++ 3 files changed, 35 insertions(+) create mode 100644 third_party/golangci-lint/.gitignore create mode 100755 third_party/golangci-lint/download.sh diff --git a/Taskfile.yml b/Taskfile.yml index 1262c96..c2da11a 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -3,13 +3,26 @@ version: '3' silent: true tasks: + install: + desc: install tools required for development or build + cmds: [ task: install-golangci-lint ] + + install-golangci-lint: + desc: install golangci-lint + cmds: [ third_party/golangci-lint/download.sh ] + world: desc: run - literally - evertyhing ;) cmds: + - task: lint - task: test test: cmds: [ go test ./... ] + lint: + desc: lint app + cmds: [ third_party/golangci-lint/golangci-lint run ] + default: cmds: [ task: world ] diff --git a/third_party/golangci-lint/.gitignore b/third_party/golangci-lint/.gitignore new file mode 100644 index 0000000..ef90a32 --- /dev/null +++ b/third_party/golangci-lint/.gitignore @@ -0,0 +1 @@ +golangci-lint diff --git a/third_party/golangci-lint/download.sh b/third_party/golangci-lint/download.sh new file mode 100755 index 0000000..02fb494 --- /dev/null +++ b/third_party/golangci-lint/download.sh @@ -0,0 +1,21 @@ +#!/usr/bin/env bash + +set -eu -o pipefail + +SCRIPT_PATH="$( cd "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )" +BINARY_PATH="$SCRIPT_PATH/golangci-lint" + +DOWNLOAD_URL='' + +if uname -a | grep 'Darwin' &> /dev/null; then + DOWNLOAD_URL='https://github.com/golangci/golangci-lint/releases/download/v1.40.1/golangci-lint-1.40.1-darwin-amd64.tar.gz' +else + DOWNLOAD_URL='https://github.com/golangci/golangci-lint/releases/download/v1.40.1/golangci-lint-1.40.1-linux-amd64.tar.gz' +fi + +cd "$SCRIPT_PATH" +curl -fsSL "$DOWNLOAD_URL" | tar -xz + +BINARY="$(find golangci-lint-*/golangci-lint)" +mv "$BINARY" "$BINARY_PATH" +rm -rf "$(find golangci-lint-*/ -type d)"