Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Go SDK

This is the README that tungsten generates for the Go target, shown for a small example API (Swagger's Petstore). Names change with your API; the structure does not.

These recorded examples retain their original generator and runtime versions. Their installation snippets name example generated packages; they are not a current registry installation recipe. See runtime distribution for the verified stable 0.1.2 package versions and matching source routes for the unreleased 0.1.3 candidate.

Generated by tungsten (tungsten-emit-go 0.1.0) from the API description. Do not edit the generated files; regenerate them with tungsten generate.

Install

go get example.com/openapi-sdk-go

The SDK runs on github.com/pboachie/tungsten/runtimes/go v0.1.3 (Go 1.22 or later, standard library only).

Use

client, err := openapi.New(tungsten.ClientOptions{
	Auth: tungsten.AuthConfig{ /* credentials by scheme name */ },
})
if err != nil {
	return err
}
result, err := client.Pets().List(ctx, openapi.PetsListRequest{}, tungsten.CallOptions{})
var failure *tungsten.Error
if errors.As(err, &failure) {
	// failure.Diagnostic is the error envelope: category, retryable,
	// remediation, next_action. Partial keeps what a failed call produced.
}

Every method takes a context.Context, the operation's request struct and tungsten.CallOptions (IdempotencyKey, Confirm, Timeout, Verify, Headers). Failures are *tungsten.Error values carrying the diagnostic envelope, the same in every tungsten runtime. Destructive and irreversible operations need confirmation: call the Preview... method and pass its token as Confirm: tungsten.ConfirmToken(token). Paginated operations have a ...Pages iterator, event streams a ...Stream iterator.

Operations

OperationMethodSafety
openapi.listPetsclient.Pets().Listread-only
openapi.createPetsclient.Pets().Createmutating
openapi.showPetByIdclient.Pets().Getread-only