Commit ac28ca64 authored by YanzheL's avatar YanzheL Committed by 陈曦
Browse files

fix(lint): satisfy errcheck for strings.Builder.WriteString calls

parent 91a3cae5
...@@ -24,23 +24,23 @@ func deriveOpenAIContentSessionSeed(body []byte) string { ...@@ -24,23 +24,23 @@ func deriveOpenAIContentSessionSeed(body []byte) string {
var b strings.Builder var b strings.Builder
if model := gjson.GetBytes(body, "model").String(); model != "" { if model := gjson.GetBytes(body, "model").String(); model != "" {
b.WriteString("model=") _, _ = b.WriteString("model=")
b.WriteString(model) _, _ = b.WriteString(model)
} }
if tools := gjson.GetBytes(body, "tools"); tools.Exists() && tools.IsArray() && tools.Raw != "[]" { if tools := gjson.GetBytes(body, "tools"); tools.Exists() && tools.IsArray() && tools.Raw != "[]" {
b.WriteString("|tools=") _, _ = b.WriteString("|tools=")
b.WriteString(normalizeCompatSeedJSON(json.RawMessage(tools.Raw))) _, _ = b.WriteString(normalizeCompatSeedJSON(json.RawMessage(tools.Raw)))
} }
if funcs := gjson.GetBytes(body, "functions"); funcs.Exists() && funcs.IsArray() && funcs.Raw != "[]" { if funcs := gjson.GetBytes(body, "functions"); funcs.Exists() && funcs.IsArray() && funcs.Raw != "[]" {
b.WriteString("|functions=") _, _ = b.WriteString("|functions=")
b.WriteString(normalizeCompatSeedJSON(json.RawMessage(funcs.Raw))) _, _ = b.WriteString(normalizeCompatSeedJSON(json.RawMessage(funcs.Raw)))
} }
if instr := gjson.GetBytes(body, "instructions").String(); instr != "" { if instr := gjson.GetBytes(body, "instructions").String(); instr != "" {
b.WriteString("|instructions=") _, _ = b.WriteString("|instructions=")
b.WriteString(instr) _, _ = b.WriteString(instr)
} }
firstUserCaptured := false firstUserCaptured := false
...@@ -51,15 +51,15 @@ func deriveOpenAIContentSessionSeed(body []byte) string { ...@@ -51,15 +51,15 @@ func deriveOpenAIContentSessionSeed(body []byte) string {
role := msg.Get("role").String() role := msg.Get("role").String()
switch role { switch role {
case "system", "developer": case "system", "developer":
b.WriteString("|system=") _, _ = b.WriteString("|system=")
if c := msg.Get("content"); c.Exists() { if c := msg.Get("content"); c.Exists() {
b.WriteString(normalizeCompatSeedJSON(json.RawMessage(c.Raw))) _, _ = b.WriteString(normalizeCompatSeedJSON(json.RawMessage(c.Raw)))
} }
case "user": case "user":
if !firstUserCaptured { if !firstUserCaptured {
b.WriteString("|first_user=") _, _ = b.WriteString("|first_user=")
if c := msg.Get("content"); c.Exists() { if c := msg.Get("content"); c.Exists() {
b.WriteString(normalizeCompatSeedJSON(json.RawMessage(c.Raw))) _, _ = b.WriteString(normalizeCompatSeedJSON(json.RawMessage(c.Raw)))
} }
firstUserCaptured = true firstUserCaptured = true
} }
...@@ -68,30 +68,30 @@ func deriveOpenAIContentSessionSeed(body []byte) string { ...@@ -68,30 +68,30 @@ func deriveOpenAIContentSessionSeed(body []byte) string {
}) })
} else if inp := gjson.GetBytes(body, "input"); inp.Exists() { } else if inp := gjson.GetBytes(body, "input"); inp.Exists() {
if inp.Type == gjson.String { if inp.Type == gjson.String {
b.WriteString("|input=") _, _ = b.WriteString("|input=")
b.WriteString(inp.String()) _, _ = b.WriteString(inp.String())
} else if inp.IsArray() { } else if inp.IsArray() {
inp.ForEach(func(_, item gjson.Result) bool { inp.ForEach(func(_, item gjson.Result) bool {
role := item.Get("role").String() role := item.Get("role").String()
switch role { switch role {
case "system", "developer": case "system", "developer":
b.WriteString("|system=") _, _ = b.WriteString("|system=")
if c := item.Get("content"); c.Exists() { if c := item.Get("content"); c.Exists() {
b.WriteString(normalizeCompatSeedJSON(json.RawMessage(c.Raw))) _, _ = b.WriteString(normalizeCompatSeedJSON(json.RawMessage(c.Raw)))
} }
case "user": case "user":
if !firstUserCaptured { if !firstUserCaptured {
b.WriteString("|first_user=") _, _ = b.WriteString("|first_user=")
if c := item.Get("content"); c.Exists() { if c := item.Get("content"); c.Exists() {
b.WriteString(normalizeCompatSeedJSON(json.RawMessage(c.Raw))) _, _ = b.WriteString(normalizeCompatSeedJSON(json.RawMessage(c.Raw)))
} }
firstUserCaptured = true firstUserCaptured = true
} }
} }
if !firstUserCaptured && item.Get("type").String() == "input_text" { if !firstUserCaptured && item.Get("type").String() == "input_text" {
b.WriteString("|first_user=") _, _ = b.WriteString("|first_user=")
if text := item.Get("text").String(); text != "" { if text := item.Get("text").String(); text != "" {
b.WriteString(text) _, _ = b.WriteString(text)
} }
firstUserCaptured = true firstUserCaptured = true
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment