github.com/Aoi-hosizora/ahlib@v1.5.1-0.20230404072829-241b93cf91c7/xstring/README.md (about)

     1  # xstring
     2  
     3  ## Dependencies
     4  
     5  + (xtesting)
     6  
     7  ## Document
     8  
     9  ### Types
    10  
    11  + None
    12  
    13  ### Variables
    14  
    15  + None
    16  
    17  ### Constants
    18  
    19  + `const CaseSplitter string`
    20  
    21  ### Functions
    22  
    23  + `func Capitalize(s string) string`
    24  + `func Uncapitalize(s string) string`
    25  + `func CapitalizeAll(s string) string`
    26  + `func UncapitalizeAll(s string) string`
    27  + `func IsArabicNumber(r rune) bool`
    28  + `func IsBlank(r rune) bool`
    29  + `func TrimBlanks(s string) string`
    30  + `func ReplaceExtraBlanks(s, repl string) string`
    31  + `func RemoveExtraBlanks(s string) string`
    32  + `func IsBreakLine(ch rune) bool`
    33  + `func TrimBreakLines(s string) string`
    34  + `func ReplaceExtraBreakLines(s, repl string) string`
    35  + `func RemoveExtraBreakLines(s string) string`
    36  + `func ReplaceExtraCharacters(s, repl string, f func(rune) bool) string`
    37  + `func SplitToWords(s string, seps ...string) []string`
    38  + `func PascalCase(s string, extraSeps ...string) string`
    39  + `func CamelCase(s string, extraSeps ...string) string`
    40  + `func SnakeCase(s string, extraSeps ...string) string`
    41  + `func KebabCase(s string, extraSeps ...string) string`
    42  + `func TimeID(t time.Time, count int) string`
    43  + `func RandString(count int, runes []rune) string`
    44  + `func RandCapitalLetterString(count int) string`
    45  + `func RandLowercaseLetterString(count int) string`
    46  + `func RandLetterString(count int) string`
    47  + `func RandNumberString(count int) string`
    48  + `func RandCapitalLetterNumberString(count int) string`
    49  + `func RandLowercaseLetterNumberString(count int) string`
    50  + `func RandLetterNumberString(count int) string`
    51  + `func FastStob(s string) []byte`
    52  + `func FastBtos(bs []byte) string`
    53  + `func TrimUTF8Bom(s string) string`
    54  + `func TrimUTF8BomBytes(bs []byte) []byte`
    55  + `func TrimUTF8Replacement(s string) string`
    56  + `func TrimUTF8ReplacementBytes(bs []byte) []byte`
    57  + `func PadLeft(s string, pad rune, totalLength int) string`
    58  + `func PadRight(s string, pad rune, totalLength int) string`
    59  + `func GetLeft(s string, length int) string`
    60  + `func GetRight(s string, length int) string`
    61  + `func GetOrPadLeft(s string, length int, pad rune) string`
    62  + `func GetOrPadRight(s string, length int, pad rune) string`
    63  + `func ExtraSpaceOnLeftIfNotEmpty(s string) string`
    64  + `func ExtraSpaceOnRightIfNotEmpty(s string) string`
    65  + `func ExtraSpaceOnLeftIfNotBlank(s string) string`
    66  + `func ExtraSpaceOnRightIfNotBlank(s string) string`
    67  + `func Bool(b bool, t, f string) string`
    68  + `func MaskToken(s string, mask rune, indices ...int) string`
    69  + `func MaskTokenR(s string, mask rune, indices ...int) string`
    70  + `func StringMaskToken(s string, mask string, indices ...int) string`
    71  + `func StringMaskTokenR(s string, mask string, indices ...int) string`
    72  + `func EncodeUrlValues(values map[string][]string, escapeFunc func(string) string) string`
    73  + `func SplitAndGet(s string, sep string, index int) string`
    74  + `func StringSliceToMap(args []string) map[string]string`
    75  + `func SliceToStringMap(args []interface{}) map[string]interface{}`
    76  + `func SemanticVersion(semver string) (uint64, uint64, uint64, error)`
    77  
    78  ### Methods
    79  
    80  + None
    81  
    82  ## xstring Benchmark Result
    83  
    84  ### go1.19.6
    85  
    86  ``` go
    87  /*
    88  	$ go version
    89  	go version go1.19.6 windows/amd64
    90  
    91  	$ go test . -run none -v -bench . -cpu 2,4,8
    92  	goos: windows
    93  	goarch: amd64
    94  	pkg: github.com/Aoi-hosizora/ahlib/xstring
    95  	cpu: Intel(R) Core(TM) i5-8250U CPU @ 1.60GHz
    96  	BenchmarkFastStob
    97  	BenchmarkFastStob/FastStob
    98  	BenchmarkFastStob/FastStob-2            1000000000               0.3857 ns/op          0 B/op          0 allocs/op
    99  	BenchmarkFastStob/FastStob-4            1000000000               0.6912 ns/op          0 B/op          0 allocs/op
   100  	BenchmarkFastStob/FastStob-8            1000000000               0.6593 ns/op          0 B/op          0 allocs/op
   101  	BenchmarkFastStob/ConvertToBytes
   102  	BenchmarkFastStob/ConvertToBytes-2      100000000               11.31 ns/op            0 B/op          0 allocs/op
   103  	BenchmarkFastStob/ConvertToBytes-4      228045162                5.782 ns/op           0 B/op          0 allocs/op
   104  	BenchmarkFastStob/ConvertToBytes-8      100000000               11.82 ns/op            0 B/op          0 allocs/op
   105  	BenchmarkFastBtos
   106  	BenchmarkFastBtos/FastBtos
   107  	BenchmarkFastBtos/FastBtos-2            1000000000               0.8827 ns/op          0 B/op          0 allocs/op
   108  	BenchmarkFastBtos/FastBtos-4            1000000000               0.8811 ns/op          0 B/op          0 allocs/op
   109  	BenchmarkFastBtos/FastBtos-8            1000000000               0.6468 ns/op          0 B/op          0 allocs/op
   110  	BenchmarkFastBtos/ConvertToString
   111  	BenchmarkFastBtos/ConvertToString-2     279168709                8.088 ns/op           0 B/op          0 allocs/op
   112  	BenchmarkFastBtos/ConvertToString-4     100000000               10.60 ns/op            0 B/op          0 allocs/op
   113  	BenchmarkFastBtos/ConvertToString-8     240822021               11.52 ns/op            0 B/op          0 allocs/op
   114  	PASS
   115  	ok      github.com/Aoi-hosizora/ahlib/xstring   18.240s
   116  */
   117  ```
   118  
   119  ### go1.18.1
   120  
   121  ```go
   122  /*
   123  	$ go version
   124  	go version go1.18.1 windows/amd64
   125  
   126  	$ go test . -run none -v -bench . -cpu 2,4,8
   127  	goos: windows
   128  	goarch: amd64
   129  	pkg: github.com/Aoi-hosizora/ahlib/xstring
   130  	cpu: Intel(R) Core(TM) i5-4300U CPU @ 1.90GHz
   131  	BenchmarkFastStob
   132  	BenchmarkFastStob/FastStob
   133  	BenchmarkFastStob/FastStob-2            1000000000               0.7139 ns/op          0 B/op          0 allocs/op
   134  	BenchmarkFastStob/FastStob-4            1000000000               0.6428 ns/op          0 B/op          0 allocs/op
   135  	BenchmarkFastStob/FastStob-8            1000000000               0.7157 ns/op          0 B/op          0 allocs/op
   136  	BenchmarkFastStob/ConvertToBytes
   137  	BenchmarkFastStob/ConvertToBytes-2      100000000               12.72 ns/op            0 B/op          0 allocs/op
   138  	BenchmarkFastStob/ConvertToBytes-4      86662959                13.79 ns/op            0 B/op          0 allocs/op
   139  	BenchmarkFastStob/ConvertToBytes-8      75211532                14.25 ns/op            0 B/op          0 allocs/op
   140  	BenchmarkFastBtos
   141  	BenchmarkFastBtos/FastBtos
   142  	BenchmarkFastBtos/FastBtos-2            1000000000               0.7057 ns/op          0 B/op          0 allocs/op
   143  	BenchmarkFastBtos/FastBtos-4            1000000000               0.7064 ns/op          0 B/op          0 allocs/op
   144  	BenchmarkFastBtos/FastBtos-8            1000000000               0.6068 ns/op          0 B/op          0 allocs/op
   145  	BenchmarkFastBtos/ConvertToString
   146  	BenchmarkFastBtos/ConvertToString-2     90174807                13.52 ns/op            0 B/op          0 allocs/op
   147  	BenchmarkFastBtos/ConvertToString-4     106228897               13.05 ns/op            0 B/op          0 allocs/op
   148  	BenchmarkFastBtos/ConvertToString-8     64067654                33.94 ns/op            0 B/op          0 allocs/op
   149  	PASS
   150  	ok      github.com/Aoi-hosizora/ahlib/xstring   16.640s
   151  */
   152  ```