|  28216bde46 * Super expansion * Explain which features are in 1.11 vs 1.12 * Move imports Signed-off-by: jolheiser <john.olheiser@gmail.com> | ||
|---|---|---|
| .. | ||
| .gitignore | ||
| .travis.yml | ||
| common.go | ||
| CONTRIBUTING.md | ||
| convert.go | ||
| count.go | ||
| doc.go | ||
| format.go | ||
| go.mod | ||
| LICENSE | ||
| manipulate.go | ||
| README.md | ||
| translate.go | ||
xstrings
Go package xstrings is a collection of string functions, which are widely used in other languages but absent in Go package strings.
All functions are well tested and carefully tuned for performance.
Propose a new function
Please review contributing guideline and create new issue to state why it should be included.
Install
Use go get to install this library.
go get github.com/huandu/xstrings
API document
See GoDoc for full document.
Function list
Go functions have a unique naming style. One, who has experience in other language but new in Go, may have difficulties to find out right string function to use.
Here is a list of functions in strings and xstrings with enough extra information about how to map these functions to their friends in other languages. Hope this list could be helpful for fresh gophers.
Package xstrings functions
Keep this table sorted by Function in ascending order.
| Function | Friends | # | 
|---|---|---|
| Center | str.centerin Python;String#centerin Ruby | #30 | 
| Count | String#countin Ruby | #16 | 
| Delete | String#deletein Ruby | #17 | 
| ExpandTabs | str.expandtabsin Python | #27 | 
| FirstRuneToLower | lcfirstin PHP or Perl | #15 | 
| FirstRuneToUpper | String#capitalizein Ruby;ucfirstin PHP or Perl | #15 | 
| Insert | String#insertin Ruby | #18 | 
| LastPartition | str.rpartitionin Python;String#rpartitionin Ruby | #19 | 
| LeftJustify | str.ljustin Python;String#ljustin Ruby | #28 | 
| Len | mb_strlenin PHP | #23 | 
| Partition | str.partitionin Python;String#partitionin Ruby | #10 | 
| Reverse | String#reversein Ruby;strrevin PHP;reversein Perl | #7 | 
| RightJustify | str.rjustin Python;String#rjustin Ruby | #29 | 
| RuneWidth | - | #27 | 
| Scrub | String#scrubin Ruby | #20 | 
| Shuffle | str_shufflein PHP | #13 | 
| ShuffleSource | str_shufflein PHP | #13 | 
| Slice | mb_substrin PHP | #9 | 
| Squeeze | String#squeezein Ruby | #11 | 
| Successor | String#succorString#nextin Ruby | #22 | 
| SwapCase | str.swapcasein Python;String#swapcasein Ruby | #12 | 
| ToCamelCase | String#camelizein RoR | #1 | 
| ToKebab | - | #41 | 
| ToSnakeCase | String#underscorein RoR | #1 | 
| Translate | str.translatein Python;String#trin Ruby;strtrin PHP;tr///in Perl | #21 | 
| Width | mb_strwidthin PHP | #26 | 
| WordCount | str_word_countin PHP | #14 | 
| WordSplit | - | #14 | 
Package strings functions
Keep this table sorted by Function in ascending order.
| Function | Friends | 
|---|---|
| Contains | String#include?in Ruby | 
| ContainsAny | - | 
| ContainsRune | - | 
| Count | str.countin Python;substr_countin PHP | 
| EqualFold | stricmpin PHP;String#casecmpin Ruby | 
| Fields | str.splitin Python;splitin Perl;String#splitin Ruby | 
| FieldsFunc | - | 
| HasPrefix | str.startswithin Python;String#start_with?in Ruby | 
| HasSuffix | str.endswithin Python;String#end_with?in Ruby | 
| Index | str.indexin Python;String#indexin Ruby;strposin PHP;indexin Perl | 
| IndexAny | - | 
| IndexByte | - | 
| IndexFunc | - | 
| IndexRune | - | 
| Join | str.joinin Python;Array#joinin Ruby;implodein PHP;joinin Perl | 
| LastIndex | str.rindexin Python;String#rindex;strrposin PHP;rindexin Perl | 
| LastIndexAny | - | 
| LastIndexFunc | - | 
| Map | String#each_codepointin Ruby | 
| Repeat | operator *in Python and Ruby;str_repeatin PHP | 
| Replace | str.replacein Python;String#subin Ruby;str_replacein PHP | 
| Split | str.splitin Python;String#splitin Ruby;explodein PHP;splitin Perl | 
| SplitAfter | - | 
| SplitAfterN | - | 
| SplitN | str.splitin Python;String#splitin Ruby;explodein PHP;splitin Perl | 
| Title | str.titlein Python | 
| ToLower | str.lowerin Python;String#downcasein Ruby;strtolowerin PHP;lcin Perl | 
| ToLowerSpecial | - | 
| ToTitle | - | 
| ToTitleSpecial | - | 
| ToUpper | str.upperin Python;String#upcasein Ruby;strtoupperin PHP;ucin Perl | 
| ToUpperSpecial | - | 
| Trim | str.stripin Python;String#stripin Ruby;trimin PHP | 
| TrimFunc | - | 
| TrimLeft | str.lstripin Python;String#lstripin Ruby;ltrimin PHP | 
| TrimLeftFunc | - | 
| TrimPrefix | - | 
| TrimRight | str.rstripin Python;String#rstripin Ruby;rtrimin PHP | 
| TrimRightFunc | - | 
| TrimSpace | str.stripin Python;String#stripin Ruby;trimin PHP | 
| TrimSuffix | String#chompin Ruby;chompin Perl | 
License
This library is licensed under MIT license. See LICENSE for details.