Skip to main content

Go SDK

This page dives into the nitty-gritty details on installing Rookout under various configurations. If you encounter difficulties with deploying Rookout, this is the place to look.

Setup

Get the package

Run the following inside your app’s directory to add the Rookout SDK to the go.mod file:


go get -d github.com/Rookout/GoSDK

Start Rookout within your application

Go to the file containing your main function and import Rookout:


import (
rookout "github.com/Rookout/GoSDK"
)

Then, in your main function, as early as possible, call rookout.Start:

rookout.Start(rookout.RookOptions{token=[Your Rookout Token], labels=map[string]string{"env": "dev"}})

Build the application


go build -gcflags="all=-dwarflocationlists=true"

SDK Configuration

Start


Start(labels)

The Start method is used to initialize the SDK and it accepts the following variables:

Environment Variable                       Default ValueDescription
ROOKOUT_TOKENNoneThe Rookout token for your organization
ROOKOUT_LABELS{}A dictionary of key:value labels for your application instances. Use k:v,k:v format for environment variables
ROOKOUT_COMMITNoneString that indicates your git commit or a branch name
ROOKOUT_REMOTE_ORIGINNoneString that indicates your git remote origin
ROOKOUT_CONTROLLER_HOSTNoneIf you are using a Rookout ETL Controller, this is the hostname for it
ROOKOUT_CONTROLLER_PORTNoneIf you are using a Rookout ETL Controller, this is the port for it
ROOKOUT_PROXYNoneURL to proxy server
ROOKOUT_DEBUGFalseSet to True to increase log level to debug
ROOKOUT_SOURCESNoneSource information (see below)
ROOKOUT_QUIETFalseSet to True to stop informative log messages from being written to the standard output and error

Supported Versions

Rookout supports Go version 1.15 to 1.19 on Mac and Linux (Debian, Alpine, Photon, etc) operating systems.

Dependencies

Depending on your OS, you may need to install additional dependencies:


apt update && apt install -y libffi-dev zlib1g-dev libedit-dev libc++-11-dev libc++abi-11-dev

CGO

Rookout requires CGO which is enabled by default.

To verify your configuration you can run:


echo ${CGO_ENABLED} && go env | grep CGO_ENABLED

Linker flags

Rookout requires the Go binary to include a symbol table.

Please avoid setting the -w and -s ldflags, as doing so causes the application to omit these tables.

Alpine OS

Please make sure to add -tags=alpine to your go build command when running on Alpine.

Forgetting to do so will result in error: ld returned 1 exit status.

Cross compiling

Cross compiling Go applications can get tricky, feel free to reach out to us with any questions :)