Skip to content

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

chore: use errors.New to replace fmt.Errorf will much better (#3789)

Cheng62be2050dd83
diff --git a/api/types.go b/api/types.go
index 2e762b39b..7fe2b4e4e 100644
--- a/api/types.go
+++ b/api/types.go
@@ -2,6 +2,7 @@ package api
import (
"encoding/json"
+ "errors"
"fmt"
"math"
"os"
@@ -307,7 +308,7 @@ func (m *Metrics) Summary() {
}
}
-var ErrInvalidOpts = fmt.Errorf("invalid options")
+var ErrInvalidOpts = errors.New("invalid options")
func (opts *Options) FromMap(m map[string]interface{}) error {
valueOpts := reflect.ValueOf(opts).Elem() // names of the fields in the options struct
diff --git a/llm/payload.go b/llm/payload.go
index 8a1343577..46713c435 100644
--- a/llm/payload.go
+++ b/llm/payload.go
@@ -17,7 +17,7 @@ import (
"github.com/ollama/ollama/gpu"
)
-var errPayloadMissing = fmt.Errorf("expected payloads not included in this build of ollama")
+var errPayloadMissing = errors.New("expected payloads not included in this build of ollama")
func Init() error {
payloadsDir, err := gpu.PayloadsDir()
diff --git a/server/images.go b/server/images.go
index 74fa1a5ee..dd44a0f4d 100644
--- a/server/images.go
+++ b/server/images.go
@@ -1137,7 +1137,7 @@ func GetSHA256Digest(r io.Reader) (string, int64) {
return fmt.Sprintf("sha256:%x", h.Sum(nil)), n
}
-var errUnauthorized = fmt.Errorf("unauthorized")
+var errUnauthorized = errors.New("unauthorized")
func makeRequestWithRetry(ctx context.Context, method string, requestURL *url.URL, headers http.Header, body io.ReadSeeker, regOpts *registryOptions) (*http.Response, error) {
for i := 0; i < 2; i++ {
@@ -1255,7 +1255,7 @@ func parseRegistryChallenge(authStr string) registryChallenge {
}
}
-var errDigestMismatch = fmt.Errorf("digest mismatch, file must be downloaded again")
+var errDigestMismatch = errors.New("digest mismatch, file must be downloaded again")
func verifyBlob(digest string) error {
fp, err := GetBlobsPath(digest)