Created
November 9, 2020 09:58
-
-
Save burik666/dea2e40c3a4ae970362e5673dfb31c08 to your computer and use it in GitHub Desktop.
Use golangci-lint in docker like locally installed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
CACHE_DIR="/tmp/golint-docker-$USER" | |
DEFAULT_CONFIG="$HOME/.golangci.yml" | |
mkdir -p "$CACHE_DIR" | |
if [ -f "$DEFAULT_CONFIG" ]; then | |
n=$(basename "$DEFAULT_CONFIG") | |
config_file=("-v" "${DEFAULT_CONFIG}:/$n") | |
fi | |
docker run \ | |
--rm -t \ | |
--user "$(id -u):$(id -g)" \ | |
-v "$CACHE_DIR:/.cache" \ | |
-v "$(go env GOPATH)/pkg:/go/pkg" \ | |
-v "$PWD:/app" \ | |
"${config_file[@]}" \ | |
--workdir /app \ | |
golangci/golangci-lint \ | |
golangci-lint "$@" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment