We recently started using Go for new microservices. Each microservice is a Go module, and we manage them as a monorepo:
/
services/
s1/
go.mod
main.go
s2/
go.mod
main.go
This works fine, but now we need to share some code between s1
and s2
- some structs used by both services, a function that uploads to S3, etc.
What's the correct way of managing this situation? Ideally, I'd have a common
directory at the repo root (sibling of services
) and put the common code there - but how will Go take the code from there when compiling s1
and s2
?