]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go/internal/modfetch: use errors.ErrUnsupported
authorTobias Klauser <tklauser@distanz.ch>
Tue, 14 Mar 2023 07:51:02 +0000 (08:51 +0100)
committerGopher Robot <gobot@golang.org>
Tue, 14 Mar 2023 21:49:36 +0000 (21:49 +0000)
CL 473935 added errors.ErrUnsupported, let's use it.

Updates #41198

Change-Id: If6534d19cb31ca979ff00d529bd6bdfc964a616d
Reviewed-on: https://go-review.googlesource.com/c/go/+/476135
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Bryan Mills <bcmills@google.com>

src/cmd/go/internal/modfetch/codehost/codehost.go
src/cmd/go/internal/modfetch/codehost/vcs.go
src/cmd/go/internal/modfetch/coderepo.go

index 855b6946ca4e42f7985541b71a9e2ab5de445e45..3a6e55e9a36f60136a5d31b74d7dad455be5bdc4 100644 (file)
@@ -201,19 +201,6 @@ func (noCommitsError) Is(err error) bool {
        return err == fs.ErrNotExist
 }
 
-// ErrUnsupported indicates that a requested operation cannot be performed,
-// because it is unsupported. This error indicates that there is no alternative
-// way to perform the operation.
-//
-// TODO(#41198): Remove this declaration and use errors.ErrUnsupported instead.
-var ErrUnsupported = unsupportedOperationError{}
-
-type unsupportedOperationError struct{}
-
-func (unsupportedOperationError) Error() string {
-       return "unsupported operation"
-}
-
 // AllHex reports whether the revision rev is entirely lower-case hexadecimal digits.
 func AllHex(rev string) bool {
        for i := 0; i < len(rev); i++ {
index 9628a8c7af38bf0a941fa1ec48d6dfac6fd7f014..afca04e96a08bb6b04065d80dced10f92f9275ed 100644 (file)
@@ -288,7 +288,7 @@ func (r *vcsRepo) loadBranches() {
 }
 
 func (r *vcsRepo) CheckReuse(old *Origin, subdir string) error {
-       return fmt.Errorf("vcs %s: CheckReuse: %w", r.cmd.vcs, ErrUnsupported)
+       return fmt.Errorf("vcs %s: CheckReuse: %w", r.cmd.vcs, errors.ErrUnsupported)
 }
 
 func (r *vcsRepo) Tags(prefix string) (*Tags, error) {
@@ -412,7 +412,7 @@ func (r *vcsRepo) RecentTag(rev, prefix string, allowed func(string) bool) (tag
        }
        defer unlock()
 
-       return "", vcsErrorf("vcs %s: RecentTag: %w", r.cmd.vcs, ErrUnsupported)
+       return "", vcsErrorf("vcs %s: RecentTag: %w", r.cmd.vcs, errors.ErrUnsupported)
 }
 
 func (r *vcsRepo) DescendsFrom(rev, tag string) (bool, error) {
@@ -422,12 +422,12 @@ func (r *vcsRepo) DescendsFrom(rev, tag string) (bool, error) {
        }
        defer unlock()
 
-       return false, vcsErrorf("vcs %s: DescendsFrom: %w", r.cmd.vcs, ErrUnsupported)
+       return false, vcsErrorf("vcs %s: DescendsFrom: %w", r.cmd.vcs, errors.ErrUnsupported)
 }
 
 func (r *vcsRepo) ReadZip(rev, subdir string, maxSize int64) (zip io.ReadCloser, err error) {
        if r.cmd.readZip == nil && r.cmd.doReadZip == nil {
-               return nil, vcsErrorf("vcs %s: ReadZip: %w", r.cmd.vcs, ErrUnsupported)
+               return nil, vcsErrorf("vcs %s: ReadZip: %w", r.cmd.vcs, errors.ErrUnsupported)
        }
 
        unlock, err := r.mu.Lock()
index 04164ff9a1c52f4c6a83465e2cc915fbbc5d1de2..047bd71a6223f6b9cd7158620437dfdc8d91ae6b 100644 (file)
@@ -608,7 +608,7 @@ func (r *codeRepo) convert(info *codehost.RevInfo, statVers string) (*RevInfo, e
        }
        if pseudoBase == "" {
                tag, err := r.code.RecentTag(info.Name, tagPrefix, tagAllowed)
-               if err != nil && !errors.Is(err, codehost.ErrUnsupported) {
+               if err != nil && !errors.Is(err, errors.ErrUnsupported) {
                        return nil, err
                }
                if tag != "" {