DEV Community

Tymoteusz Blazejczyk
Tymoteusz Blazejczyk

Posted on

2 2

A Docker image with preinstalled tools for developing, formatting, linting, building, testing and documenting Go projects

Docker Go

A Docker image with preinstalled tools for developing, formatting, linting,
building, testing and documenting Go projects.

Project site: https://gitlab.com/tymonx/docker-go

For GitLab CI: https://gitlab.com/tymonx/gitlab-ci

Features

  • Pre-installed required tools for developing, formatting, linting, building, testing and documenting Go projects
  • Pre-installed the mockgen tool for generating mocks for testing
  • Formatting and validating Go source files imports with the goimports tool
  • Formatting and validating Go source files format with the gofmt tool
  • Validating Go source files errors with the errcheck tool
  • Linting Go source files with the revive, the golangci-lint and the golint tools
  • Building Go source files
  • Testing Go project
  • Generating Go coverage result, text and HTML reports
  • Generating JUnit test XML report for GitLab Merge Requests
  • Generating Cobertura coverage XML report for GitLab Merge Requests
  • Validating Go coverage value threshold with colorization
  • Colorizing Go imports and format validation with the colordiff tool
  • Colorizing Go tests with the richgo tool
  • Colorizing Go coverage results and format nicely with the column tool
  • Generating static HTML coverage report with the go tool cover tool

Usage

Download the docker-run.sh helper script:

wget -O docker-run.sh https://gitlab.com/tymonx/docker-go/-/raw/master/docker-run.sh

Make it executable:

chmod a+x ./docker-run.sh

Run the docker-run.sh script without any arguments to work in Docker container:

./docker-run.sh

Or pass arguments to the docker-run.sh script to execute commands inside Docker container:

./docker-run.sh go build ./...

Use the go-format command to automatically reformat Go source files:

./docker-run.sh go-format

Use the go-lint command to run various Go linters on Go source files with enabled colorization:

./docker-run.sh go-lint

Use the go-build command to build Go source files. Equivalent to the go build ./... execution:

./docker-run.sh go-build

Use the go-test command to run tests and validate coverage result with enabled colorization:

./docker-run.sh go-test

All commands accept standard Go paths as additional arguments like ./, ./..., <package-name> and so on.

AWS Q Developer image

Your AI Code Assistant

Ask anything about your entire project, code and get answers and even architecture diagrams. Built to handle large projects, Amazon Q Developer works alongside you from idea to production code.

Start free in your IDE

Top comments (0)

Eliminate Context Switching and Maximize Productivity

Pieces.app

Pieces Copilot is your personalized workflow assistant, working alongside your favorite apps. Ask questions about entire repositories, generate contextualized code, save and reuse useful snippets, and streamline your development process.

Learn more

👋 Kindness is contagious

Engage with a wealth of insights in this thoughtful article, valued within the supportive DEV Community. Coders of every background are welcome to join in and add to our collective wisdom.

A sincere "thank you" often brightens someone’s day. Share your gratitude in the comments below!

On DEV, the act of sharing knowledge eases our journey and fortifies our community ties. Found value in this? A quick thank you to the author can make a significant impact.

Okay