Skip to content
This repository has been archived by the owner on Jan 25, 2023. It is now read-only.

highlight/highlight-go

Repository files navigation

Go Report Card GoDoc codecov

highlight-go

Official implementation of the Highlight backend client in Go.

Usage

First, import the package

go get -u github.com/highlight-run/highlight-go

Then, add the following lines to your applications main function:

import (
	"github.com/highlight-run/highlight-go"
)

func main() {
	//...application logic...
	highlight.Start()
	defer highlight.Stop()
	//...application logic...
}

Then, use a highlight middleware in your apps router:

if you're using go-chi/chi:

import (
	highlightChi "github.com/highlight-run/highlight-go/middleware/chi"
)

func main() {
	//...
	r := chi.NewMux()
	r.Use(highlightChi.Middleware)
	//...
}

if you're using gin-gonic/gin:

import (
	highlightGin "github.com/highlight-run/highlight-go/middleware/gin"
)

func main() {
	//...
	r := gin.New()
	r.Use(highlightGin.Middleware())
	//...
}

Finally, it's time to consume errors. Add the following line to your error handling:

func someEndpoint() {
	err := someFuntionCall()
	if err != nil {
		highlight.ConsumeError(err)
		// including optional tags:
		highlight.ConsumeError(err, "environment:dev", "important")
	}
}