diff options
author | Damian Gryski <[email protected]> | 2022-08-05 13:18:48 -0700 |
---|---|---|
committer | Ron Evans <[email protected]> | 2022-08-07 10:32:23 +0200 |
commit | a2704f1435c8c26e072f036c32820571498b9052 (patch) | |
tree | d55091269813504dbf74d6ed97266b522a18d291 /builder | |
parent | edbbca5614fc5694d0c631cbcea73c7e2e90b336 (diff) | |
download | tinygo-a2704f1435c8c26e072f036c32820571498b9052.tar.gz tinygo-a2704f1435c8c26e072f036c32820571498b9052.zip |
all: move from os.IsFoo to errors.Is(err, ErrFoo)
Diffstat (limited to 'builder')
-rw-r--r-- | builder/build.go | 3 | ||||
-rw-r--r-- | builder/cc.go | 5 | ||||
-rw-r--r-- | builder/env.go | 6 | ||||
-rw-r--r-- | builder/library.go | 6 |
4 files changed, 13 insertions, 7 deletions
diff --git a/builder/build.go b/builder/build.go index d5d7a242c..c6d0ff267 100644 --- a/builder/build.go +++ b/builder/build.go @@ -14,6 +14,7 @@ import ( "fmt" "go/types" "hash/crc32" + "io/fs" "math/bits" "os" "os/exec" @@ -147,7 +148,7 @@ func Build(pkgName, outpath string, config *compileopts.Config, action func(Buil libcDependencies = append(libcDependencies, libcJob) case "wasi-libc": path := filepath.Join(root, "lib/wasi-libc/sysroot/lib/wasm32-wasi/libc.a") - if _, err := os.Stat(path); os.IsNotExist(err) { + if _, err := os.Stat(path); errors.Is(err, fs.ErrNotExist) { return errors.New("could not find wasi-libc, perhaps you need to run `make wasi-libc`?") } libcDependencies = append(libcDependencies, dummyCompileJob(path)) diff --git a/builder/cc.go b/builder/cc.go index 7d7c10ad8..080ef2bff 100644 --- a/builder/cc.go +++ b/builder/cc.go @@ -10,6 +10,7 @@ import ( "errors" "fmt" "io" + "io/fs" "os" "path/filepath" "sort" @@ -107,11 +108,11 @@ func compileAndCacheCFile(abspath, tmpdir string, cflags []string, thinlto bool, if err == nil { if _, err := os.Stat(outpath); err == nil { return outpath, nil - } else if !os.IsNotExist(err) { + } else if !errors.Is(err, fs.ErrNotExist) { return "", err } } - } else if !os.IsNotExist(err) { + } else if !errors.Is(err, fs.ErrNotExist) { // expected either nil or IsNotExist return "", err } diff --git a/builder/env.go b/builder/env.go index b28173c44..d60861317 100644 --- a/builder/env.go +++ b/builder/env.go @@ -1,6 +1,8 @@ package builder import ( + "errors" + "io/fs" "io/ioutil" "os" "os/exec" @@ -17,13 +19,13 @@ import ( func getClangHeaderPath(TINYGOROOT string) string { // Check whether we're running from the source directory. path := filepath.Join(TINYGOROOT, "llvm-project", "clang", "lib", "Headers") - if _, err := os.Stat(path); !os.IsNotExist(err) { + if _, err := os.Stat(path); !errors.Is(err, fs.ErrNotExist) { return path } // Check whether we're running from the installation directory. path = filepath.Join(TINYGOROOT, "lib", "clang", "include") - if _, err := os.Stat(path); !os.IsNotExist(err) { + if _, err := os.Stat(path); !errors.Is(err, fs.ErrNotExist) { return path } diff --git a/builder/library.go b/builder/library.go index d514568a0..0de718082 100644 --- a/builder/library.go +++ b/builder/library.go @@ -1,6 +1,8 @@ package builder import ( + "errors" + "io/fs" "os" "path/filepath" "runtime" @@ -109,10 +111,10 @@ func (l *Library) load(config *compileopts.Config, tmpdir string) (job *compileJ err = os.Rename(temporaryHeaderPath, headerPath) if err != nil { switch { - case os.IsExist(err): + case errors.Is(err, fs.ErrExist): // Another invocation of TinyGo also seems to have already created the headers. - case runtime.GOOS == "windows" && os.IsPermission(err): + case runtime.GOOS == "windows" && errors.Is(err, fs.ErrPermission): // On Windows, a rename with a destination directory that already // exists does not result in an IsExist error, but rather in an // access denied error. To be sure, check for this case by checking |