Documentation
¶
Index ¶
- Constants
- func Format(template string, args ...any) string
- func FormatComplex(template string, args map[string]any) string
- func GetFormattingStyleOptions(style string) (FormattingStyle, CaseSetting, CaseSetting)
- func MapToString[K string | int | uint | int32 | int64 | uint32 | uint64, V any](data map[K]V, format string, separator string) string
- func SetStyle(text *string, style FormattingStyle, firstSymbol CaseSetting, ...) string
- func SliceSameTypeToString[T any](data *[]T, separator *string) string
- func SliceToString(data *[]any, separator *string) string
- type CaseSetting
- type FormattingStyle
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 GetFormattingStyleOptions ¶ added in v1.6.0
func GetFormattingStyleOptions(style string) (FormattingStyle, CaseSetting, CaseSetting)
GetFormattingStyleOptions function that defines formatting style, case of first char and result from 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 SetStyle ¶ added in v1.6.0
func SetStyle(text *string, style FormattingStyle, firstSymbol CaseSetting, textCase CaseSetting) string
SetStyle is a function that converts text with code to defined code style.
Set text like a code style to on from FormattingStyle (Camel, Snake, or Kebab) * conversion of abbreviations like JSON, USB, and so on is going like a regular text * for current version, therefore they these abbreviations could be in a different * case after conversion. * Case settings apply in the following order : 1 - textCase, 2 - firstSymbol. * If you are not applying textCase to text converting from Camel to Snake or Kebab * result is lower case styled text. textCase does not apply to Camel style. * Parameters: * - text - pointer to text * - style - new code style * - firstSymbol - case settings for first symbol * - textCase - case settings for whole text except first symbol * Returns : new string with formatted line
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 ¶
type CaseSetting ¶ added in v1.6.0
type CaseSetting int
const ( ToUpper CaseSetting = 1 ToLower CaseSetting = 2 NoChanges CaseSetting = 3 )
type FormattingStyle ¶ added in v1.6.0
type FormattingStyle string
const ( Camel FormattingStyle = "camel" Snake FormattingStyle = "snake" Kebab FormattingStyle = "kebab" )
Click to show internal directories.
Click to hide internal directories.



