Documentation ¶
Overview ¶
transform package contains all base functions to transform one string to another
Index ¶
- func Circle(str string) string
- func CircleInverse(str string) string
- func Double(str string) string
- func Emoji(s string) string
- func Flip(str string) string
- func Reverse(value string) string
- func Spacer(s string) string
- func Square(str string) string
- func SquareInverse(str string) string
- type StringFn
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Circle ¶
Circle returns all characters inside circles
Example ¶
Converts all characters to circled characters
package main import ( "fmt" "github.com/guumaster/textifier/pkg/transform" ) func main() { text := transform.Circle("hello") fmt.Println(text) }
Output: ⓗⓔⓛⓛⓞ
func CircleInverse ¶
CircleInverse like circle but with filled background
Example ¶
Converts same as Circle but with background
package main import ( "fmt" "github.com/guumaster/textifier/pkg/transform" ) func main() { text := transform.Circle("hello world") fmt.Println(text) }
Output: 🅗🅔🅛🅛🅞
func Emoji ¶
Emoji parse emoji codes like Github or Slack. ex: :boom:
Example ¶
Converts emoji codes like GitHub or Slack
package main import ( "fmt" "github.com/guumaster/textifier/pkg/transform" ) func main() { text := transform.Emoji(":boom: Hello :beer: World! :earth_americas:") fmt.Println(text) }
Output: 💥 Hello 🍺 World! 🌎
func Flip ¶
Flip turns text upside down
Example ¶
Turns the text upside down
package main import ( "fmt" "github.com/guumaster/textifier/pkg/transform" ) func main() { text := transform.Flip("Hello World") fmt.Println(text) }
Output: plɹoM ollǝH
func Reverse ¶
Reverse return a string in reverse order
Example ¶
Change direction of the whole text
package main import ( "fmt" "github.com/guumaster/textifier/pkg/transform" ) func main() { text := transform.Reverse("Hello World") fmt.Println(text) }
Output: dlroW olleH
func Spacer ¶
Spacer add spaces between letters
Example ¶
Add spaces between characters
package main import ( "fmt" "github.com/guumaster/textifier/pkg/transform" ) func main() { text := transform.Spacer("Hello World") fmt.Println(text) }
Output: H e l l o W o r l d
func Square ¶
Square transform characters to squared
Example ¶
Converts all characters to squared characters
package main import ( "fmt" "github.com/guumaster/textifier/pkg/transform" ) func main() { text := transform.Square("Hello World") fmt.Println(text) }
Output: 🄷🄴🄻🄻🄾 🅆🄾🅁🄻🄳
func SquareInverse ¶
Square same as Square but with filled background
Example ¶
Same as Square but with filled background
package main import ( "fmt" "github.com/guumaster/textifier/pkg/transform" ) func main() { text := transform.Square("Hello World") fmt.Println(text) }
Output: 🅷🅴🅻🅻🅾 🆆🅾🆁🅻🅳
Types ¶
type StringFn ¶
StringFn is the basic composable function type
func Compose ¶
Compose combine two transformers together
Example ¶
This example show how to compose more than one transformer together
package main import ( "fmt" "strings" "github.com/guumaster/textifier/pkg/transform" ) func main() { tr := transform.Compose( transform.Reverse, strings.ToUpper, // <- Note that you can use any other function with same signature as StringFn transform.SquareInverse, transform.Spacer, transform.Emoji, ) text := tr(":boom: Hello World") fmt.Println(text) }
Output: 🅳 🅻 🆁 🅾 🆆 🅾 🅻 🅻 🅴 🅷 💥