api-go-sdk
is the Buddy SDK for the Go programming language.
The SDK requires a minimum version of Go 1.21
.
Checkout out our blog for information about the latest changes
To get started working with the SDK setup your project for Go modules, and retrieve the SDK dependencies with go get
.
This example shows how you can use the SDK to make an API request using the SDK's client.
$ mkdir ~/buddytest
$ cd ~/buddytest
$ go mod init buddytest
$ go get github.com/buddy/api-go-sdk
In your preferred editor add the following content to main.go
package main
import (
"fmt"
"github.com/buddy/api-go-sdk/buddy"
"os"
)
func main() {
client, err := buddy.NewDefaultClient(os.Getenv("BUDDY_TOKEN"))
if err != nil {
fmt.Printf("Error: %s", err.Error())
os.Exit(1)
}
profile, _, err := client.ProfileService.Get()
if err != nil {
fmt.Printf("Error: %s", err.Error())
os.Exit(1)
} else {
fmt.Printf("My name is %s", profile.Name)
}
}
For more examples go to examples directory
Full API docs can be found here