Skip to content

The Trinsic Go SDK

The Trinsic Go SDK makes it easy to interact with the Trinsic API from any Go application. The most recent version of the library can be found on ____. You can find the SDKs source on Github.

Installation and Configuration

If you're installing go on M1, the Standard Go.dev Install Page actually defaults to still showing you an amd64 install pkg even if you're on an M1.

You have to go to the other downloads page to get the arm64 version for sure.

  • NOTE: Windows installation is possible, but requires jumping through a few hoops. More details to come later.
  • Make sure you have the okapi native binaries installed on your machine. Default installation instructions are in the readme.md here
  • You need to have CGO configured for the okapi native binary link
  • Issue the following command:
    go install github.com/trinsic-id/sdk/[email protected]
    
  • To test the installation, try the following go code:
trinsicService, err := sdk.NewTrinsic()
if err != nil {
    panic("Account service not created")
}

profile, err := trinsicService.Account().LoginAnonymous(context.Background())
if err != nil {
    panic("Sign in failed!")
}
fmt.Printf("%v\n", profile)

Next Steps

Once the go package is installed and configured, you're ready to start building! We recommend going through the walkthrough next. If you're ready to dive into building your ecosystem, check out our API Reference

Start Walkthrough Explore API Go API Reference

Diagnostics

M1 Architecture install issues

uname -m
echo $GOARCH

The go architecture and apple processor architecture need to match for the dynamic okapi library loading to work.

The long story short is though, when that happens, it actually sets all the environment variables also to AMD, including GOHOSTARCH, GOARCH, and GOTOOLDIR. This, then causes the bad env variable to impact the linker.

If you receive an error that looks like the following on Apple M1 architecture, it is possible that you have the wrong architecture of golang installed/configured.

panic: unable to open a handle to the library [recovered]
panic: unable to open a handle to the library

Try running a test code with the following env vars set:

GOARCH=arm64  go test ./...

If CGO is not enabled, you will receive an error like the following:

go/pkg/mod/github.com/trinsic-id/okapi/[email protected]/okapi/didcomm.go:22:9: undefined: callOkapiNative

Try running with the following env var set:

CGO_ENABLED=1  go test ./...