Skip to content

Instantly share code, notes, and snippets.

@burik666
Created November 9, 2020 09:58
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save burik666/dea2e40c3a4ae970362e5673dfb31c08 to your computer and use it in GitHub Desktop.
Save burik666/dea2e40c3a4ae970362e5673dfb31c08 to your computer and use it in GitHub Desktop.
Use golangci-lint in docker like locally installed.
#!/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