From 3f69c32a555411c80c02d87bd0b7e3751963ea46 Mon Sep 17 00:00:00 2001 From: ZauberNerd Date: Fri, 4 Mar 2022 21:14:06 +0000 Subject: [PATCH] src/os: export correct values for os.DevNull for each OS This commit introduces `os.DevNull` exports for all supported OS targets. --- src/os/file_anyos.go | 2 -- src/os/file_other.go | 2 ++ src/os/file_unix.go | 5 +++++ src/os/file_windows.go | 2 ++ 4 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/os/file_anyos.go b/src/os/file_anyos.go index 04ee6301..225b72f5 100644 --- a/src/os/file_anyos.go +++ b/src/os/file_anyos.go @@ -26,8 +26,6 @@ var ( Stderr = NewFile(uintptr(syscall.Stderr), "/dev/stderr") ) -const DevNull = "/dev/null" - // isOS indicates whether we're running on a real operating system with // filesystem support. const isOS = true diff --git a/src/os/file_other.go b/src/os/file_other.go index a96c0540..9206d343 100644 --- a/src/os/file_other.go +++ b/src/os/file_other.go @@ -15,6 +15,8 @@ var ( Stderr = NewFile(2, "/dev/stderr") ) +const DevNull = "/dev/null" + // isOS indicates whether we're running on a real operating system with // filesystem support. const isOS = false diff --git a/src/os/file_unix.go b/src/os/file_unix.go index cc257d7e..a76f5ff1 100644 --- a/src/os/file_unix.go +++ b/src/os/file_unix.go @@ -1,6 +1,9 @@ //go:build darwin || (linux && !baremetal) // +build darwin linux,!baremetal +// target wasi sets GOOS=linux and thus the +linux build tag, +// even though it doesn't show up in "tinygo info target -wasi" + // Portions copyright 2009 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. @@ -12,6 +15,8 @@ import ( "syscall" ) +const DevNull = "/dev/null" + type syscallFd = int // fixLongPath is a noop on non-Windows platforms. diff --git a/src/os/file_windows.go b/src/os/file_windows.go index 694b1394..a26cfd2a 100644 --- a/src/os/file_windows.go +++ b/src/os/file_windows.go @@ -13,6 +13,8 @@ import ( "unicode/utf16" ) +const DevNull = "NUL" + type syscallFd = syscall.Handle // Symlink is a stub, it is not implemented.