env

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2023 License: MIT Imports: 3 Imported by: 0

README

env

Package env provides a platform-independent interface for environment variables with a twist.

Documentation

Overview

Package shlex implements a simple lexer which expands environment variables using shell-style rules for quoting and commenting.

The basic use case uses the default ASCII lexer to split a string into sub-strings:

shlex.Expand("one ${A} four", ...) -> "one X four"

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Expand

func Expand(s string, mapping MappingFunc) (string, error)

Expand replaces ${var}, ${var:def} or $var in the string based on the mapping function.

Types

type MappingFunc

type MappingFunc func(key string) (string, bool)

MappingFunc is the type of the function called by Expand to retrieve the value of the environment variable named by the key. If the variable is present in the environment the value (which may be empty) is returned and the boolean is true. Otherwise, the returned value will be empty and the boolean will be false.

Jump to

Keyboard shortcuts

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