I'd like to replace retool with go modules tools.go "tools as dependencies". However I'm struggling to understand how this works when my developers and CI env all use different operating systems.
I want to make sure each environment uses the exact same version of tools.
For a concrete example, my app requires the protoc compiler to generate go code via github.com/golang/protobuf/protoc-gen-go. I have 3 OS, all needing to execute protoc with the protoc-gen-go plugin/generator:
- Ryan: uses MacOS
- Joe: Linux (Ubuntu)
- CI: Linux (CentOS)
I currently use retool to make sure ALL environments are locked in on the same version of tools (protoc-gen-go in this ex):
retool do build/bin/protoc -Ibuild/protoc/include -I. rpc/platform/platform.proto --go_out=.
My new go modules / "tools as dependencies" setup
tools.go:
// +build tools
package tools
import (
_ "github.com/golang/protobuf/protoc-gen-go"
)
Set the path that go install
will use:
export GOBIN=$PWD/bin
Install:
go install github.com/golang/protobuf/protoc-gen-go
If Ryan runs the go install ..
a bin/protoc-gen-go
MacOS executable is created.
Questions:
- At this point, why is
protoc-gen-go
tool version (or git hash) NOT listed in go.mod? - When Joe clones the app repo, how does he get and compile the same version of protoc-gen-go that Ryan used?
- How does
protoc
know to use theprotoc-gen-go
executable generator in my./bin
dir?