Template
1
0
Fork 0
mirror of https://codeberg.org/forgejo/forgejo synced 2024-11-25 03:06:10 +01:00
forgejo/vendor/github.com/huandu/xstrings
6543 12a1f914f4
Vendor Update Go Libs (#13166)
* update github.com/alecthomas/chroma v0.8.0 -> v0.8.1

* github.com/blevesearch/bleve v1.0.10 -> v1.0.12

* editorconfig-core-go v2.1.1 -> v2.3.7

* github.com/gliderlabs/ssh v0.2.2 -> v0.3.1

* migrate editorconfig.ParseBytes to Parse

* github.com/shurcooL/vfsgen to 0d455de96546

* github.com/go-git/go-git/v5 v5.1.0 -> v5.2.0

* github.com/google/uuid v1.1.1 -> v1.1.2

* github.com/huandu/xstrings v1.3.0 -> v1.3.2

* github.com/klauspost/compress v1.10.11 -> v1.11.1

* github.com/markbates/goth v1.61.2 -> v1.65.0

* github.com/mattn/go-sqlite3 v1.14.0 -> v1.14.4

* github.com/mholt/archiver v3.3.0 -> v3.3.2

* github.com/microcosm-cc/bluemonday 4f7140c49acb -> v1.0.4

* github.com/minio/minio-go v7.0.4 -> v7.0.5

* github.com/olivere/elastic v7.0.9 -> v7.0.20

* github.com/urfave/cli v1.20.0 -> v1.22.4

* github.com/prometheus/client_golang v1.1.0 -> v1.8.0

* github.com/xanzy/go-gitlab v0.37.0 -> v0.38.1

* mvdan.cc/xurls v2.1.0 -> v2.2.0

Co-authored-by: Lauris BH <lauris@nix.lv>
2020-10-16 01:06:27 -04:00
..
.gitignore More expansions in template repositories (#10021) 2020-01-28 13:57:15 +00:00
.travis.yml More expansions in template repositories (#10021) 2020-01-28 13:57:15 +00:00
common.go Vendor Update Go Libs (#13166) 2020-10-16 01:06:27 -04:00
CONTRIBUTING.md More expansions in template repositories (#10021) 2020-01-28 13:57:15 +00:00
convert.go Vendor Update Go Libs (#13166) 2020-10-16 01:06:27 -04:00
count.go More expansions in template repositories (#10021) 2020-01-28 13:57:15 +00:00
doc.go More expansions in template repositories (#10021) 2020-01-28 13:57:15 +00:00
format.go Vendor Update Go Libs (#13166) 2020-10-16 01:06:27 -04:00
go.mod More expansions in template repositories (#10021) 2020-01-28 13:57:15 +00:00
LICENSE More expansions in template repositories (#10021) 2020-01-28 13:57:15 +00:00
manipulate.go Vendor Update Go Libs (#13166) 2020-10-16 01:06:27 -04:00
README.md More expansions in template repositories (#10021) 2020-01-28 13:57:15 +00:00
stringbuilder.go Vendor Update Go Libs (#13166) 2020-10-16 01:06:27 -04:00
stringbuilder_go110.go Vendor Update Go Libs (#13166) 2020-10-16 01:06:27 -04:00
translate.go Vendor Update Go Libs (#13166) 2020-10-16 01:06:27 -04:00

xstrings

Build Status GoDoc Go Report Coverage Status

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.center in Python; String#center in Ruby #30
Count String#count in Ruby #16
Delete String#delete in Ruby #17
ExpandTabs str.expandtabs in Python #27
FirstRuneToLower lcfirst in PHP or Perl #15
FirstRuneToUpper String#capitalize in Ruby; ucfirst in PHP or Perl #15
Insert String#insert in Ruby #18
LastPartition str.rpartition in Python; String#rpartition in Ruby #19
LeftJustify str.ljust in Python; String#ljust in Ruby #28
Len mb_strlen in PHP #23
Partition str.partition in Python; String#partition in Ruby #10
Reverse String#reverse in Ruby; strrev in PHP; reverse in Perl #7
RightJustify str.rjust in Python; String#rjust in Ruby #29
RuneWidth - #27
Scrub String#scrub in Ruby #20
Shuffle str_shuffle in PHP #13
ShuffleSource str_shuffle in PHP #13
Slice mb_substr in PHP #9
Squeeze String#squeeze in Ruby #11
Successor String#succ or String#next in Ruby #22
SwapCase str.swapcase in Python; String#swapcase in Ruby #12
ToCamelCase String#camelize in RoR #1
ToKebab - #41
ToSnakeCase String#underscore in RoR #1
Translate str.translate in Python; String#tr in Ruby; strtr in PHP; tr/// in Perl #21
Width mb_strwidth in PHP #26
WordCount str_word_count in 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.count in Python; substr_count in PHP
EqualFold stricmp in PHP; String#casecmp in Ruby
Fields str.split in Python; split in Perl; String#split in Ruby
FieldsFunc -
HasPrefix str.startswith in Python; String#start_with? in Ruby
HasSuffix str.endswith in Python; String#end_with? in Ruby
Index str.index in Python; String#index in Ruby; strpos in PHP; index in Perl
IndexAny -
IndexByte -
IndexFunc -
IndexRune -
Join str.join in Python; Array#join in Ruby; implode in PHP; join in Perl
LastIndex str.rindex in Python; String#rindex; strrpos in PHP; rindex in Perl
LastIndexAny -
LastIndexFunc -
Map String#each_codepoint in Ruby
Repeat operator * in Python and Ruby; str_repeat in PHP
Replace str.replace in Python; String#sub in Ruby; str_replace in PHP
Split str.split in Python; String#split in Ruby; explode in PHP; split in Perl
SplitAfter -
SplitAfterN -
SplitN str.split in Python; String#split in Ruby; explode in PHP; split in Perl
Title str.title in Python
ToLower str.lower in Python; String#downcase in Ruby; strtolower in PHP; lc in Perl
ToLowerSpecial -
ToTitle -
ToTitleSpecial -
ToUpper str.upper in Python; String#upcase in Ruby; strtoupper in PHP; uc in Perl
ToUpperSpecial -
Trim str.strip in Python; String#strip in Ruby; trim in PHP
TrimFunc -
TrimLeft str.lstrip in Python; String#lstrip in Ruby; ltrim in PHP
TrimLeftFunc -
TrimPrefix -
TrimRight str.rstrip in Python; String#rstrip in Ruby; rtrim in PHP
TrimRightFunc -
TrimSpace str.strip in Python; String#strip in Ruby; trim in PHP
TrimSuffix String#chomp in Ruby; chomp in Perl

License

This library is licensed under MIT license. See LICENSE for details.