英文:
Bugsnag is throwing invalid api key: '' error
问题
我正在使用go v1.19构建一个go应用程序。我已经在Linux操作系统中使用服务文件运行了这个应用程序。
以下是我初始化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,
})
}
但是当我在测试处理程序中调用bugsnag.Notify(err, metadata)
时,它显示以下内容:
bugsnag/defaultReportPublisher.publishReport: bugsnag/payload.deliver: invalid api key: ''
这里有什么问题?
英文:
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 ?
答案1
得分: 1
我刚刚将导入语句更改为"github.com/bugsnag/bugsnag-go/v2"
,对我来说有效。
英文:
I just changed the import statement to "github.com/bugsnag/bugsnag-go/v2"
and it worked for me.
答案2
得分: 0
如果您仍然对此有问题,请随时发送邮件至support@bugsnag.com。
英文:
If you're still having problems with this please feel free to write in to support@bugsnag.com.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论