aquarkgn commented on PR #123:
URL: https://github.com/apache/skywalking-go/pull/123#issuecomment-2062950563

   这个问题有可能是因为导入 `_ "github.com/apache/skywalking-go"`  之前进行了日志打印,
   原因可能是skywalking-go-agent命令在执行日志上报时发现skywalking-go包还没有初始化。
   以我自己的为例,我将日志打印放在了初始化中,会立即遇到空指针报错。
   ```
   package tests
   
   import (
        "testing"
   
        "github.com/sirupsen/logrus"
   
        _ "github.com/apache/skywalking-go"
   )
   
   func init() {
        logrus.Infof("before init skywalking")
   }
   
   func TestSkyWalking(t *testing.T) {
        logrus.Infof("test skywalking")
   }
   ```
   当我移除 init 函数时就可以正常运行
   ```
   package tests
   
   import (
        "testing"
   
        "github.com/sirupsen/logrus"
   
        _ "github.com/apache/skywalking-go"
   )
   
   func TestSkyWalking(t *testing.T) {
        logrus.Infof("test skywalking")
   }
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to