I am using go v1.19 to build a go application. I have run this application using a service file in linux OS.
Below in my code to initialize the bugsnag:
package main
import (
"github.com/bugsnag/bugsnag-go"
bugsnaggin "github.com/bugsnag/bugsnag-go-gin"
"github.com/gin-gonic/gin"
)
func init() {
BugsnagAutoNotify()
}
func main() {
InitRoutes()
}
var routes = Routes{
Route{"GET", "/test", test},
}
func InitRoutes() {
router := gin.Default()
for _, route := range routes {
switch route.Method {
case "GET":
router.GET(route.Url, route.HandlerFunc)
case "POST":
router.POST(route.Url, route.HandlerFunc)
default:
router.GET(route.Url, func(c *gin.Context) {
c.JSON(200, gin.H{
"result": "Specify a valid http method with this route.",
})
})
}
}
router.Run(":8080")
}
func BugsnagAutoNotify() gin.HandlerFunc {
return bugsnaggin.AutoNotify(bugsnag.Configuration{
APIKey: bugsnagApiKey,
ProjectPackages: []string{"main"},
AppVersion: bugsnagAppVersion,
})
}
But when I call bugsnag.Notify(err, metadata)
in test handler it says following:
bugsnag/defaultReportPublisher.publishReport: bugsnag/payload.deliver: invalid api key: ''
whats wrong here ?
I just changed the import statement to "github.com/bugsnag/bugsnag-go/v2"
and it worked for me.