github.com/twelsh-aw/go/src@v0.0.0-20230516233729-a56fe86a7c81/runtime/os_js.go (about) 1 // Copyright 2018 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 //go:build js && wasm 6 7 package runtime 8 9 import ( 10 "unsafe" 11 ) 12 13 func exit(code int32) 14 15 func write1(fd uintptr, p unsafe.Pointer, n int32) int32 { 16 if fd > 2 { 17 throw("runtime.write to fd > 2 is unsupported") 18 } 19 wasmWrite(fd, p, n) 20 return n 21 } 22 23 //go:wasmimport gojs runtime.wasmWrite 24 //go:noescape 25 func wasmWrite(fd uintptr, p unsafe.Pointer, n int32) 26 27 func usleep(usec uint32) { 28 // TODO(neelance): implement usleep 29 } 30 31 //go:wasmimport gojs runtime.getRandomData 32 //go:noescape 33 func getRandomData(r []byte) 34 35 func goenvs() { 36 goenvs_unix() 37 }