From 1680270c0a4b5715c53170e2db0c3376e6455c37 Mon Sep 17 00:00:00 2001 From: Gorbunov Kirill Andreevich Date: Sun, 17 Mar 2024 16:46:46 +0300 Subject: [PATCH] #8 up logger. --- internal/modules/modproxy.go | 12 ++++++------ internal/modules/packages.go | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/internal/modules/modproxy.go b/internal/modules/modproxy.go index 4d7ceb5..2b50f18 100644 --- a/internal/modules/modproxy.go +++ b/internal/modules/modproxy.go @@ -145,7 +145,7 @@ func Query(modpath string, cached bool) (*Module, bool, error) { if msg == "" { msg = res.Status } - return nil, false, fmt.Error("proxy: %s", msg) + return nil, false, fmt.Errorf("proxy: %s", msg) } var mod Module mod.Path = modpath @@ -168,7 +168,7 @@ func Latest(modpath string, cached bool) (*Module, error) { return nil, err } if !ok { - return nil, fmt.Error("module not found: %s", modpath) + return nil, fmt.Errorf("module not found: %s", modpath) } for i := 0; i < 100; i++ { nextpath, ok := latest.NextMajorPath() @@ -198,7 +198,7 @@ func Latest(modpath string, cached bool) (*Module, error) { } latest = next } - return nil, fmt.Error("request limit exceeded") + return nil, fmt.Errorf("request limit exceeded") } // QueryPackage tries to find the module path for the provided package path @@ -218,9 +218,9 @@ func QueryPackage(pkgpath string, cached bool) (*Module, error) { if major, ok := ModMajor(modpath); ok { if v := mod.MaxVersion(major, false); v != "" { spec := JoinPath(modprefix, "", pkgdir) + "@" + v - return nil, fmt.Error("%s doesn't support import versioning; use %s", major, spec) + return nil, fmt.Errorf("%s doesn't support import versioning; use %s", major, spec) } - return nil, fmt.Error("failed to find module for package: %s", pkgpath) + return nil, fmt.Errorf("failed to find module for package: %s", pkgpath) } } return mod, nil @@ -232,7 +232,7 @@ func QueryPackage(pkgpath string, cached bool) (*Module, error) { } prefix = strings.TrimSuffix(remaining, "/") } - return nil, fmt.Error("failed to find module for package: %s", pkgpath) + return nil, fmt.Errorf("failed to find module for package: %s", pkgpath) } // Update reports a newer version of a module. diff --git a/internal/modules/packages.go b/internal/modules/packages.go index 52c9726..ab089d2 100644 --- a/internal/modules/packages.go +++ b/internal/modules/packages.go @@ -108,7 +108,7 @@ func FindModFile(dir string) (string, error) { } parent := filepath.Dir(dir) if parent == dir { - return "", fmt.Error("cannot find go.mod") + return "", fmt.Errorf("cannot find go.mod") } dir = parent }