The Flipt Go SDK supports developing applications in Go against Flipt. It also supports the ability to access the resource management APIs and other systems, such as authentication and metadata.
The SDK supports both Flipts gRPC
and HTTP
RPC APIs.
A majority of this client is generated directly from Flipt's protobuf
definitions.
The Flipt SDK Generator can be found locally within this repository.
- Go
>= v1.20
client ⌄ / server › | <= 1.19.* | >= 1.20.0 |
---|---|---|
0.1.* | ✓ | ✓* |
>= 0.2.* | ✗ | ✓ |
* Backwards compatible, but can only access the "default"
namespace.
go get go.flipt.io/flipt/sdk/go
Constructing an SDK client is easy.
- Pick your transport of choice. Both
grpc
orhttp
are sub-packages with respective implementations. - Pass a constructed
Transport
implementation tosdk.New(...)
. - Optionally pass in a
sdk.ClientAuthenticationProvider
to authenticate your RPC calls.
package main
import (
sdk "go.flipt.io/flipt/sdk/go"
sdkgrpc "go.flipt.io/flipt/sdk/go/grpc"
grpc "google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"
)
func main() {
token := sdk.StaticTokenAuthenticationProvider("a-flipt-client-token")
conn, err := grpc.NewClient("localhost:9000", grpc.WithTransportCredentials(insecure.NewCredentials()))
if err != nil {
panic(err)
}
defer conn.Close()
client := sdk.New(sdkgrpc.NewTransport(conn), sdk.WithAuthenticationProvider(token))
}