Transform is a Go library that provides a simple way to transform data from one format to another.
go get github.com/zeiss/go-transform
type example struct {
Name string `tansform:"trim,lowercase"`
}
t := transform.New()
e := example{Name: " John Doe "}
if err := t.Transform(&e); err != nil {
log.Fatal(err)
}
fmt.Println(e.Name) // Output: john doe
This is the list of all available transformations:
Function | Description |
---|---|
trim |
Removes leading and trailing whitespace. |
lowercase |
Converts the string to lowercase. |
uppercase |
Converts the string to uppercase. |
rtrim |
Removes trailing whitespace. |
ltrim |
Removes leading whitespace. |
uppercase |
Converts the string to uppercase. |