Go Service (opens in a new tab)

Coverage (opens in a new tab) Quality (opens in a new tab) Documentation (opens in a new tab) CI/CD (opens in a new tab) Promo (opens in a new tab) Mirror (opens in a new tab) Template (opens in a new tab)

🧩 Service

Template for a typical service written on Go.

🛫 Quick start

Work with Makefile
$ make setup
$ make help
 
$ make find-todos
$ make test lint
$ TIMEOUT=5s make test-with-coverage
Work with Taskfile
$ alias run=./Taskfile
$ run refresh
$ run help
 
$ run docs # === `run docs install -- build -- start`
$ run docs npm ci
$ run docs npm i nextra@latest
 
$ run tools go generate tools.go
$ run tools golangci-lint --version -- mockgen --version
$ run which goimports golangci-lint govulncheck mockgen
Work with Tools
$ make tools
$ source bin/activate
 
$ which goimports
$ goimports -local $(go list -m) -w ./...
Work with Docker
$ make go-1.19 # or go-1.20, etc.
/src# make go-env 2>/dev/null | grep GOVERSION
# GOVERSION:   1.19.10
/src# make test

💡 Idea

Define a powerful template that quickly creates a new Go service. Not only does it provide a starting point for new projects, but it comes equipped with pre-configured ci/cd and inventory.

$ server up &
$ client call

🏆 Motivation

At OctoLab (opens in a new tab), we want to start new projects faster using best practices with a predefined structure and focusing on core ideas implementation rather than wasting time on environment configuration and copying boilerplate code.

🤼‍ How to

Build your own service

  1. Generate (opens in a new tab) a new repository from the template.
  2. Clone the repository locally.
  3. Update the desired files as needed, e.g., run init my.new/service.
  4. Write your code and tests.
  5. 🚀

Contribute to the template

  1. Read the contribution guidelines (opens in a new tab).
  2. Fork (opens in a new tab) the repository.
  3. Make your changes.
  4. Send a pull request.
  5. 🤗

Before you start, please make sure your changes are in demand. The best for that is to create a new discussion (opens in a new tab), or if you find an issue, report it (opens in a new tab) first.

🎛️ Configuration

Pre-configured

  1. GitHub Actions (opens in a new tab).
  2. GitHub Pages (opens in a new tab).
  3. Dependabot (opens in a new tab).

Included

  1. Nextra (opens in a new tab).
  2. Makefiles (opens in a new tab).
  3. Taskfiles (opens in a new tab).
  4. Go tools (opens in a new tab): mockgen (opens in a new tab), golangci-lint (opens in a new tab), goimports (opens in a new tab), govulncheck (opens in a new tab), protobuf (opens in a new tab)

Optional

  1. Bitbucket (opens in a new tab)1.
  2. Codecov (opens in a new tab).
  3. Slack (opens in a new tab).
  4. Settings (opens in a new tab)2.
  5. Go Report Card (opens in a new tab).
  6. Shields.io (opens in a new tab).
  7. GitHub Socialify (opens in a new tab).

Coming soon

  1. CodeQL (opens in a new tab) (code scanning).
  2. Graphite (opens in a new tab) (git workflow).
  3. Qodana (opens in a new tab) (code quality).
  4. SonarCloud (opens in a new tab) (code quality).
  5. Vanity URL (opens in a new tab) (canonical import path).
  6. Vercel (opens in a new tab) (docs preview).

🛬 Installation

Homebrew

$ brew install octolab/tap/service

Binary

$ curl -fsSL https://install.octolab.org/octomation/service | sh
# or
$ wget -qO-  https://install.octolab.org/octomation/service | sh

Source

# use standard go tools
$ go get go.octolab.org/template/service/cmd/client@latest
$ go get go.octolab.org/template/service/cmd/server@latest
# or use egg tool
$ egg tools add go.octolab.org/template/tool/cmd/client@latest
$ egg tools add go.octolab.org/template/tool/cmd/server@latest

Shell completions

$ client completion > /path/to/completions/...
# or
$ source <(client completion)

🏗️ Ecosystem

Input

Impact

Output

made with ❤️ for everyone by OctoLab

Footnotes

  1. An alternative for backup could be GitLab (opens in a new tab), Gogs (opens in a new tab), or Gitea (opens in a new tab).

  2. It has been deprecated and will be replaced someday by GitHub Actions (opens in a new tab).