We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
type Cwiki interface { GetPdfByPageId(pageId string) (pdf []byte, err error) }
type cwikiClient struct { client *resty.Client }
func NewCwikiClient() Cwiki { client := resty.New() client.SetTimeout(15 * time.Second) client.SetRetryCount(0) client.SetRetryWaitTime(0 * time.Second) client.SetLogger(nil) client.SetJSONMarshaler(sonic.Marshal) client.SetJSONUnmarshaler(sonic.Unmarshal) client.SetHeaders(map[string]string{ "Content-Type": "application/json", "Authorization": conf.Conf.Cwiki.Token, }) client.SetBaseURL(conf.Conf.Cwiki.Base_url) client.SetTransport(&http.Transport{ MaxIdleConns: 100, MaxIdleConnsPerHost: 100, IdleConnTimeout: 180 * time.Second, }) client.SetRetryResetReaders(true)
return &cwikiClient{client: client}
}
func (c *cwikiClient) GetPdfByPageId(pageId string) (pdf []byte, err error) {
formData := url.Values{} formData.Set("pageId", pageId) queryString := formData.Encode() fullURL := fmt.Sprintf("%s?%s", conf.Conf.wiki.GetPdf, queryString) respData, err := c.client.SetBaseURL(conf.Conf.Cwiki.Base_url).R().Get(fullURL) if err != nil { return nil, err } if respData.StatusCode() == 500 { return nil, ErrPdfDownloadFailed } if respData.StatusCode() != 200 { return nil, HTTPStatusError } body := respData.Body() return body, nil
panic: runtime error: invalid memory address or nil pointer dereference [recovered] panic: runtime error: invalid memory address or nil pointer dereference [signal 0xc0000005 code=0x0 addr=0x28 pc=0x7ff7e8c933f8]
goroutine 367 [running]: github.com/go-resty/resty/v2.(*Request).Execute.func1() D:/GolandProjects/ai-cwiki/vendor/github.com/go-resty/resty/v2/request.go:1007 +0x15a panic({0x7ff7e927b9a0?, 0x7ff7e914dcd0?}) D:/Go/src/runtime/panic.go:914 +0x21f github.com/go-resty/resty/v2.(*Request).Execute.func2() D:/GolandProjects/ai-cwiki/vendor/github.com/go-resty/resty/v2/request.go:1045 +0x178 github.com/go-resty/resty/v2.Backoff(0xc001325728, {0xc0013256f8, 0x6, 0x0?}) D:/GolandProjects/ai-cwiki/vendor/github.com/go-resty/resty/v2/retry.go:115 +0x16c github.com/go-resty/resty/v2.(*Request).Execute(0xc0003561e0, {0x7ff7e93972df?, 0xc0013257f8?}, {0xc0018e8d40, 0x36}) D:/GolandProjects/ai-cwiki/vendor/github.com/go-resty/resty/v2/request.go:1037 +0x5f1 github.com/go-resty/resty/v2.(*Request).Get(...) D:/GolandProjects/ai-cwiki/vendor/github.com/go-resty/resty/v2/request.go:947 ai-cwiki/repositorys/remoteApi.(*cwikiClient).GetPdfByPageId(0xc0007180b8, {0xc00142c5bb, 0x8}) D:/GolandProjects/ai-cwiki/repositorys/remoteApi/cwikiApi.go:425 +0x4c7 ai-cwiki/async.(*asyncTaskImpl).UploadTask(0xc0000aeaa0, {0x7ff7e93c661e, 0x1}) D:/GolandProjects/ai-cwiki/async/UploadTask.go:78 +0x5eb ai-cwiki/async.InitAsyncTask.func6({0x7ff7e93c661e, 0x1}) D:/GolandProjects/ai-cwiki/async/initAsyncTask.go:137 +0x39 created by ai-cwiki/async.InitAsyncTask in goroutine 1 D:/GolandProjects/ai-cwiki/async/initAsyncTask.go:128 +0x3b2
The text was updated successfully, but these errors were encountered:
Maybe you should modify *resty.Client like this @KurotsuchiMayuri
func NewCwikiClient() Cwiki { client := resty.New(). SetTimeout(15 * time.Second). SetRetryCount(0). SetRetryWaitTime(0 * time.Second). SetLogger(nil). SetJSONMarshaler(sonic.Marshal). SetJSONUnmarshaler(sonic.Unmarshal). SetHeaders(map[string]string{ "Content-Type": "application/json", "Authorization": conf.Conf.Cwiki.Token, }). SetBaseURL(conf.Conf.Cwiki.Base_url). SetTransport(&http.Transport{ MaxIdleConns: 100, MaxIdleConnsPerHost: 100, IdleConnTimeout: 180 * time.Second, }). SetRetryResetReaders(true) return &cwikiClient{client: client} }
Sorry, something went wrong.
No branches or pull requests
type Cwiki interface {
GetPdfByPageId(pageId string) (pdf []byte, err error)
}
type cwikiClient struct {
client *resty.Client
}
func NewCwikiClient() Cwiki {
client := resty.New()
client.SetTimeout(15 * time.Second)
client.SetRetryCount(0)
client.SetRetryWaitTime(0 * time.Second)
client.SetLogger(nil)
client.SetJSONMarshaler(sonic.Marshal)
client.SetJSONUnmarshaler(sonic.Unmarshal)
client.SetHeaders(map[string]string{
"Content-Type": "application/json",
"Authorization": conf.Conf.Cwiki.Token,
})
client.SetBaseURL(conf.Conf.Cwiki.Base_url)
client.SetTransport(&http.Transport{
MaxIdleConns: 100,
MaxIdleConnsPerHost: 100,
IdleConnTimeout: 180 * time.Second,
})
client.SetRetryResetReaders(true)
}
func (c *cwikiClient) GetPdfByPageId(pageId string) (pdf []byte, err error) {
}
type Cwiki interface {
GetPdfByPageId(pageId string) (pdf []byte, err error)
}
type cwikiClient struct {
client *resty.Client
}
func NewCwikiClient() Cwiki {
client := resty.New()
client.SetTimeout(15 * time.Second)
client.SetRetryCount(0)
client.SetRetryWaitTime(0 * time.Second)
client.SetLogger(nil)
client.SetJSONMarshaler(sonic.Marshal)
client.SetJSONUnmarshaler(sonic.Unmarshal)
client.SetHeaders(map[string]string{
"Content-Type": "application/json",
"Authorization": conf.Conf.Cwiki.Token,
})
client.SetBaseURL(conf.Conf.Cwiki.Base_url)
client.SetTransport(&http.Transport{
MaxIdleConns: 100,
MaxIdleConnsPerHost: 100,
IdleConnTimeout: 180 * time.Second,
})
client.SetRetryResetReaders(true)
}
panic: runtime error: invalid memory address or nil pointer dereference [recovered]
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xc0000005 code=0x0 addr=0x28 pc=0x7ff7e8c933f8]
goroutine 367 [running]:
github.com/go-resty/resty/v2.(*Request).Execute.func1()
D:/GolandProjects/ai-cwiki/vendor/github.com/go-resty/resty/v2/request.go:1007 +0x15a
panic({0x7ff7e927b9a0?, 0x7ff7e914dcd0?})
D:/Go/src/runtime/panic.go:914 +0x21f
github.com/go-resty/resty/v2.(*Request).Execute.func2()
D:/GolandProjects/ai-cwiki/vendor/github.com/go-resty/resty/v2/request.go:1045 +0x178
github.com/go-resty/resty/v2.Backoff(0xc001325728, {0xc0013256f8, 0x6, 0x0?})
D:/GolandProjects/ai-cwiki/vendor/github.com/go-resty/resty/v2/retry.go:115 +0x16c
github.com/go-resty/resty/v2.(*Request).Execute(0xc0003561e0, {0x7ff7e93972df?, 0xc0013257f8?}, {0xc0018e8d40, 0x36})
D:/GolandProjects/ai-cwiki/vendor/github.com/go-resty/resty/v2/request.go:1037 +0x5f1
github.com/go-resty/resty/v2.(*Request).Get(...)
D:/GolandProjects/ai-cwiki/vendor/github.com/go-resty/resty/v2/request.go:947
ai-cwiki/repositorys/remoteApi.(*cwikiClient).GetPdfByPageId(0xc0007180b8, {0xc00142c5bb, 0x8})
D:/GolandProjects/ai-cwiki/repositorys/remoteApi/cwikiApi.go:425 +0x4c7
ai-cwiki/async.(*asyncTaskImpl).UploadTask(0xc0000aeaa0, {0x7ff7e93c661e, 0x1})
D:/GolandProjects/ai-cwiki/async/UploadTask.go:78 +0x5eb
ai-cwiki/async.InitAsyncTask.func6({0x7ff7e93c661e, 0x1})
D:/GolandProjects/ai-cwiki/async/initAsyncTask.go:137 +0x39
created by ai-cwiki/async.InitAsyncTask in goroutine 1
D:/GolandProjects/ai-cwiki/async/initAsyncTask.go:128 +0x3b2
The text was updated successfully, but these errors were encountered: