This order match constants from wasi_snapshot_preview1.ErrnoSuccess for easier maintenance.
var ( // ErrnoAcces Permission denied. ErrnoAcces = &Errno{"EACCES"} // ErrnoAgain Resource unavailable, or operation would block. ErrnoAgain = &Errno{"EAGAIN"} // ErrnoBadf Bad file descriptor. ErrnoBadf = &Errno{"EBADF"} // ErrnoExist File exists. ErrnoExist = &Errno{"EEXIST"} // ErrnoFault Bad address. ErrnoFault = &Errno{"EFAULT"} // ErrnoIntr Interrupted function. ErrnoIntr = &Errno{"EINTR"} // ErrnoInval Invalid argument. ErrnoInval = &Errno{"EINVAL"} // ErrnoIo I/O error. ErrnoIo = &Errno{"EIO"} // ErrnoIsdir Is a directory. ErrnoIsdir = &Errno{"EISDIR"} // ErrnoLoop Too many levels of symbolic links. ErrnoLoop = &Errno{"ELOOP"} // ErrnoNametoolong Filename too long. ErrnoNametoolong = &Errno{"ENAMETOOLONG"} // ErrnoNoent No such file or directory. ErrnoNoent = &Errno{"ENOENT"} // ErrnoNosys function not supported. ErrnoNosys = &Errno{"ENOSYS"} // ErrnoNotdir Not a directory or a symbolic link to a directory. ErrnoNotdir = &Errno{"ENOTDIR"} // ErrnoNotempty Directory not empty. ErrnoNotempty = &Errno{"ENOTEMPTY"} // ErrnoNotsup Not supported, or operation not supported on socket. ErrnoNotsup = &Errno{"ENOTSUP"} // ErrnoPerm Operation not permitted. ErrnoPerm = &Errno{"EPERM"} // ErrnoRofs read-only file system. ErrnoRofs = &Errno{"EROFS"} )
ClearTimeoutEvent implements runtime.clearTimeoutEvent which supports runtime.notetsleepg used by runtime.signal_recv.
See https://github.com/golang/go/blob/go1.20/src/runtime/sys_wasm.s#L129
var ClearTimeoutEvent = goarch.NewFunc(custom.NameRuntimeClearTimeoutEvent, clearTimeoutEvent)
CopyBytesToGo copies a JavaScript managed byte array to linear memory. For example, this is used to read an HTTP response body.
See https://github.com/golang/go/blob/go1.20/src/syscall/js/js.go#L569 and https://github.com/golang/go/blob/go1.20/misc/wasm/wasm_exec.js#L437-L449
var CopyBytesToGo = goos.NewFunc(custom.NameSyscallCopyBytesToGo, copyBytesToGo)
CopyBytesToJS copies linear memory to a JavaScript managed byte array. For example, this is used to read an HTTP request body.
See https://github.com/golang/go/blob/go1.20/src/syscall/js/js.go#L583 and https://github.com/golang/go/blob/go1.20/misc/wasm/wasm_exec.js#L438-L448
var CopyBytesToJS = goos.NewFunc(custom.NameSyscallCopyBytesToJS, copyBytesToJS)
Debug has unknown use, so stubbed.
See https://github.com/golang/go/blob/go1.20/src/cmd/link/internal/wasm/asm.go#L131-L136
var Debug = goarch.StubFunction(custom.NameDebug)
FinalizeRef implements js.finalizeRef, which is used as a runtime.SetFinalizer on the given reference.
See https://github.com/golang/go/blob/go1.20/src/syscall/js/js.go#L61
var FinalizeRef = goos.NewFunc(custom.NameSyscallFinalizeRef, finalizeRef)
GetRandomData implements runtime.getRandomData, which initializes the seed for runtime.fastrand.
See https://github.com/golang/go/blob/go1.20/src/runtime/sys_wasm.s#L133
var GetRandomData = goarch.NewFunc(custom.NameRuntimeGetRandomData, getRandomData)
var NaN = math.NaN()
Nanotime1 implements runtime.nanotime which supports time.Since.
See https://github.com/golang/go/blob/go1.20/src/runtime/sys_wasm.s#L117
var Nanotime1 = goarch.NewFunc(custom.NameRuntimeNanotime1, nanotime1)
ResetMemoryDataView signals wasm.OpcodeMemoryGrow happened, indicating any cached view of memory should be reset.
See https://github.com/golang/go/blob/go1.20/src/runtime/mem_js.go#L82
var ResetMemoryDataView = goarch.NewFunc(custom.NameRuntimeResetMemoryDataView, resetMemoryDataView)
ScheduleTimeoutEvent implements runtime.scheduleTimeoutEvent which supports runtime.notetsleepg used by runtime.signal_recv.
Unlike other most functions prefixed by "runtime.", this both launches a goroutine and invokes code compiled into wasm "resume".
See https://github.com/golang/go/blob/go1.20/src/runtime/sys_wasm.s#L125
var ScheduleTimeoutEvent = goarch.NewFunc(custom.NameRuntimeScheduleTimeoutEvent, scheduleTimeoutEvent)
StringVal implements js.stringVal, which is used to load the string for `js.ValueOf(x)`. For example, this is used when setting HTTP headers.
See https://github.com/golang/go/blob/go1.20/src/syscall/js/js.go#L212 and https://github.com/golang/go/blob/go1.20/misc/wasm/wasm_exec.js#L305-L308
var StringVal = goos.NewFunc(custom.NameSyscallStringVal, stringVal)
ValueCall implements js.valueCall, which is used to call a js.Value function by name, e.g. `document.Call("createElement", "div")`.
See https://github.com/golang/go/blob/go1.20/src/syscall/js/js.go#L394 and https://github.com/golang/go/blob/go1.20/misc/wasm/wasm_exec.js#L343-L358
var ValueCall = goos.NewFunc(custom.NameSyscallValueCall, valueCall)
ValueDelete is stubbed as it isn't used in Go's main source tree.
See https://github.com/golang/go/blob/go1.20/src/syscall/js/js.go#L321
var ValueDelete = goarch.StubFunction(custom.NameSyscallValueDelete)
ValueGet implements js.valueGet, which is used to load a js.Value property by name, e.g. `v.Get("address")`. Notably, this is used by js.handleEvent to get the pending event.
See https://github.com/golang/go/blob/go1.20/src/syscall/js/js.go#L295 and https://github.com/golang/go/blob/go1.20/misc/wasm/wasm_exec.js#L311-L316
var ValueGet = goos.NewFunc(custom.NameSyscallValueGet, valueGet)
ValueIndex implements js.valueIndex, which is used to load a js.Value property by index, e.g. `v.Index(0)`. Notably, this is used by js.handleEvent to read event arguments
See https://github.com/golang/go/blob/go1.20/src/syscall/js/js.go#L334 and https://github.com/golang/go/blob/go1.20/misc/wasm/wasm_exec.js#L331-L334
var ValueIndex = goos.NewFunc(custom.NameSyscallValueIndex, valueIndex)
ValueInstanceOf is stubbed as it isn't used in Go's main source tree.
See https://github.com/golang/go/blob/go1.20/src/syscall/js/js.go#L543
var ValueInstanceOf = goarch.StubFunction(custom.NameSyscallValueInstanceOf)
ValueInvoke is stubbed as it isn't used in Go's main source tree.
See https://github.com/golang/go/blob/go1.20/src/syscall/js/js.go#L413
var ValueInvoke = goarch.StubFunction(custom.NameSyscallValueInvoke)
ValueLength implements js.valueLength, which is used to load the length property of a value, e.g. `array.length`.
See https://github.com/golang/go/blob/go1.20/src/syscall/js/js.go#L372 and https://github.com/golang/go/blob/go1.20/misc/wasm/wasm_exec.js#L395-L398
var ValueLength = goos.NewFunc(custom.NameSyscallValueLength, valueLength)
ValueLoadString implements js.valueLoadString, which is used copy a string value for `o.String()`.
See https://github.com/golang/go/blob/go1.20/src/syscall/js/js.go#L533 and https://github.com/golang/go/blob/go1.20/misc/wasm/wasm_exec.js#L409-L413
var ValueLoadString = goos.NewFunc(custom.NameSyscallValueLoadString, valueLoadString)
ValueNew implements js.valueNew, which is used to call a js.Value, e.g. `array.New(2)`.
See https://github.com/golang/go/blob/go1.20/src/syscall/js/js.go#L432 and https://github.com/golang/go/blob/go1.20/misc/wasm/wasm_exec.js#L378-L392
var ValueNew = goos.NewFunc(custom.NameSyscallValueNew, valueNew)
ValuePrepareString implements js.valuePrepareString, which is used to load the string for `o.String()` (via js.jsString) for string, boolean and number types. Notably, http.Transport uses this in RoundTrip to coerce the URL to a string.
See https://github.com/golang/go/blob/go1.20/src/syscall/js/js.go#L531 and https://github.com/golang/go/blob/go1.20/misc/wasm/wasm_exec.js#L401-L406
var ValuePrepareString = goos.NewFunc(custom.NameSyscallValuePrepareString, valuePrepareString)
ValueSet implements js.valueSet, which is used to store a js.Value property by name, e.g. `v.Set("address", a)`. Notably, this is used by js.handleEvent set the event result.
See https://github.com/golang/go/blob/go1.20/src/syscall/js/js.go#L309 and https://github.com/golang/go/blob/go1.20/misc/wasm/wasm_exec.js#L318-L322
var ValueSet = goos.NewFunc(custom.NameSyscallValueSet, valueSet)
ValueSetIndex is stubbed as it is only used for js.ValueOf when the input is []interface{}, which doesn't appear to occur in Go's source tree.
See https://github.com/golang/go/blob/go1.20/src/syscall/js/js.go#L348
var ValueSetIndex = goarch.StubFunction(custom.NameSyscallValueSetIndex)
Walltime implements runtime.walltime which supports time.Now.
See https://github.com/golang/go/blob/go1.20/src/runtime/sys_wasm.s#L121
var Walltime = goarch.NewFunc(custom.NameRuntimeWalltime, walltime)
WasmExit implements runtime.wasmExit which supports runtime.exit.
See https://github.com/golang/go/blob/go1.20/src/runtime/sys_wasm.go#L24
var WasmExit = goarch.NewFunc(custom.NameRuntimeWasmExit, wasmExit)
WasmWrite implements runtime.wasmWrite which supports runtime.write and runtime.writeErr. This implements `println`.
See https://github.com/golang/go/blob/go1.20/src/runtime/os_js.go#L30
var WasmWrite = goarch.NewFunc(custom.NameRuntimeWasmWrite, wasmWrite)
func GetLastEventArgs(ctx context.Context) []interface{}
GetLastEventArgs implements goos.GetLastEventArgs
func LoadValue(ctx context.Context, ref goos.Ref) interface{}
LoadValue reads up to 8 bytes at the memory offset `addr` to return the value written by storeValue.
See https://github.com/golang/go/blob/go1.20/misc/wasm/wasm_exec.js#L122-L133
func WriteArgsAndEnviron(mod api.Module) (argc, argv uint32, err error)
WriteArgsAndEnviron writes arguments and environment variables to memory, so they can be read by main, Go compiles as the function export "run".
Errno is a (GOARCH=wasm) error, which must match a key in mapJSError.
See https://github.com/golang/go/blob/go1.20/src/syscall/tables_js.go#L371-L494
type Errno struct {
// contains filtered or unexported fields
}
func ToErrno(err error) *Errno
ToErrno maps I/O errors as the message must be the code, ex. "EINVAL", not the message, e.g. "invalid argument".
func (e *Errno) Error() string
Error implements error.
State holds state used by the "go" imports used by gojs. Note: This is module-scoped.
type State struct {
// contains filtered or unexported fields
}
func NewState(config *config.Config) *State
func (s *State) Get(propertyKey string) interface{}
Get implements the same method as documented on goos.GetFunction
StateKey is a context.Context Value key. The value must be a state pointer.
type StateKey struct{}
Name | Synopsis |
---|---|
.. |