stew/* Packages / 14.2

📟 stew/io

The stew/io package provides simple and lightweight methods for interacting with the user and the developer without having to manipulate the JS bridge manually.

Console & Debug

These methods are displayed in the browser's developer console.

Console.Log(...args)

Displays a standard message.

Console.Warn(...args)

Displays a warning message (yellow).

Console.Warning(...args)

Alias for Warn.

Console.Error(...args)

Displays an error message (red).

Browser Dialogs

These methods block execution (synchronous) until user interaction.

Alert(message)

Displays an alert box with an OK button.

Confirm(message) bool

Requests a confirmation (OK/Cancel). Returns true if OK.

Prompt(message) string

Requests text input. Returns the value or an empty string.

Full Example

<goscript client>
    import "stew/io"

    onDelete := func() {
        if Confirm("Are you sure you want to delete?") {
            Console.Log("Action confirmed")
            // Deletion logic...
        } else {
            Console.Warn("Action cancelled")
        }
    }
</goscript>
⚡ Performance: This package is extremely lightweight as it directly uses native functions from the Go Wasm runtime.