util

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2025 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Examples

Constants

View Source
const (
	NoLineBreakAttrKey = "no_line_break"
)

Variables

View Source
var (
	AppVersion = "0.0.0"
)

Functions

func Base64Decode added in v0.2.0

func Base64Decode(text string) (string, error)

func Base64Encode added in v0.2.0

func Base64Encode(text string) string

func Dedent added in v0.2.0

func Dedent(text string) string
Example
s := `
		Lorem ipsum dolor sit amet,
		consectetur adipiscing elit.
		Curabitur justo tellus, facilisis nec efficitur dictum,
		fermentum vitae ligula. Sed eu convallis sapien.`
fmt.Println(Dedent(s))
fmt.Println("-------------")
fmt.Println(s)
Output:
Lorem ipsum dolor sit amet,
consectetur adipiscing elit.
Curabitur justo tellus, facilisis nec efficitur dictum,
fermentum vitae ligula. Sed eu convallis sapien.
-------------

		Lorem ipsum dolor sit amet,
		consectetur adipiscing elit.
		Curabitur justo tellus, facilisis nec efficitur dictum,
		fermentum vitae ligula. Sed eu convallis sapien.

func Indent added in v0.2.0

func Indent(text string, numberOfSpaces int) string

Indents the each line with given number of spaces except the first line.

Example
indented := Indent(`line1
  line2
line3`, 2)

fmt.Println(indented)
Output:
line1
    line2
  line3

func IndentTab added in v0.2.0

func IndentTab(text string, numberOfTabs int) string

Indents the each line with given number of tabs except the first line.

func MultilineString added in v0.2.0

func MultilineString(text string) string

Dedents the data using Dedent so that the multiline strings with indentation are handled properly. Trims the spaces after dedent.

Example
indented := MultilineString(`
	line1
	  line2
	line3`)

fmt.Println(indented)
Output:
line1
  line2
line3

func ParseTemplate added in v0.2.0

func ParseTemplate(templateText string, data any) string

Parses a template as a string by calling MultilineString on template text beforehand. Panics if template is invalid.

func SlogNoLineBreakAttr

func SlogNoLineBreakAttr() slog.Attr

func ToKubernetesIdentifier added in v0.2.0

func ToKubernetesIdentifier(name string) string

Converts a string to a valid Kubernetes identifier by replacing invalid characters.

Types

This section is empty.

Jump to

Keyboard shortcuts

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