Go API Project Set-Up

This page summarizes the projects mentioned and recommended in the original post on dev.to

Our great sponsors
  • WorkOS - The modern identity platform for B2B SaaS
  • InfluxDB - Power Real-Time Data Analytics at Scale
  • SaaSHub - Software Alternatives and Reviews
  • golang-standards/project-layout

    Standard Go Project Layout

    In the case of a Go-based project my starting point is the project layout which is documented in the golang-standards Project Layout.

  • gomock

    Discontinued GoMock is a mocking framework for the Go programming language. (by golang)

    Unit tests are leveraged to test individual units of code. As such it is not recommended for a developer to scaffold entire dependencies for the sake of testing a single object. Due to the way Go's specific implementations work, I've learned over time to declare interfaces for a lot of the structs that I use in Go. Interfaces not only define a contract for which struct-based implementations should adhere, but they also provide a mechanism for which struct methods can be mocked. While I've experimented with the mock package in testify, I've come to prefer the mock functionality which is provided by mockgen.

  • WorkOS

    The modern identity platform for B2B SaaS. The APIs are flexible and easy-to-use, supporting authentication, user identity, and complex enterprise features like SSO and SCIM provisioning.

  • gotestsum

    'go test' runner with output optimized for humans, JUnit XML for CI integration, and a summary of the test results.

    The go test command does not support test reporting out of the box. To generate a test report, we have to use gotestsum to generate a JUnit report. We add gotestsum to our tools.go file:

  • gocover-cobertura

    golang : go tool cover to XML (Cobertura) export tool.

    To report coverage to GitLab we have to use a tool which can convert the coverage report from go test to Cobertura. We'll pull in gocover-cobertura to generate our coverage report.

  • hub-feedback

    Feedback and bug reports for the Docker Hub

    The next block in .gitlab-ci.yml is the services block. Since our tests use testcontainers package and we're pushing a docker container onto Dockerhub, we will need to specify a services block next. Services will enable our pipeline to leverage Docker-in-Docker DinD.

  • testcontainers-go

    Testcontainers for Go is a Go package that makes it simple to create and clean up container-based dependencies for automated integration/smoke tests. The clean, easy-to-use API enables developers to programmatically define containers that should be run as part of a test and clean up those resources when the test is done.

    The next block in .gitlab-ci.yml is the services block. Since our tests use testcontainers package and we're pushing a docker container onto Dockerhub, we will need to specify a services block next. Services will enable our pipeline to leverage Docker-in-Docker DinD.

  • golangci-lint

    Fast linters Runner for Go

    golangci lint - https://golangci-lint.run/

  • InfluxDB

    Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.

NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts