package convert

import "github.com/purpleidea/mgmt/lang/core/convert"

Index

Constants

const (
	// ModuleName is the prefix given to all the functions in this module.
	ModuleName = "convert"
)

Functions

func FormatBool

func FormatBool(ctx context.Context, input []types.Value) (types.Value, error)

FormatBool converts a boolean to a string representation that can be consumed by ParseBool. This value will be `"true"` or `"false"`.

func IntToStr

func IntToStr(ctx context.Context, input []types.Value) (types.Value, error)

IntToStr converts an integer to a string.

func ParseBool

func ParseBool(ctx context.Context, input []types.Value) (types.Value, error)

ParseBool parses a bool string and returns a boolean. It errors if you pass it an invalid value. Valid values match what is accepted by the golang strconv.ParseBool function. It's recommended to use the strings `true` or `false` if you are undecided about what string representation to choose.

func ToFloat

func ToFloat(ctx context.Context, input []types.Value) (types.Value, error)

ToFloat converts an integer to a float.

func ToInt

func ToInt(ctx context.Context, input []types.Value) (types.Value, error)

ToInt converts a float to an integer.

Source Files

convert.go format_bool.go parse_bool.go to_float.go to_int.go to_str.go

Version
v0.0.0-20250322185616-c50a578426f1 (latest)
Published
Mar 22, 2025
Platform
linux/amd64
Imports
5 packages
Last checked
4 days ago

Tools for package owners.