Docker image for gofmt

November 5, 2022 · View on GitHub

Tag License

lint build nightly

All #awesome-ci Docker images

ansible-lint ansible awesome-ci bandit black checkmake eslint file-lint gofmt goimports golint jsonlint kubeval linkcheck mypy php-cs-fixer phpcbf phpcs phplint pycodestyle pydocstyle pylint terraform-docs terragrunt-fmt terragrunt yamlfmt yamllint

View Dockerfiles on GitHub.

Available Architectures: amd64, i386, arm64, arm/v7

Tiny Alpine-based multistage-build dockerized version of gofmt[1], which adds the additional --ci argument[2] via a shell wrapper to ensure to exit > 0 if file diffs occur. The image is built nightly against multiple stable versions and pushed to Dockerhub.

:whale: Available Docker image versions

Docker

Rolling releaess

The following Docker image tags are rolling releases and are built and updated every night.

nightly

Docker TagGit RefgofmtAvailable Architectures
latestmasterlatestamd64, i386, arm64, arm/v7

Point in time releases

The following Docker image tags are built once and can be used for reproducible builds. Its version never changes so you will have to update tags in your pipelines from time to time in order to stay up-to-date.

build

Docker TagGit RefgofmtAvailable Architectures
latest-<tag>tag: <tag>latestamd64, i386, arm64, arm/v7

Where <tag> refers to the chosen git tag from this repository.

:open_file_folder: Docker mounts

The working directory inside the Docker container is /data/ and should be mounted locally to the root of your project.

:computer: Usage

General

$ docker run --rm cytopia/gofmt --help

Usage: cytopia/gofmt [flags] [path...]
       cytopia/gofmt [--ci] [-r rule] [-se] [path...]
       cytopia/gofmt --help

Dockerized version of gofmt with an addition to fail (exit 1) in case of file changes.

Additional wrapper features:
----------------------------
--ci      This option will print the diff to stdout (similar to '-d') and if a diff
          exists it will fail with exit 1.
          Can only be combined with '-r rule', '-s' and '-e'.
          To be used in continuous integration with explicit failing.

Default gofmt flages:
----------------------------
-d        Do not print reformatted sources to standard output.
          If a file's formatting is different than gofmt's, print diffs
          to standard output.
-e        Print all (including spurious) errors.
-l        Do not print reformatted sources to standard output.
          If a file's formatting is different from gofmt's, print its name
          to standard output.
-r rule   Apply the rewrite rule to the source before reformatting.
-s        Try to simplify code (after applying the rewrite rule, if any).
-w        Do not print reformatted sources to standard output.
          If a file's formatting is different from gofmt's, overwrite it
          with gofmt's version. If an error occurred during overwriting,
          the original file is restored from an automatic backup.

Default gofmt usage

# Print diff to stdout and exit 0
$ docker run --rm -v $(pwd):/data cytopia/gofmt -d .

CI wrapper usage

# Print diff to stdout and exit > 0 if diff occurs
$ docker run --rm -v $(pwd):/data cytopia/gofmt --ci .

Docker images

Save yourself from installing lot's of dependencies and pick a dockerized version of your favourite linter below for reproducible local or remote CI tests:

GitHubDockerHubTypeDescription
awesome-ciaci-hub-imgBasicTools for git, file and static source code analysis
file-lintflint-hub-imgBasicBaisc source code analysis
linkchecklinkcheck-hub-imgBasicSearch for URLs in files and validate their HTTP status code
ansibleansible-hub-imgAnsibleMultiple versions and flavours of Ansible
ansible-lintalint-hub-imgAnsibleLint Ansible
gofmtgfmt-hub-imgGoFormat Go source code [1]
goimportsgimp-hub-imgGoFormat Go source code [1]
golintglint-hub-imgGoLint Go code
eslintelint-hub-imgJavascriptLint Javascript code
jsonlintjlint-hub-imgJSONLint JSON files [1]
kubevalkubeval-hub-imgK8sLint Kubernetes files
checkmakecm-hub-imgMakeLint Makefiles
phpcbfpcbf-hub-imgPHPPHP Code Beautifier and Fixer
phpcspcs-hub-imgPHPPHP Code Sniffer
phplintplint-hub-imgPHPPHP Code Linter [1]
php-cs-fixerpcsf-hub-imgPHPPHP Coding Standards Fixer
banditbandit-hub-imgPythonA security linter from PyCQA
blackblack-hub-imgPythonThe uncompromising Python code formatter
mypymypy-hub-imgPythonStatic source code analysis
pycodestylepycs-hub-imgPythonPython style guide checker
pydocstylepyds-hub-imgPythonPython docstyle checker
pylintpylint-hub-imgPythonPython source code, bug and quality checker
terraform-docstfdocs-hub-imgTerraformTerraform doc generator (TF 0.12 ready) [1]
terragrunttg-hub-imgTerraformTerragrunt and Terraform
terragrunt-fmttgfmt-hub-imgTerraformterraform fmt for Terragrunt files [1]
yamlfmtyfmt-hub-imgYamlFormat Yaml files [1]
yamllintylint-hub-imgYamlLint Yaml files

[1] Uses a shell wrapper to add enhanced functionality not available by original project.

Makefiles

Visit cytopia/makefiles for dependency-less, seamless project integration and minimum required best-practice code linting for CI. The provided Makefiles will only require GNU Make and Docker itself removing the need to install anything else.

:page_facing_up: License

MIT License

Copyright (c) 2019 cytopia