expand

package module
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2024 License: MIT Imports: 10 Imported by: 6

README

expand CI Go Reference Coverage Code to Test Ratio Test Execution Time

expand package provides convenient functions to apply func os.Expand efficiently.

Import

import "github.com/k1LoW/expand"

Usage

c := &Config{}
p := "config.yml"
buf, err := os.ReadFile(p)
if err != nil {
    return err
}
if err := yaml.Unmarshal(expand.ExpandenvYAMLBytes(buf), c); err != nil {
    return err
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExpandYAML

func ExpandYAML(s string, mapping func(string) (string, bool)) string

ExpandYAML replaces ${var} or $var in the values of YAML (string) based on the mapping function.

func ExpandYAMLBytes

func ExpandYAMLBytes(b []byte, mapping func(string) (string, bool)) []byte

ExpandYAML replaces ${var} or $var in the values of YAML ([]byte) based on the mapping function.

func ExpandenvYAML

func ExpandenvYAML(s string) string

ExpandenvYAML replaces ${var} or $var in the values of YAML (string) according to the values of the current environment variables.

func ExpandenvYAMLBytes

func ExpandenvYAMLBytes(b []byte) []byte

ExpandenvYAML replaces ${var} or $var in the values of YAML ([]byte) according to the values of the current environment variables.

func ExprRepFn added in v0.5.0

func ExprRepFn(delimStart, delimEnd string, env any) repFn

func InterpolateRepFn added in v0.5.0

func InterpolateRepFn(mapping func(string) (string, bool)) repFn

func ReplaceYAML added in v0.3.0

func ReplaceYAML(s string, repFn func(s string) (string, error), opts ...Option) (string, error)

ReplaceYAML replaces the tokens of YAML (string) using repFn.

Types

type Mapper added in v0.4.0

type Mapper struct {
	// contains filtered or unexported fields
}

func (Mapper) Get added in v0.4.0

func (m Mapper) Get(key string) (string, bool)

type Option added in v0.8.0

type Option func(*config) error

func QuoteCollection added in v0.8.0

func QuoteCollection() Option

QuoteCollection - Quotes the replaced value as a string if it is a map or slice.

func ReplaceMapKey added in v0.8.0

func ReplaceMapKey() Option

ReplaceMapKey - Replace map key of YAML.

Jump to

Keyboard shortcuts

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