runtime

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2024 License: MIT Imports: 8 Imported by: 0

README

runtime

runtime is a Starlark module provides Go and app runtime information.

Functions

uptime()

Returns the uptime of the current process in time.duration.

Examples

basic

Returns the uptime of the current process immediately.

load("runtime", "uptime")
print(uptime())
# Output: 883.583µs
getenv(key, default=None)

Returns the value of the environment variable key as a string if it exists, or default if it doesn't.

Examples

basic

Returns the value of the environment variable PATH if it exists, or None if it doesn't.

load("runtime", "getenv")
print(getenv("PATH"))
# Output: /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
putenv(key, value)

Sets the value of the environment variable named by the key, returning an error if any.

Examples

basic

Sets the environment variable STARLET_TEST to the value 123456.

load("runtime", "putenv")
putenv("STARLET_TEST", 123456)
setenv(key, value)

Sets the value of the environment variable named by the key, returning an error if any. Alias of putenv.

Examples

basic

Sets the environment variable STARLET_TEST to the value ABC.

load("runtime", "setenv")
setenv("STARLET_TEST", "ABC")
unsetenv(key)

Unsets a single environment variable.

Examples

basic

Unsets the environment variable STARLET_TEST.

load("runtime", "unsetenv")
unsetenv("STARLET_TEST")

Documentation

Overview

Package runtime implements the Starlark module for Go and app runtime information.

Index

Constants

View Source
const ModuleName = "runtime"

ModuleName defines the expected name for this Module when used in starlark's load() function, eg: load('base64', 'encode')

Variables

This section is empty.

Functions

func LoadModule

func LoadModule() (md starlark.StringDict, err error)

LoadModule loads the runtime module. It is concurrency-safe and idempotent.

Types

This section is empty.

Jump to

Keyboard shortcuts

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