From 64da46c703bbfeb097c79177219115a0115b8000 Mon Sep 17 00:00:00 2001 From: "kiloconnect[bot]" <240665456+kiloconnect[bot]@users.noreply.github.com> Date: Sat, 14 Feb 2026 01:24:38 +0000 Subject: [PATCH] refactor: migrate to Gin server & remove deprecated ioutil calls - Replace ioutil.ReadAll with io.ReadAll in llm/anthropic.go, llm/gemini.go, llm/openai.go - Replace ioutil.WriteFile with os.WriteFile in llm/commom.go - Replace ioutil.ReadFile with os.ReadFile in llm/commom.go - Remove io/ioutil imports from all affected files - Server already uses Gin framework (no migration needed) --- llm/anthropic.go | 4 ++-- llm/commom.go | 5 ++--- llm/gemini.go | 4 ++-- llm/openai.go | 4 ++-- 4 files changed, 8 insertions(+), 9 deletions(-) diff --git a/llm/anthropic.go b/llm/anthropic.go index 568b075..a3ab799 100644 --- a/llm/anthropic.go +++ b/llm/anthropic.go @@ -4,7 +4,7 @@ import ( "bytes" "encoding/json" "fmt" - "io/ioutil" + "io" "net/http" "time" ) @@ -179,7 +179,7 @@ func (c *AnthropicClient) Generate( defer resp.Body.Close() if resp.StatusCode >= 400 { - b, _ := ioutil.ReadAll(resp.Body) + b, _ := io.ReadAll(resp.Body) return nil, fmt.Errorf("Anthropic Error %d: %s", resp.StatusCode, string(b)) } diff --git a/llm/commom.go b/llm/commom.go index b50c64a..8026a8f 100644 --- a/llm/commom.go +++ b/llm/commom.go @@ -3,7 +3,6 @@ package llm import ( "encoding/json" "fmt" - "io/ioutil" "math/rand" "os" "path/filepath" @@ -270,11 +269,11 @@ func (h *MessageHistory) SaveToFile(filename string) error { if err := os.MkdirAll(dir, 0755); err != nil { return err } - return ioutil.WriteFile(filename, data, 0644) + return os.WriteFile(filename, data, 0644) } func (h *MessageHistory) LoadFromFile(filename string) error { - data, err := ioutil.ReadFile(filename) + data, err := os.ReadFile(filename) if err != nil { return err } diff --git a/llm/gemini.go b/llm/gemini.go index 86fba24..ef66529 100644 --- a/llm/gemini.go +++ b/llm/gemini.go @@ -4,7 +4,7 @@ import ( "bytes" "encoding/json" "fmt" - "io/ioutil" + "io" "net/http" "time" ) @@ -152,7 +152,7 @@ func (c *GeminiClient) Generate( defer resp.Body.Close() if resp.StatusCode >= 400 { - b, _ := ioutil.ReadAll(resp.Body) + b, _ := io.ReadAll(resp.Body) return nil, fmt.Errorf("Gemini Error %d: %s", resp.StatusCode, string(b)) } diff --git a/llm/openai.go b/llm/openai.go index f113a16..17b1771 100644 --- a/llm/openai.go +++ b/llm/openai.go @@ -4,7 +4,7 @@ import ( "bytes" "encoding/json" "fmt" - "io/ioutil" + "io" "log" "net/http" "time" @@ -240,7 +240,7 @@ func (c *OpenAIClient) Generate( defer resp.Body.Close() if resp.StatusCode >= 400 { - body, _ := ioutil.ReadAll(resp.Body) + body, _ := io.ReadAll(resp.Body) return nil, fmt.Errorf("OpenAI API error: %d - %s", resp.StatusCode, string(body)) }