Remove github.com/satori/go.uuid.
This commit is contained in:
parent
e1d097ea20
commit
2e19e45aa4
25 changed files with 1027 additions and 365 deletions
6
vendor/github.com/huandu/xstrings/common.go
generated
vendored
6
vendor/github.com/huandu/xstrings/common.go
generated
vendored
|
@ -7,7 +7,7 @@ import (
|
|||
"bytes"
|
||||
)
|
||||
|
||||
const _BUFFER_INIT_GROW_SIZE_MAX = 2048
|
||||
const bufferMaxInitGrowSize = 2048
|
||||
|
||||
// Lazy initialize a buffer.
|
||||
func allocBuffer(orig, cur string) *bytes.Buffer {
|
||||
|
@ -15,8 +15,8 @@ func allocBuffer(orig, cur string) *bytes.Buffer {
|
|||
maxSize := len(orig) * 4
|
||||
|
||||
// Avoid to reserve too much memory at once.
|
||||
if maxSize > _BUFFER_INIT_GROW_SIZE_MAX {
|
||||
maxSize = _BUFFER_INIT_GROW_SIZE_MAX
|
||||
if maxSize > bufferMaxInitGrowSize {
|
||||
maxSize = bufferMaxInitGrowSize
|
||||
}
|
||||
|
||||
output.Grow(maxSize)
|
||||
|
|
77
vendor/github.com/huandu/xstrings/convert.go
generated
vendored
77
vendor/github.com/huandu/xstrings/convert.go
generated
vendored
|
@ -44,18 +44,25 @@ func ToCamelCase(str string) string {
|
|||
return buf.String()
|
||||
}
|
||||
|
||||
buf.WriteRune(unicode.ToUpper(r0))
|
||||
r0, size = utf8.DecodeRuneInString(str)
|
||||
str = str[size:]
|
||||
r0 = unicode.ToUpper(r0)
|
||||
|
||||
for len(str) > 0 {
|
||||
r1 = r0
|
||||
r0, size = utf8.DecodeRuneInString(str)
|
||||
str = str[size:]
|
||||
|
||||
if r1 == '_' && r0 != '_' {
|
||||
if r1 == '_' && r0 == '_' {
|
||||
buf.WriteRune(r1)
|
||||
continue
|
||||
}
|
||||
|
||||
if r1 == '_' {
|
||||
r0 = unicode.ToUpper(r0)
|
||||
} else {
|
||||
r0 = unicode.ToLower(r0)
|
||||
}
|
||||
|
||||
if r1 != '_' {
|
||||
buf.WriteRune(r1)
|
||||
}
|
||||
}
|
||||
|
@ -65,7 +72,7 @@ func ToCamelCase(str string) string {
|
|||
}
|
||||
|
||||
// ToSnakeCase can convert all upper case characters in a string to
|
||||
// underscore format.
|
||||
// snake case format.
|
||||
//
|
||||
// Some samples.
|
||||
// "FirstName" => "first_name"
|
||||
|
@ -74,7 +81,31 @@ func ToCamelCase(str string) string {
|
|||
// "GO_PATH" => "go_path"
|
||||
// "GO PATH" => "go_path" // space is converted to underscore.
|
||||
// "GO-PATH" => "go_path" // hyphen is converted to underscore.
|
||||
// "HTTP2XX" => "http_2xx" // insert an underscore before a number and after an alphabet.
|
||||
// "http2xx" => "http_2xx"
|
||||
// "HTTP20xOK" => "http_20x_ok"
|
||||
func ToSnakeCase(str string) string {
|
||||
return camelCaseToLowerCase(str, '_')
|
||||
}
|
||||
|
||||
// ToKebabCase can convert all upper case characters in a string to
|
||||
// kebab case format.
|
||||
//
|
||||
// Some samples.
|
||||
// "FirstName" => "first-name"
|
||||
// "HTTPServer" => "http-server"
|
||||
// "NoHTTPS" => "no-https"
|
||||
// "GO_PATH" => "go-path"
|
||||
// "GO PATH" => "go-path" // space is converted to '-'.
|
||||
// "GO-PATH" => "go-path" // hyphen is converted to '-'.
|
||||
// "HTTP2XX" => "http-2xx" // insert a '-' before a number and after an alphabet.
|
||||
// "http2xx" => "http-2xx"
|
||||
// "HTTP20xOK" => "http-20x-ok"
|
||||
func ToKebabCase(str string) string {
|
||||
return camelCaseToLowerCase(str, '-')
|
||||
}
|
||||
|
||||
func camelCaseToLowerCase(str string, connector rune) string {
|
||||
if len(str) == 0 {
|
||||
return ""
|
||||
}
|
||||
|
@ -83,7 +114,7 @@ func ToSnakeCase(str string) string {
|
|||
var prev, r0, r1 rune
|
||||
var size int
|
||||
|
||||
r0 = '_'
|
||||
r0 = connector
|
||||
|
||||
for len(str) > 0 {
|
||||
prev = r0
|
||||
|
@ -92,11 +123,11 @@ func ToSnakeCase(str string) string {
|
|||
|
||||
switch {
|
||||
case r0 == utf8.RuneError:
|
||||
buf.WriteByte(byte(str[0]))
|
||||
buf.WriteRune(r0)
|
||||
|
||||
case unicode.IsUpper(r0):
|
||||
if prev != '_' {
|
||||
buf.WriteRune('_')
|
||||
if prev != connector && !unicode.IsNumber(prev) {
|
||||
buf.WriteRune(connector)
|
||||
}
|
||||
|
||||
buf.WriteRune(unicode.ToLower(r0))
|
||||
|
@ -113,7 +144,7 @@ func ToSnakeCase(str string) string {
|
|||
break
|
||||
}
|
||||
|
||||
// find next non-upper-case character and insert `_` properly.
|
||||
// find next non-upper-case character and insert connector properly.
|
||||
// it's designed to convert `HTTPServer` to `http_server`.
|
||||
// if there are more than 2 adjacent upper case characters in a word,
|
||||
// treat them as an abbreviation plus a normal word.
|
||||
|
@ -124,17 +155,23 @@ func ToSnakeCase(str string) string {
|
|||
|
||||
if r0 == utf8.RuneError {
|
||||
buf.WriteRune(unicode.ToLower(r1))
|
||||
buf.WriteByte(byte(str[0]))
|
||||
buf.WriteRune(r0)
|
||||
break
|
||||
}
|
||||
|
||||
if !unicode.IsUpper(r0) {
|
||||
if r0 == '_' || r0 == ' ' || r0 == '-' {
|
||||
r0 = '_'
|
||||
r0 = connector
|
||||
|
||||
buf.WriteRune(unicode.ToLower(r1))
|
||||
} else if unicode.IsNumber(r0) {
|
||||
// treat a number as an upper case rune
|
||||
// so that both `http2xx` and `HTTP2XX` can be converted to `http_2xx`.
|
||||
buf.WriteRune(unicode.ToLower(r1))
|
||||
buf.WriteRune(connector)
|
||||
buf.WriteRune(r0)
|
||||
} else {
|
||||
buf.WriteRune('_')
|
||||
buf.WriteRune(connector)
|
||||
buf.WriteRune(unicode.ToLower(r1))
|
||||
buf.WriteRune(r0)
|
||||
}
|
||||
|
@ -145,14 +182,20 @@ func ToSnakeCase(str string) string {
|
|||
buf.WriteRune(unicode.ToLower(r1))
|
||||
}
|
||||
|
||||
if len(str) == 0 || r0 == '_' {
|
||||
if len(str) == 0 || r0 == connector {
|
||||
buf.WriteRune(unicode.ToLower(r0))
|
||||
break
|
||||
}
|
||||
|
||||
case unicode.IsNumber(r0):
|
||||
if prev != connector && !unicode.IsNumber(prev) {
|
||||
buf.WriteRune(connector)
|
||||
}
|
||||
|
||||
buf.WriteRune(r0)
|
||||
|
||||
default:
|
||||
if r0 == ' ' || r0 == '-' {
|
||||
r0 = '_'
|
||||
if r0 == ' ' || r0 == '-' || r0 == '_' {
|
||||
r0 = connector
|
||||
}
|
||||
|
||||
buf.WriteRune(r0)
|
||||
|
|
4
vendor/github.com/huandu/xstrings/count.go
generated
vendored
4
vendor/github.com/huandu/xstrings/count.go
generated
vendored
|
@ -8,12 +8,12 @@ import (
|
|||
"unicode/utf8"
|
||||
)
|
||||
|
||||
// Get str's utf8 rune length.
|
||||
// Len returns str's utf8 rune length.
|
||||
func Len(str string) int {
|
||||
return utf8.RuneCountInString(str)
|
||||
}
|
||||
|
||||
// Count number of words in a string.
|
||||
// WordCount returns number of words in a string.
|
||||
//
|
||||
// Word is defined as a locale dependent string containing alphabetic characters,
|
||||
// which may also contain but not start with `'` and `-` characters.
|
||||
|
|
4
vendor/github.com/huandu/xstrings/doc.go
generated
vendored
4
vendor/github.com/huandu/xstrings/doc.go
generated
vendored
|
@ -1,8 +1,8 @@
|
|||
// Copyright 2015 Huan Du. All rights reserved.
|
||||
// Licensed under the MIT license that can be found in the LICENSE file.
|
||||
|
||||
// Package `xstrings` is to provide string algorithms which are useful but not included in `strings` package.
|
||||
// Package xstrings is to provide string algorithms which are useful but not included in `strings` package.
|
||||
// See project home page for details. https://github.com/huandu/xstrings
|
||||
//
|
||||
// Package `xstrings` assumes all strings are encoded in utf8.
|
||||
// Package xstrings assumes all strings are encoded in utf8.
|
||||
package xstrings
|
||||
|
|
4
vendor/github.com/huandu/xstrings/manipulate.go
generated
vendored
4
vendor/github.com/huandu/xstrings/manipulate.go
generated
vendored
|
@ -128,7 +128,7 @@ func Insert(dst, src string, index int) string {
|
|||
return Slice(dst, 0, index) + src + Slice(dst, index, -1)
|
||||
}
|
||||
|
||||
// Scrubs invalid utf8 bytes with repl string.
|
||||
// Scrub scrubs invalid utf8 bytes with repl string.
|
||||
// Adjacent invalid bytes are replaced only once.
|
||||
func Scrub(str, repl string) string {
|
||||
var buf *bytes.Buffer
|
||||
|
@ -171,7 +171,7 @@ func Scrub(str, repl string) string {
|
|||
return origin
|
||||
}
|
||||
|
||||
// Splits a string into words. Returns a slice of words.
|
||||
// WordSplit splits a string into words. Returns a slice of words.
|
||||
// If there is no word in a string, return nil.
|
||||
//
|
||||
// Word is defined as a locale dependent string containing alphabetic characters,
|
||||
|
|
6
vendor/github.com/huandu/xstrings/translate.go
generated
vendored
6
vendor/github.com/huandu/xstrings/translate.go
generated
vendored
|
@ -492,8 +492,9 @@ func Count(str, pattern string) int {
|
|||
// If pattern is not empty, only runes matching the pattern will be squeezed.
|
||||
//
|
||||
// Samples:
|
||||
// Squeeze("hello", "") => "helo"
|
||||
// Squeeze("hello", "m-z") => "hello"
|
||||
// Squeeze("hello", "") => "helo"
|
||||
// Squeeze("hello", "m-z") => "hello"
|
||||
// Squeeze("hello world", " ") => "hello world"
|
||||
func Squeeze(str, pattern string) string {
|
||||
var last, r rune
|
||||
var size int
|
||||
|
@ -532,6 +533,7 @@ func Squeeze(str, pattern string) string {
|
|||
}
|
||||
|
||||
last = r
|
||||
skipSqueeze = false
|
||||
}
|
||||
|
||||
str = str[size:]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue