Templates!!! v6.25.0
π Exciting New Release for Gofakeit v6!
We're thrilled to introduce the latest version of Gofakeit, packed with a powerful addition to enhance your templating experience. Brace yourself for the introduction of custom outputs using Golang's template engine! π
SPECIAL THANKS to @Mrpye for his work on this!
π Template Magic
Now, you can unleash your creativity with custom outputs using Golang's template engine. We've integrated all available functions into the template engine, providing you with a versatile toolkit to craft dynamic and personalized content.
π Additional Functions
But that's not all! We've gone the extra mile and added some game-changing functions to supercharge your template building:
ToUpper & ToLower: Easily manipulate text case for a polished appearance.
ToString: Swiftly convert any data type to a string.
ToDate: Effortlessly transform strings into time.Time objects.
SpliceAny, SpliceString, SpliceUInt, SpliceInt: Build slices dynamically, perfect for weighted scenarios and random selections.
π Example Usages
To give you a taste of the excitement, here's a snippet showcasing the newfound template capabilities:
// Your template goes here
template := `
Subject: {{RandomString (SliceString "Greetings" "Hello" "Hi")}}
Dear {{LastName}},
{{RandomString (SliceString "Greetings!" "Hello there!" "Hi, how are you?")}}
{{Paragraph 1 5 10 "\n\n"}}
{{RandomString (SliceString "Warm regards" "Best wishes" "Sincerely")}}
{{$person:=Person}}
{{$person.FirstName}} {{$person.LastName}}
{{$person.Email}}
{{$person.Phone}}
`
// Applying the template
value, err := gofakeit.Template(template, nil)