github.com/evanw/esbuild@v0.21.4/internal/fs/iswin_wasm.go (about)

     1  //go:build js && wasm
     2  // +build js,wasm
     3  
     4  package fs
     5  
     6  import (
     7  	"os"
     8  )
     9  
    10  var checkedIfWindows bool
    11  var cachedIfWindows bool
    12  
    13  func CheckIfWindows() bool {
    14  	if !checkedIfWindows {
    15  		checkedIfWindows = true
    16  
    17  		// Hack: Assume that we're on Windows if we're running WebAssembly and
    18  		// the "C:\\" directory exists. This is a workaround for a bug in Go's
    19  		// WebAssembly support: https://github.com/golang/go/issues/43768.
    20  		_, err := os.Stat("C:\\")
    21  		cachedIfWindows = err == nil
    22  	}
    23  
    24  	return cachedIfWindows
    25  }