package corestrings
import "github.com/purpleidea/mgmt/lang/core/strings"
Index ¶
- Constants
- func JoinNonempty(ctx context.Context, input []types.Value) (types.Value, error)
- func LeftPad(ctx context.Context, input []types.Value) (types.Value, error)
- func RightPad(ctx context.Context, input []types.Value) (types.Value, error)
- func Split(ctx context.Context, input []types.Value) (types.Value, error)
- func SubStr(ctx context.Context, input []types.Value) (types.Value, error)
- func ToLower(ctx context.Context, input []types.Value) (types.Value, error)
Constants ¶
const ( // ModuleName is the prefix given to all the functions in this module. ModuleName = "strings" )
Functions ¶
func JoinNonempty ¶
JoinNonempty behaves exactly like the regular string join, except it filters out empty elements first. Since this behaviour is commonly useful when writing scripts, we include it as a built-in primitive, since it is also cheaper than running the graph changing, filter function. TODO: compiler optimization: find patterns where someone used the filter function as previously described, and replace it with this implementation.
func LeftPad ¶
LeftPad adds multiples of the pad string to the left of the input string until it reaches a minimum length. If the padding string is not an integer multiple of the missing length to pad, then this will overshoot. It is better to overshoot than to undershoot because if you need a string of a precise length, then it's easier to truncate the result, rather than having to pad even more. Most scenarios pad with a single char meaning this is not even an issue.
func RightPad ¶
RightPad adds multiples of the pad string to the right of the input string until it reaches a minimum length. If the padding string is not an integer multiple of the missing length to pad, then this will overshoot. It is better to overshoot than to undershoot because if you need a string of a precise length, then it's easier to truncate the result, rather than having to pad even more. Most scenarios pad with a single char meaning this is not even an issue.
func Split ¶
Split splits the input string using the separator and returns the segments as a list.
func SubStr ¶
SubStr returns a substring of the input string from low to high.
func ToLower ¶
ToLower turns a string to lowercase.
Source Files ¶
join_nonempty.go pad.go split.go strings.go substring.go to_lower.go
- Version
- v0.0.0-20250322185616-c50a578426f1 (latest)
- Published
- Mar 22, 2025
- Platform
- linux/amd64
- Imports
- 6 packages
- Last checked
- 4 days ago –
Tools for package owners.