String Utilities for Go
"strutil" provides string functions for go applications.
In some functions it may not work as expected in non-latin alphabets like cyrillic, chinese, etc. Also there may be some language spesific edge cases that aren't supported well. Any help on those areas would be appreciated.
For documentation with examples see GoDoc
Functions
| Function | Desctiption |
|---|---|
| Align | Aligns the text to the spesified side |
| AlignCenter | Aligns the text to the center |
| AlignLeft | Aligns the text to the left |
| AlignRight | Aligns the text to the right |
| Box | Draws a frame around the string with default chars |
| Center | Centers the string |
| CountWords | Count the words in the string |
| CustomBox | Draws a frame around the string with specified chars |
| ExpandTabs | Converts tabs to spaces |
| Indent | Indents the string |
| MapLines | Runs spesified function on every line of the text |
| Pad | Left and right pads the strings |
| PadLeft | Left pads the string |
| PadRight | Right pads the string |
| Random | Creates a random string from a character set |
| RemoveAccents | Remove accents in the string |
| ReplaceAllToOne | Replace all substrings in the text to the spesified string |
| Reverse | Reverses the string |
| Slugify | Converts the string to a slug |
| SplitCamelCase | Splits the words in a camelCase string |
| ToCamelCase | Converts the string to camelCase |
| ToSnakeCase | Converts the string to snake_Case |
| Substring | Returns a part of the string |
| Summary | Cuts the text to the length |
| Splice | Replaces a part of the string |
| Wordwrap | Wraps the lines in the text |
Install
Prequsities:
- Go 1.10+
Install with
go get github.com/ozgio/strutilDependencies:
go get golang.org/x/text/runes
go get golang.org/x/text/transform
go get golang.org/x/text/unicode/normImport
import "github.com/ozgio/strutil"TODO
- Improve tests. More test cases are needed
- Test for different languages
- Handle "\r\n"
- Improve whitespace and punctuation support