Standard library
OS
Process id, working directory, hostname, and platform.
Introduction
Process id, working directory, hostname, and platform. Import std/os to bind the module as os. Call free functions as os.name(...). Struct methods use a receiver value.
/ std/os
This page is the package reference for std/os. Private helpers used only by co-located tests are not listed.
Functions
Free functions on os. Each function has a short description, an example, then parameters and return shape.
pid
Returns the current process id. Call form: os.pid().
/ std/os
$ id = os.pid()
Parameters: No parameters. Returns: Integer process id.
cwd
Returns the current working directory. Call form: os.cwd().
/ std/os
$ dir = os.cwd()
Parameters: No parameters. Returns: Working directory path string.
chdir
Changes the process working directory. Call form: os.chdir(path).
/ std/os
os.chdir(p'/tmp')
Parameters: path: directory path as string or locator. Returns: None.
hostname
Returns the host name of the machine. Call form: os.hostname().
/ std/os
$ h = os.hostname()
Parameters: No parameters. Returns: Hostname string.
platform
Returns a platform identifier string. Call form: os.platform().
/ std/os
$ p = os.platform()
Parameters: No parameters. Returns: Platform string.