Documentation ¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Stringify ¶
func Stringify(v interface{}) string
Stringify converts a given interface into a human readable string
Example ¶
package main import ( "fmt" "github.com/VirtusLab/kubedrainer/internal/stringer" ) func main() { var value = []string{ "one", "two", "three", } valuePtr := &value //lint:ignore S1021 needed for the test var valueInter interface{} valueInter = value valueInterPtr := &valueInter fmt.Println(stringer.Stringify(nil)) fmt.Println(stringer.Stringify("")) fmt.Println(stringer.Stringify(value)) fmt.Println(stringer.Stringify(valuePtr)) fmt.Println(stringer.Stringify(&valuePtr)) fmt.Println(stringer.Stringify(valueInter)) fmt.Println(stringer.Stringify(valueInterPtr)) fmt.Println(stringer.Stringify(&valueInterPtr)) }
Output: <nil> [one two three] [one two three] [one two three] [one two three] [one two three] [one two three]
Example (Nested) ¶
package main import ( "fmt" "github.com/VirtusLab/kubedrainer/internal/stringer" ) type tester struct { one string two *string nested *tester } func main() { second := "second" t := &tester{ one: "first", two: &second, nested: &tester{ one: "", two: &second, nested: nil, }, } fmt.Println(stringer.Stringify(t)) }
Output: {one:first two:second nested:{one: two:second nested:<nil>}}
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.