aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/internal/script
diff options
context:
space:
mode:
authorJulien Cretel <jub0bsinthecloud@gmail.com>2025-10-01 20:08:18 +0000
committerGopher Robot <gobot@golang.org>2025-10-13 10:12:48 -0700
commit6bcd97d9f4386528aa85eb3cc27da0ed902de870 (patch)
tree54acec806440b95e7afc493d42b0b095fdaee1a5 /src/cmd/internal/script
parent1cd71689f2ed8f07031a0cc58fc3586ca501839f (diff)
downloadgo-6bcd97d9f4386528aa85eb3cc27da0ed902de870.tar.xz
all: replace calls to errors.As with errors.AsType
This change replaces most occurrences (in code as well as in comments) of errors.As with errors.AsType. It leaves the errors package and vendored code untouched. Change-Id: I3bde73f318a0b408bdb8f5a251494af15a13118a GitHub-Last-Rev: 8aaaa36a5a12d2a6a90c6d51680464e1a3115139 GitHub-Pull-Request: golang/go#75698 Reviewed-on: https://go-review.googlesource.com/c/go/+/708495 Auto-Submit: Michael Pratt <mpratt@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Alan Donovan <adonovan@google.com> Reviewed-by: Michael Pratt <mpratt@google.com>
Diffstat (limited to 'src/cmd/internal/script')
-rw-r--r--src/cmd/internal/script/engine.go8
-rw-r--r--src/cmd/internal/script/scripttest/scripttest.go2
2 files changed, 5 insertions, 5 deletions
diff --git a/src/cmd/internal/script/engine.go b/src/cmd/internal/script/engine.go
index eb9344f6e2..4607868379 100644
--- a/src/cmd/internal/script/engine.go
+++ b/src/cmd/internal/script/engine.go
@@ -185,7 +185,7 @@ func (e *Engine) Execute(s *State, file string, script *bufio.Reader, log io.Wri
var lineno int
lineErr := func(err error) error {
- if errors.As(err, new(*CommandError)) {
+ if _, ok := errors.AsType[*CommandError](err); ok {
return err
}
return fmt.Errorf("%s:%d: %w", file, lineno, err)
@@ -283,7 +283,7 @@ func (e *Engine) Execute(s *State, file string, script *bufio.Reader, log io.Wri
// Run the command.
err = e.runCommand(s, cmd, impl)
if err != nil {
- if stop := (stopError{}); errors.As(err, &stop) {
+ if stop, ok := errors.AsType[stopError](err); ok {
// Since the 'stop' command halts execution of the entire script,
// log its message separately from the section in which it appears.
err = endSection(true)
@@ -607,13 +607,13 @@ func checkStatus(cmd *command, err error) error {
return nil
}
- if s := (stopError{}); errors.As(err, &s) {
+ if _, ok := errors.AsType[stopError](err); ok {
// This error originated in the Stop command.
// Propagate it as-is.
return cmdError(cmd, err)
}
- if w := (waitError{}); errors.As(err, &w) {
+ if _, ok := errors.AsType[waitError](err); ok {
// This error was surfaced from a background process by a call to Wait.
// Add a call frame for Wait itself, but ignore its "want" field.
// (Wait itself cannot fail to wait on commands or else it would leak
diff --git a/src/cmd/internal/script/scripttest/scripttest.go b/src/cmd/internal/script/scripttest/scripttest.go
index bace662a67..349201fd18 100644
--- a/src/cmd/internal/script/scripttest/scripttest.go
+++ b/src/cmd/internal/script/scripttest/scripttest.go
@@ -89,7 +89,7 @@ func Run(t testing.TB, e *script.Engine, s *script.State, filename string, testS
return e.Execute(s, filename, bufio.NewReader(testScript), log)
}()
- if skip := (skipError{}); errors.As(err, &skip) {
+ if skip, ok := errors.AsType[skipError](err); ok {
if skip.msg == "" {
t.Skip("SKIP")
} else {