Skip to content

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

  1. Start a new go project

    Terminal window
    mkdir example
    cd example
    go mod init example
  2. Install kibu’s base tool chain

    Terminal window
    go install github.com/google/wire/cmd/wire@latest
    go install github.com/kibu-sh/kibu/internal/toolchain/kibugenv2/cmd/kibugenv2@main
    go install github.com/kibu-sh/kibu/internal/toolchain/kibuwire/cmd/kibuwire@main
  3. Jump start the project structure

    Terminal window
    # this will be our code generation entrypoint
    touch generate.go
    # we need a place to put our first service
    mkdir -p src/backend/systems/health/services
    touch 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:activity
type Activities interface{}
// Service checks the health of the entire system
//
//kibu:service
type 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 ./...
Terminal window
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