Getting Started
I want to skip the tutorial
If you’re eager to see the outcome of this tutorial, jump straight to our templates’ repo.
Starting from scratch
-
Start a new go project
Terminal window mkdir examplecd examplego mod init example -
Install kibu’s base tool chain
Terminal window go install github.com/google/wire/cmd/wire@latestgo install github.com/kibu-sh/kibu/internal/toolchain/kibugenv2/cmd/kibugenv2@maingo install github.com/kibu-sh/kibu/internal/toolchain/kibuwire/cmd/kibuwire@main -
Jump start the project structure
Terminal window # this will be our code generation entrypointtouch generate.go# we need a place to put our first servicemkdir -p src/backend/systems/health/servicestouch src/backend/systems/health/health.go
Let’s write a simple service interface in Kibu
src/backend/systems/health/health.go
package health
import ( "context")
type CheckRequest struct {}
type CheckResponse struct { Message string `json:"message"`}
// Activities stub until bug is fixed//kibu:activitytype Activities interface{}
// Service checks the health of the entire system////kibu:servicetype Service interface { // Check returns a message letting us know the service is alive // //kibu:service:method method=GET Check(ctx context.Context, req CheckRequest) (res CheckResponse, err error)}
Now, generate some plumbing
generate.go
package generate
// analyze each module and generate system plumbing code//go:generate kibugenv2 ./...
// execute a second pass to generate wire superset//go:generate kibuwire ./...
go generate generate.go
Two new files have manifested
System plumbing for the interfaces we defined.
src/backend/systems/health/health.gen.go
A managed wire superset of all the //kibu:provider
directives in the system.
At scale, kibu makes managing wire sets a breeze across hundreds of services.
kibuwire/kibuwire.gen.go