- Go 93%
- Makefile 5.1%
- HTML 1.4%
- AMPL 0.5%
Go Common
Overview
Common code shared by other Go services
Quickstart
- Clone the repo
- Update submodules with the following commands
git submodule init
git submodule update
- Ensure you have go 1.24.x installed
- Ensure you have the protocol buffers compiler (protoc) installed
- Download dependencies with
make download
make download_tools
- Install
goplslanguage server with
make install_gopls
- Run tests with the following
make generate
make test_clean
IMPORTANT
Make sure that you update the version number in VERSION and create a
new tag when you make ANY changes/fixes to this repository
Go uses the tags for versioning of code and you'll need to make sure that repos
using this common code are updated to pick up the new version. This repo follows
semantic versioning and the version in the VERSION file
MUST always be updated on code changes.
Follow these step for this repo
- Create a branch with a fix/change and increment the version in
VERSION - For bug/minor fixes, just the patch version could be changed
- For new, non-breaking, functionality increase the minor number
- For significant or breaking changes, increment the major number
- Reset minor/patch numbers to
0if you increment major/minor, e.g. 0.1.3 -> 1.0.0, or 0.1.4 -> 0.2.0 - Once the branch is reviewed and merged then switch to the
mainbranch locally - Run this command to create a tag and push it
TODO: Automate the tagging steps below
git pull # Just make sure your branch is up to date with origin/main
git tag v`cat VERSION`
git push --tags
- In repositories that use the common code and need the new fix run this
go get -u codeberg.org/fionahiklas/go-common
- This should pull the latest version of the common code and update the
go.modfile
Notes
Go Tools
Initial install of tools packages
go get -tool -modfile=go.imports.mod golang.org/x/tools/cmd/goimports
go get -tool -modfile=go.mock.mod go.uber.org/mock/mockgen
go get -tool -modfile=go.grpc.mod google.golang.org/protobuf/cmd/protoc-gen-go
go get -tool -modfile=go.grpc.mod google.golang.org/grpc/cmd/protoc-gen-go-grpc
go get -tool -modfile=go.telemetry.mod github.com/open-telemetry/opentelemetry-collector-contrib/cmd/telemetrygen
go get -tool -modfile=go.lint.mod github.com/golangci/golangci-lint/cmd/golangci-lint
go get -tool -modfile=go.gopls.mod golang.org/x/tools/gopls
We have to load the tools into their own module files because of conflicts in libraries. At time of writing (2026年05月08日) the gopls tool still uses an older version of golang.org/x/tools which then clashes with newer versions used in other tools. Overall the mix of my code's dependencies and those for tools was getting out of hand hence the move to seperate files.
Protocol Buffers
Installing the protocol buffers compiler on various platoforms
Mac
brew install protobuf protoc-gen-go
Linux
On Alpine Linux
apk add protoc
Setting up submodules
The OpenTelemetry submodule was setup as follows
git submodule add https://github.com/open-telemetry/opentelemetry-proto submodules/opentelemetry-proto
This updates the git repo so needs to be committed and pushed