登录
首页 >  Golang >  Go问答

如何登录到滚动条

来源:stackoverflow

时间:2024-04-14 14:39:32 249浏览 收藏

“纵有疾风来,人生不言弃”,这句话送给正在学习Golang的朋友们,也希望在阅读本文《如何登录到滚动条》后,能够真的帮助到大家。我也会在后续的文章中,陆续更新Golang相关的技术文章,有好的建议欢迎大家在评论留言,非常感谢!

问题内容

rollbar.com 网站上有一个示例 go 代码,该代码应该说明如何将日志项发送到 rollbar:

package main

import (
  "github.com/rollbar/rollbar-go"
)

func main() {
  rollbar.SetToken("6a...16")
  rollbar.SetEnvironment("production")                 // defaults to "development"
  rollbar.SetCodeVersion("v2")                         // optional Git hash/branch/tag (required for GitHub integration)
  rollbar.SetServerHost("web.1")                       // optional override; defaults to hostname
  rollbar.SetServerRoot("github.com/heroku/myproject") // path of project (required for GitHub integration and non-project stacktrace collapsing)

  result, err := DoSomething()
  if err != nil {
    rollbar.Critical(err)
  }

  rollbar.Info("Message body goes here")

  rollbar.Wait()
}

不幸的是,此代码无法编译,因为调用的 dosomething 函数不存在。但即使我解决了这个问题并创建了一个名为 dosomething 的函数,它仍然不会将任何内容记录到 rollbar 中。

我应该如何从 go 代码登录到 rollbar?


解决方案


这是一个从 go 代码登录到 rollbar 的接近最小的代码:

package main

import (
    "github.com/rollbar/rollbar-go"
    "time"
)

func main() {
    rollbar.SetToken("7135d6a90b1c4a6d9dbc736fb97d3816")
    rollbar.SetEnvironment("production")                 // defaults to "development"

    rollbar.Info("Message body goes here")
    rollbar.WrapAndWait(DoSomething)
}

func DoSomething() {
    var timer *time.Timer = nil
    timer.Reset(10) // this will panic
}

文中关于的知识介绍,希望对你的学习有所帮助!若是受益匪浅,那就动动鼠标收藏这篇《如何登录到滚动条》文章吧,也可关注golang学习网公众号了解相关技术文章。

声明:本文转载于:stackoverflow 如有侵犯,请联系study_golang@163.com删除
相关阅读
更多>
最新阅读
更多>
课程推荐
更多>