wxspider
wxspider copied to clipboard
invalid memory address or nil pointer dereference
你好,经过我多次测试,均会出现这个问题,请帮忙修正一下,谢谢。
resp, err := client.PostForm(cf.PostConfig.ServeURL, data)
// resp, err := http.NewRequest("POST", cf.PostConfig.ServeURL, strings.NewReader(data.Encode()))
//测试打印日志
if resp ==nil {
log.Println("resp==nil")
}
log.Println(cf.PostConfig.ServeURL)
resp.Header.Add("accept", `application/json`)
resp.Header.Add("Authorization", fmt.Sprintf(`Bearer %v`, cf.PostConfig.AuthorizationToken))
输出日志:
resp==nil
http://examples.com/
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xc0000005 code=0x0 addr=0x38 pc=0x8e292e]
goroutine 2426 [running]:
github.com/yizenghui/wxspider.PostArticle(0x15, 0xc0002be120, 0x21, 0xc000600410, 0x6, 0xc000600420, 0xc, 0xc000600430, 0xf, 0xc0003b0090, ...)
E:/go-home/go-repo/src/github.com/yizenghui/wxspider/article.go:208 +0xed5
github.com/yizenghui/wxspider.PublishArticle(0x1, 0x0)
E:/go-home/go-repo/src/github.com/yizenghui/wxspider/article.go:137 +0x186
created by main.postLocationArticle
E:/work-app/wxspider/run/wxspider.go:55 +0x84
貌似是“http://examples.com/” 导致的,请问这个地址的作用,还有应该怎么配置,多谢
@kindcao
配置conf.toml
请把conf.toml放在执行文件wxspider.exe位置
参考 conf.example.toml
This is a TOML document. Boom.
[BaiDuAiConf] api_key = "kGMQC1R***********InjUL" secret_key = "H6Mk*******************0Y7DkH0p"
[PostConfig] serve_url = "http://examples.com/" authorization_token = ""
[WebServe] Port = 3355
serve_url 是数据发布接口
能提供一下微信嘛,加你有偿帮设置一下
@qdstar 微信号 yize1992 请注明来意