shortloop-go
provides client implementation of Shortloop SDK for the Go programming
language.
Current SDK version requires Go 1.17 or higher.
For Gin framework, it requires gin version 1.4.0 or higher.
shortloop-go
can be installed like any other Go library through go get
:
$ go get github.com/short-loop/shortloop-go@latest
-
Import sdk in your code
For gin:
import "github.com/short-loop/shortloop-go/shortloopgin"
For mux:
import "github.com/short-loop/shortloop-go/shortloopmux"
-
Initialize the sdk
Example for gin:router := gin.Default() sdk, err := shortloopgin.Init(shortloopgin.Options{ ShortloopEndpoint: "http://localhost:8080", ApplicationName: "test-service-go", LoggingEnabled: true, LogLevel: "INFO", }) if err != nil { fmt.Println("Error initializing shortloopgin: ", err) } else { router.Use(sdk.Filter()) }
Example for mux:
mux := mux.NewRouter() sdk, err := shortloopmux.Init(shortloopmux.Options{ ShortloopEndpoint: "http://localhost:8080", ApplicationName: "test-service-go", LoggingEnabled: true, LogLevel: "INFO", }) if err != nil { fmt.Println("Error initializing shortloopmux: ", err) } else { mux.Use(sdk.Filter) }