From beb045efb51957716a59f11998b6a135120d37df Mon Sep 17 00:00:00 2001 From: bad Date: Sun, 17 Oct 2021 20:39:16 +0200 Subject: [PATCH] Add golangci-lint --- pre-commit.sh | 17 +++++++++++++++++ shell.nix | 3 +-- 2 files changed, 18 insertions(+), 2 deletions(-) create mode 100755 pre-commit.sh diff --git a/pre-commit.sh b/pre-commit.sh new file mode 100755 index 0000000..603b2ad --- /dev/null +++ b/pre-commit.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env bash + +# stolen from somewhere idk where tho tbh + +GOPATH="${GOPATH:-"$HOME/go"}" + +PATH="$PATH:$GOPATH/bin/" + +# Check for golangci-lint +if [[ ! "which golangci-lint 2>&1 > /dev/null" ]]; then + printf "\t\033[41mPlease install golangci-lint\033" + exit 1 +fi + +golangci-lint run --fix --new-from-rev HEAD ./... + +exit 0 diff --git a/shell.nix b/shell.nix index 2db1ebe..7693d99 100644 --- a/shell.nix +++ b/shell.nix @@ -1,5 +1,4 @@ { pkgs ? import {} }: pkgs.mkShell { - # nativeBuildInputs is usually what you want -- tools you need to run - nativeBuildInputs = with pkgs; [ (enableDebugging mosquitto) wireshark delve ]; + nativeBuildInputs = with pkgs; [ go golangci-lint (enableDebugging mosquitto) wireshark delve ]; }