fmt

package
v0.8.4 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2020 License: LGPL-2.1 Imports: 8 Imported by: 0

Documentation

Overview

Suite of string formatting utilities.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Commands

type Commands struct {
	utils.Module
	// contains filtered or unexported fields
}

func New

func New(env utils.Runtime) *Commands

func (*Commands) Autotype

func (self *Commands) Autotype(input interface{}) (interface{}, error)

Takes an input value and returns that value as the most appropriate data type based on its contents.

func (*Commands) Camelize

func (self *Commands) Camelize(input interface{}) (string, error)

Return the given string converted to camelCase.

func (*Commands) Codepoints added in v0.6.4

func (self *Commands) Codepoints(input interface{}) ([]int, error)

Return an array of Unicode codepoints for each character in the given string.

func (*Commands) Format

func (self *Commands) Format(pattern string, args *FormatArgs) (string, error)

Format the given string according to the given pattern and values.

func (*Commands) Join

func (self *Commands) Join(inputs interface{}, args *JoinArgs) (string, error)

Join an array of inputs into a single string, with each item separated by a given joiner string.

func (*Commands) Lcp

func (self *Commands) Lcp(inputs interface{}) (string, error)

Returns the longest common prefix among an array of input strings.

func (*Commands) Lower

func (self *Commands) Lower(input interface{}) (string, error)

Return the given string converted to lowercase.

func (*Commands) Pascalize

func (self *Commands) Pascalize(input interface{}) (string, error)

Return the given string converted to PascalCase.

func (*Commands) Replace

func (self *Commands) Replace(input interface{}, args *ReplaceArgs) (string, error)

Replaces values in an input string (exact matches or regular expressions) with a replacement value. Exact matches will be replaced up to a certain number of times, or all occurrences of count is -1 (default).

func (*Commands) Split

func (self *Commands) Split(input interface{}, args *SplitArgs) ([]string, error)

Split a given string by a given delimiter.

func (*Commands) Strip

func (self *Commands) Strip(input interface{}) (string, error)

Strip leading and trailing whitespace from the given string.

func (*Commands) Title

func (self *Commands) Title(input interface{}) (string, error)

Return the given string converted to Title Case.

func (*Commands) Trim

func (self *Commands) Trim(input interface{}, args *TrimArgs) (string, error)

Remove a leading and/org trailing string value from the given string.

func (*Commands) Underscore

func (self *Commands) Underscore(input interface{}) (string, error)

Return the given string converted to underscore_case.

func (*Commands) Upper

func (self *Commands) Upper(input interface{}) (string, error)

Return the given string converted to UPPERCASE.

type FormatArgs

type FormatArgs struct {
	Data interface{} `json:"data"`
}

type JoinArgs

type JoinArgs struct {
	Joiner string `json:"joiner" default:","`
}

type ReplaceArgs

type ReplaceArgs struct {
	Find    interface{} `json:"find"`
	Replace string      `json:"replace"`
	Count   int         `json:"count" default:"-1"`
}

type SplitArgs

type SplitArgs struct {
	On string `json:"on" default:","`
}

type TrimArgs

type TrimArgs struct {
	Prefix string `json:"prefix"`
	Suffix string `json:"suffix"`
}

Jump to

Keyboard shortcuts

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