Documentation
¶
Index ¶
- Constants
- func Format(template string, args ...any) string
- func FormatComplex(template string, args map[string]any) string
- func MapToString[K string | int | uint | int32 | int64 | uint32 | uint64, V any](data map[K]V, format string, separator string) string
- func SliceSameTypeToString[T any](data *[]T, separator *string) string
- func SliceToString(data *[]any, separator *string) string
Constants ¶
View Source
const ( // KeyKey placeholder will be formatted to map key KeyKey = "key" // KeyValue placeholder will be formatted to map value KeyValue = "value" )
Variables ¶
This section is empty.
Functions ¶
func Format ¶
Format
Func that makes string formatting from template * It differs from above function only by generic interface that allow to use only primitive data types: * - integers (int, int8, int16, int32, int64, uint, uint8, uint16, uint32, uin64) * - floats (float32, float64) * - boolean * - string * - complex * - objects * This function defines format automatically * Parameters * - template - string that contains template * - args - values that are using for formatting with template * Returns formatted string
func FormatComplex ¶
FormatComplex
Function that format text using more complex templates contains string literals i.e "Hello {username} here is our application {appname}"
* Parameters
* - template - string that contains template
* - args - values (dictionary: string key - any value) that are using for formatting with template
* Returns formatted string
func MapToString ¶ added in v1.1.0
func MapToString[ K string | int | uint | int32 | int64 | uint32 | uint64, V any, ](data map[K]V, format string, separator string) string
MapToString - format map keys and values according to format, joining parts with separator. Format should contain key and value placeholders which will be used for formatting, e.g. "{key} : {value}", or "{value}", or "{key} => {value}". Parts order in resulting string is not guranteed.
func SliceSameTypeToString ¶ added in v1.4.1
func SliceToString ¶ added in v1.4.0
SliceToString function that converts slice of any type items to string in format {item}{sep}{item}... TODO(UMV): probably add one more param to wrap item in quotes if necessary
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.



