Skip to content

Commit ebf8e26

Browse files
tklausergopherbot
authored andcommitted
cmd/go/internal/modfetch: use errors.ErrUnsupported
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 <[email protected]> Reviewed-by: Cherry Mui <[email protected]> Auto-Submit: Tobias Klauser <[email protected]> Run-TryBot: Bryan Mills <[email protected]> Run-TryBot: Tobias Klauser <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Auto-Submit: Bryan Mills <[email protected]>
1 parent 08c3299 commit ebf8e26

File tree

3 files changed

+5
-18
lines changed

3 files changed

+5
-18
lines changed

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

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -201,19 +201,6 @@ func (noCommitsError) Is(err error) bool {
201201
return err == fs.ErrNotExist
202202
}
203203

204-
// ErrUnsupported indicates that a requested operation cannot be performed,
205-
// because it is unsupported. This error indicates that there is no alternative
206-
// way to perform the operation.
207-
//
208-
// TODO(#41198): Remove this declaration and use errors.ErrUnsupported instead.
209-
var ErrUnsupported = unsupportedOperationError{}
210-
211-
type unsupportedOperationError struct{}
212-
213-
func (unsupportedOperationError) Error() string {
214-
return "unsupported operation"
215-
}
216-
217204
// AllHex reports whether the revision rev is entirely lower-case hexadecimal digits.
218205
func AllHex(rev string) bool {
219206
for i := 0; i < len(rev); i++ {

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ func (r *vcsRepo) loadBranches() {
288288
}
289289

290290
func (r *vcsRepo) CheckReuse(old *Origin, subdir string) error {
291-
return fmt.Errorf("vcs %s: CheckReuse: %w", r.cmd.vcs, ErrUnsupported)
291+
return fmt.Errorf("vcs %s: CheckReuse: %w", r.cmd.vcs, errors.ErrUnsupported)
292292
}
293293

294294
func (r *vcsRepo) Tags(prefix string) (*Tags, error) {
@@ -412,7 +412,7 @@ func (r *vcsRepo) RecentTag(rev, prefix string, allowed func(string) bool) (tag
412412
}
413413
defer unlock()
414414

415-
return "", vcsErrorf("vcs %s: RecentTag: %w", r.cmd.vcs, ErrUnsupported)
415+
return "", vcsErrorf("vcs %s: RecentTag: %w", r.cmd.vcs, errors.ErrUnsupported)
416416
}
417417

418418
func (r *vcsRepo) DescendsFrom(rev, tag string) (bool, error) {
@@ -422,12 +422,12 @@ func (r *vcsRepo) DescendsFrom(rev, tag string) (bool, error) {
422422
}
423423
defer unlock()
424424

425-
return false, vcsErrorf("vcs %s: DescendsFrom: %w", r.cmd.vcs, ErrUnsupported)
425+
return false, vcsErrorf("vcs %s: DescendsFrom: %w", r.cmd.vcs, errors.ErrUnsupported)
426426
}
427427

428428
func (r *vcsRepo) ReadZip(rev, subdir string, maxSize int64) (zip io.ReadCloser, err error) {
429429
if r.cmd.readZip == nil && r.cmd.doReadZip == nil {
430-
return nil, vcsErrorf("vcs %s: ReadZip: %w", r.cmd.vcs, ErrUnsupported)
430+
return nil, vcsErrorf("vcs %s: ReadZip: %w", r.cmd.vcs, errors.ErrUnsupported)
431431
}
432432

433433
unlock, err := r.mu.Lock()

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -608,7 +608,7 @@ func (r *codeRepo) convert(info *codehost.RevInfo, statVers string) (*RevInfo, e
608608
}
609609
if pseudoBase == "" {
610610
tag, err := r.code.RecentTag(info.Name, tagPrefix, tagAllowed)
611-
if err != nil && !errors.Is(err, codehost.ErrUnsupported) {
611+
if err != nil && !errors.Is(err, errors.ErrUnsupported) {
612612
return nil, err
613613
}
614614
if tag != "" {

0 commit comments

Comments
 (0)