https://github.com/tymonx/docker-go
A Docker image with preinstalled tools for developing, mocking, formatting, linting, building, testing and documenting Go projects. It is only a read-only project mirror. Active development is maintained at the GitLab.
https://github.com/tymonx/docker-go
ci ci-cd cicd continuous-integration continuous-testing devops devops-tools docker docker-image documentation go golang mock mocking productivity programming test testing testing-tools tests
Last synced: 11 days ago
JSON representation
A Docker image with preinstalled tools for developing, mocking, formatting, linting, building, testing and documenting Go projects. It is only a read-only project mirror. Active development is maintained at the GitLab.
- Host: GitHub
- URL: https://github.com/tymonx/docker-go
- Owner: tymonx
- License: apache-2.0
- Created: 2020-05-28T17:20:46.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2021-02-09T08:16:38.000Z (over 4 years ago)
- Last Synced: 2025-03-28T02:42:54.689Z (3 months ago)
- Topics: ci, ci-cd, cicd, continuous-integration, continuous-testing, devops, devops-tools, docker, docker-image, documentation, go, golang, mock, mocking, productivity, programming, test, testing, testing-tools, tests
- Language: Shell
- Homepage: https://gitlab.com/tymonx/docker-go
- Size: 202 KB
- Stars: 2
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Docker Go
A Docker image with preinstalled tools for developing, mocking, formatting, linting,
building, testing and documenting Go projects.## Features
* Pre-installed required tools for developing, mocking, 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
* Formatting and validating Go source files line lengths with the `golines` 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## Example

## Usage
Download the `docker-run.sh` helper script:
```plaintext
wget -O docker-run.sh https://gitlab.com/tymonx/docker-go/-/raw/master/docker-run.sh
```Make it executable:
```plaintext
chmod a+x ./docker-run.sh
```Run the `docker-run.sh` script without any arguments to work in Docker container:
```plaintext
./docker-run.sh
```Or pass arguments to the `docker-run.sh` script to execute commands inside Docker container:
```plaintext
./docker-run.sh go build ./...
```Use the `go-mock` command to create mocks for all automatically detected Go interfaces:
```plaintext
./docker-run.sh go-mock
```Use the `go-format` command to automatically reformat Go source files:
```plaintext
./docker-run.sh go-format
```Use the `go-lint` command to run various Go linters on Go source files with enabled colorization:
```plaintext
./docker-run.sh go-lint
```:exclamation: Notice :exclamation:
To fix Go source code formatting errors from Go linter tools,
use the `./docker-run.sh go-format` script for that.Use the `go-build` command to build Go source files. Equivalent to the `go build ./...` execution:
```plaintext
./docker-run.sh go-build
```Use the `go-test` command to run tests and validate coverage result with enabled colorization:
```plaintext
./docker-run.sh go-test
```Use the `go-test-no-cover` command to run tests without coverage:
```plaintext
./docker-run.sh go-test-no-cover
```To run only a single test:
```plaintext
./docker-run.sh go-test -run ./...
```Running only a single test without coverage:
```plaintext
./docker-run.sh go-test-no-cover -run ./...
```Use the `go-doc` command to run Go source code documentation server for your project on default `localhost:6060`:
```plaintext
./docker-run.sh go-doc
```:exclamation: Notice :exclamation:
It can take some time before server will process all source code files for browsing.
Wait several seconds more and refresh your web browser.All commands accept standard Go paths as additional arguments like `./`, `./...`, `./` and so on.