♻️ Refactor Go to err != nil, err == nil (#12385)

This commit is contained in:
Oleksandr Redko 2024-09-04 04:40:50 +03:00 committed by GitHub
parent 473a159ef2
commit b100721fee
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
147 changed files with 1661 additions and 1659 deletions

View file

@ -50,7 +50,7 @@ func ChatGPT(msg string, contextMsgs []string, c *openai.Client, model string, m
ctx, cancel := context.WithTimeout(context.Background(), time.Duration(timeout)*time.Second)
defer cancel()
resp, err := c.CreateChatCompletion(ctx, req)
if nil != err {
if err != nil {
PushErrMsg("Requesting failed, please check kernel log for more details", 3000)
logging.LogErrorf("create chat completion failed: %s", err)
stop = true
@ -86,7 +86,7 @@ func NewOpenAIClient(apiKey, apiProxy, apiBaseURL, apiUserAgent, apiVersion, api
transport := &http.Transport{}
if "" != apiProxy {
proxyUrl, err := url.Parse(apiProxy)
if nil != err {
if err != nil {
logging.LogErrorf("OpenAI API proxy failed: %v", err)
} else {
transport.Proxy = http.ProxyURL(proxyUrl)