Skip to content

Get up and running with Kimi, GLM, MiniMax, DeepSeek, gpt-oss, Qwen, Gemma and other models.

llm,readline: use errors.Is instead of simple == check (#3161)

Blake Mizerany6ce37e4d969b
diff --git a/llm/gguf.go b/llm/gguf.go
index 61c551488..f3b62fe62 100644
--- a/llm/gguf.go
+++ b/llm/gguf.go
@@ -3,6 +3,7 @@ package llm
import (
"bytes"
"encoding/binary"
+ "errors"
"fmt"
"io"
"log/slog"
@@ -540,7 +541,7 @@ func (llm *GGUFModel) Encode(f *os.File) error {
b, err := io.ReadFull(dataFile, data)
remaining -= uint64(b)
- if err == io.EOF || remaining <= 0 {
+ if errors.Is(err, io.EOF) || remaining <= 0 {
finished = true
} else if err != nil {
return err
diff --git a/llm/payload_common.go b/llm/payload_common.go
index 010ba73d9..3c9c98867 100644
--- a/llm/payload_common.go
+++ b/llm/payload_common.go
@@ -113,7 +113,7 @@ func nativeInit() error {
libs, err := extractDynamicLibs(payloadsDir, "llama.cpp/build/*/*/*/lib/*")
if err != nil {
- if err == payloadMissing {
+ if errors.Is(err, payloadMissing) {
slog.Info(fmt.Sprintf("%s", payloadMissing))
return nil
}
diff --git a/readline/history.go b/readline/history.go
index d0138cd91..7b2764394 100644
--- a/readline/history.go
+++ b/readline/history.go
@@ -62,7 +62,7 @@ func (h *History) Init() error {
for {
line, err := r.ReadString('\n')
if err != nil {
- if err == io.EOF {
+ if errors.Is(err, io.EOF) {
break
}
return err