Unverified Commit 6ce37e4d authored by Blake Mizerany's avatar Blake Mizerany Committed by GitHub
Browse files

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



This fixes some brittle, simple equality checks to use errors.Is. Since
go1.13, errors.Is is the idiomatic way to check for errors.
Co-authored-by: default avatarJeffrey Morgan <jmorganca@gmail.com>
parent 703684a8
......@@ -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
......
......@@ -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
}
......
......@@ -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
......
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