wasmexec

package module
v1.0.22 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 8, 2024 License: BSD-3-Clause Imports: 9 Imported by: 5

README

wasmexec

For applications that need to provide the correct wasm_exec.js based on a go runtime version.

Rationale

The $GOROOT/misc/wasm/wasm_exec.js file is included in the go installation, but is only accessible from the filesystem.

This module provides a means to source the correct wasm_exec.js content programmatically.

The golang source repository is scanned nightly and the current tags in the repository are mapped to the correct content at misc/wasm/wasm_exec.js.

Example


http.HandleFunc("/wasm_exec.js", func (writer http.ResponseWriter, request *http.Request) {
    content, err := wasmexec.Current()
    if err != nil {
        writer.WriteHeader(http.StatusInternalServerError)
        return
    }
    writer.Header().Set("Content-Type", "application/javascript")
    _, _ = writer.Write(content)
})

Go Report Card

created by tigwen

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Current

func Current() (content []byte, err error)

func TagToSha added in v1.0.0

func TagToSha(tag string) string

func Version

func Version(version string) (contents []byte, err error)

func WriteLauncher added in v1.0.10

func WriteLauncher(writer http.ResponseWriter)

WriteLauncher writes Current wasm js and minimal WebAssembly instantiation code.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL