Learn more about Streama© – the foundational technology behind our stateful streaming data platform. Learn More

Go

Coralogix provides Go SDK for your Go applications.

Installation

You need to install go-coralogix-sdk package as any other external package:

go install github.com/coralogix/go-coralogix-sdk

After the installation you can import the package:

import (
    coralogix "github.com/coralogix/go-coralogix-sdk"
)

If your Coralogix account top level domain is different than ‘.com’ add the following environment variables:

CORALOGIX_LOG_URL=https://api.CLUSTER_URL:443/api/v1/logs
CORALOGIX_TIME_DELTA_URL=https://api.CLUSTER_URL:443/sdk/v1/time

based on the table:

 EUINUSA
Cluster URLcoralogix.comapp.coralogix.incoralogix.us
Team URL.coralogix.com.app.coralogix.in.app.coralogix.us

Example for India (IN) cluster:
CORALOGIX_LOG_URL=https://api.app.coralogix.in:443/api/v1/logs
CORALOGIX_TIME_DELTA_URL=https://api.app.coralogix.in:443/sdk/v1/time

 

The simple code example:

package main

import (
    coralogix "github.com/coralogix/go-coralogix-sdk"
)

func main() {
    coralogix.SetDebug(true)

    logger := coralogix.NewCoralogixLogger(
        "YOUR_PRIVATE_KEY_HERE",
        "YOUR_APPLICATION_NAME",
        "YOUR_SUBSYSTEM_NAME",
    )
    defer logger.Destroy()

    logger.Debug("Test message 1")
    logger.Info(map[string]string{
        "text":  "Test message 2",
        "extra": "additional",
    })
    logger.Warning("Test message 4")
}

You can find more information about the go-coralogix-sdk package:
The source code: https://github.com/coralogix/go-coralogix-sdk
The code documentation: https://pkg.go.dev/github.com/coralogix/go-coralogix-sdk