diff options
Diffstat (limited to 'vendor/github.com/uptrace/bun/internal')
-rw-r--r-- | vendor/github.com/uptrace/bun/internal/flag.go | 16 | ||||
-rw-r--r-- | vendor/github.com/uptrace/bun/internal/hex.go | 43 | ||||
-rw-r--r-- | vendor/github.com/uptrace/bun/internal/logger.go | 27 | ||||
-rw-r--r-- | vendor/github.com/uptrace/bun/internal/map_key.go | 67 | ||||
-rw-r--r-- | vendor/github.com/uptrace/bun/internal/parser/parser.go | 141 | ||||
-rw-r--r-- | vendor/github.com/uptrace/bun/internal/safe.go | 11 | ||||
-rw-r--r-- | vendor/github.com/uptrace/bun/internal/tagparser/parser.go | 184 | ||||
-rw-r--r-- | vendor/github.com/uptrace/bun/internal/time.go | 61 | ||||
-rw-r--r-- | vendor/github.com/uptrace/bun/internal/underscore.go | 67 | ||||
-rw-r--r-- | vendor/github.com/uptrace/bun/internal/unsafe.go | 20 | ||||
-rw-r--r-- | vendor/github.com/uptrace/bun/internal/util.go | 57 |
11 files changed, 0 insertions, 694 deletions
diff --git a/vendor/github.com/uptrace/bun/internal/flag.go b/vendor/github.com/uptrace/bun/internal/flag.go deleted file mode 100644 index 22d2db291..000000000 --- a/vendor/github.com/uptrace/bun/internal/flag.go +++ /dev/null @@ -1,16 +0,0 @@ -package internal - -type Flag uint64 - -func (flag Flag) Has(other Flag) bool { - return flag&other != 0 -} - -func (flag Flag) Set(other Flag) Flag { - return flag | other -} - -func (flag Flag) Remove(other Flag) Flag { - flag &= ^other - return flag -} diff --git a/vendor/github.com/uptrace/bun/internal/hex.go b/vendor/github.com/uptrace/bun/internal/hex.go deleted file mode 100644 index 6fae2bb78..000000000 --- a/vendor/github.com/uptrace/bun/internal/hex.go +++ /dev/null @@ -1,43 +0,0 @@ -package internal - -import ( - fasthex "github.com/tmthrgd/go-hex" -) - -type HexEncoder struct { - b []byte - written bool -} - -func NewHexEncoder(b []byte) *HexEncoder { - return &HexEncoder{ - b: b, - } -} - -func (enc *HexEncoder) Bytes() []byte { - return enc.b -} - -func (enc *HexEncoder) Write(b []byte) (int, error) { - if !enc.written { - enc.b = append(enc.b, '\'') - enc.b = append(enc.b, `\x`...) - enc.written = true - } - - i := len(enc.b) - enc.b = append(enc.b, make([]byte, fasthex.EncodedLen(len(b)))...) - fasthex.Encode(enc.b[i:], b) - - return len(b), nil -} - -func (enc *HexEncoder) Close() error { - if enc.written { - enc.b = append(enc.b, '\'') - } else { - enc.b = append(enc.b, "NULL"...) - } - return nil -} diff --git a/vendor/github.com/uptrace/bun/internal/logger.go b/vendor/github.com/uptrace/bun/internal/logger.go deleted file mode 100644 index 2e22a0893..000000000 --- a/vendor/github.com/uptrace/bun/internal/logger.go +++ /dev/null @@ -1,27 +0,0 @@ -package internal - -import ( - "fmt" - "log" - "os" -) - -var Warn = log.New(os.Stderr, "WARN: bun: ", log.LstdFlags) - -var Deprecated = log.New(os.Stderr, "DEPRECATED: bun: ", log.LstdFlags) - -type Logging interface { - Printf(format string, v ...interface{}) -} - -type logger struct { - log *log.Logger -} - -func (l *logger) Printf(format string, v ...interface{}) { - _ = l.log.Output(2, fmt.Sprintf(format, v...)) -} - -var Logger Logging = &logger{ - log: log.New(os.Stderr, "bun: ", log.LstdFlags|log.Lshortfile), -} diff --git a/vendor/github.com/uptrace/bun/internal/map_key.go b/vendor/github.com/uptrace/bun/internal/map_key.go deleted file mode 100644 index bb5fcca8c..000000000 --- a/vendor/github.com/uptrace/bun/internal/map_key.go +++ /dev/null @@ -1,67 +0,0 @@ -package internal - -import "reflect" - -var ifaceType = reflect.TypeOf((*interface{})(nil)).Elem() - -type MapKey struct { - iface interface{} -} - -func NewMapKey(is []interface{}) MapKey { - return MapKey{ - iface: newMapKey(is), - } -} - -func newMapKey(is []interface{}) interface{} { - switch len(is) { - case 1: - ptr := new([1]interface{}) - copy((*ptr)[:], is) - return *ptr - case 2: - ptr := new([2]interface{}) - copy((*ptr)[:], is) - return *ptr - case 3: - ptr := new([3]interface{}) - copy((*ptr)[:], is) - return *ptr - case 4: - ptr := new([4]interface{}) - copy((*ptr)[:], is) - return *ptr - case 5: - ptr := new([5]interface{}) - copy((*ptr)[:], is) - return *ptr - case 6: - ptr := new([6]interface{}) - copy((*ptr)[:], is) - return *ptr - case 7: - ptr := new([7]interface{}) - copy((*ptr)[:], is) - return *ptr - case 8: - ptr := new([8]interface{}) - copy((*ptr)[:], is) - return *ptr - case 9: - ptr := new([9]interface{}) - copy((*ptr)[:], is) - return *ptr - case 10: - ptr := new([10]interface{}) - copy((*ptr)[:], is) - return *ptr - default: - } - - at := reflect.New(reflect.ArrayOf(len(is), ifaceType)).Elem() - for i, v := range is { - *(at.Index(i).Addr().Interface().(*interface{})) = v - } - return at.Interface() -} diff --git a/vendor/github.com/uptrace/bun/internal/parser/parser.go b/vendor/github.com/uptrace/bun/internal/parser/parser.go deleted file mode 100644 index cdfc0be16..000000000 --- a/vendor/github.com/uptrace/bun/internal/parser/parser.go +++ /dev/null @@ -1,141 +0,0 @@ -package parser - -import ( - "bytes" - "strconv" - - "github.com/uptrace/bun/internal" -) - -type Parser struct { - b []byte - i int -} - -func New(b []byte) *Parser { - return &Parser{ - b: b, - } -} - -func NewString(s string) *Parser { - return New(internal.Bytes(s)) -} - -func (p *Parser) Valid() bool { - return p.i < len(p.b) -} - -func (p *Parser) Bytes() []byte { - return p.b[p.i:] -} - -func (p *Parser) Read() byte { - if p.Valid() { - c := p.b[p.i] - p.Advance() - return c - } - return 0 -} - -func (p *Parser) Peek() byte { - if p.Valid() { - return p.b[p.i] - } - return 0 -} - -func (p *Parser) Advance() { - p.i++ -} - -func (p *Parser) Skip(skip byte) bool { - if p.Peek() == skip { - p.Advance() - return true - } - return false -} - -func (p *Parser) SkipBytes(skip []byte) bool { - if len(skip) > len(p.b[p.i:]) { - return false - } - if !bytes.Equal(p.b[p.i:p.i+len(skip)], skip) { - return false - } - p.i += len(skip) - return true -} - -func (p *Parser) ReadSep(sep byte) ([]byte, bool) { - ind := bytes.IndexByte(p.b[p.i:], sep) - if ind == -1 { - b := p.b[p.i:] - p.i = len(p.b) - return b, false - } - - b := p.b[p.i : p.i+ind] - p.i += ind + 1 - return b, true -} - -func (p *Parser) ReadIdentifier() (string, bool) { - if p.i < len(p.b) && p.b[p.i] == '(' { - s := p.i + 1 - if ind := bytes.IndexByte(p.b[s:], ')'); ind != -1 { - b := p.b[s : s+ind] - p.i = s + ind + 1 - return internal.String(b), false - } - } - - ind := len(p.b) - p.i - var alpha bool - for i, c := range p.b[p.i:] { - if isNum(c) { - continue - } - if isAlpha(c) || (i > 0 && alpha && c == '_') { - alpha = true - continue - } - ind = i - break - } - if ind == 0 { - return "", false - } - b := p.b[p.i : p.i+ind] - p.i += ind - return internal.String(b), !alpha -} - -func (p *Parser) ReadNumber() int { - ind := len(p.b) - p.i - for i, c := range p.b[p.i:] { - if !isNum(c) { - ind = i - break - } - } - if ind == 0 { - return 0 - } - n, err := strconv.Atoi(string(p.b[p.i : p.i+ind])) - if err != nil { - panic(err) - } - p.i += ind - return n -} - -func isNum(c byte) bool { - return c >= '0' && c <= '9' -} - -func isAlpha(c byte) bool { - return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') -} diff --git a/vendor/github.com/uptrace/bun/internal/safe.go b/vendor/github.com/uptrace/bun/internal/safe.go deleted file mode 100644 index 862ff0eb3..000000000 --- a/vendor/github.com/uptrace/bun/internal/safe.go +++ /dev/null @@ -1,11 +0,0 @@ -// +build appengine - -package internal - -func String(b []byte) string { - return string(b) -} - -func Bytes(s string) []byte { - return []byte(s) -} diff --git a/vendor/github.com/uptrace/bun/internal/tagparser/parser.go b/vendor/github.com/uptrace/bun/internal/tagparser/parser.go deleted file mode 100644 index a3905853d..000000000 --- a/vendor/github.com/uptrace/bun/internal/tagparser/parser.go +++ /dev/null @@ -1,184 +0,0 @@ -package tagparser - -import ( - "strings" -) - -type Tag struct { - Name string - Options map[string][]string -} - -func (t Tag) IsZero() bool { - return t.Name == "" && t.Options == nil -} - -func (t Tag) HasOption(name string) bool { - _, ok := t.Options[name] - return ok -} - -func (t Tag) Option(name string) (string, bool) { - if vs, ok := t.Options[name]; ok { - return vs[len(vs)-1], true - } - return "", false -} - -func Parse(s string) Tag { - if s == "" { - return Tag{} - } - p := parser{ - s: s, - } - p.parse() - return p.tag -} - -type parser struct { - s string - i int - - tag Tag - seenName bool // for empty names -} - -func (p *parser) setName(name string) { - if p.seenName { - p.addOption(name, "") - } else { - p.seenName = true - p.tag.Name = name - } -} - -func (p *parser) addOption(key, value string) { - p.seenName = true - if key == "" { - return - } - if p.tag.Options == nil { - p.tag.Options = make(map[string][]string) - } - if vs, ok := p.tag.Options[key]; ok { - p.tag.Options[key] = append(vs, value) - } else { - p.tag.Options[key] = []string{value} - } -} - -func (p *parser) parse() { - for p.valid() { - p.parseKeyValue() - if p.peek() == ',' { - p.i++ - } - } -} - -func (p *parser) parseKeyValue() { - start := p.i - - for p.valid() { - switch c := p.read(); c { - case ',': - key := p.s[start : p.i-1] - p.setName(key) - return - case ':': - key := p.s[start : p.i-1] - value := p.parseValue() - p.addOption(key, value) - return - case '"': - key := p.parseQuotedValue() - p.setName(key) - return - } - } - - key := p.s[start:p.i] - p.setName(key) -} - -func (p *parser) parseValue() string { - start := p.i - - for p.valid() { - switch c := p.read(); c { - case '"': - return p.parseQuotedValue() - case ',': - return p.s[start : p.i-1] - case '(': - p.skipPairs('(', ')') - } - } - - if p.i == start { - return "" - } - return p.s[start:p.i] -} - -func (p *parser) parseQuotedValue() string { - if i := strings.IndexByte(p.s[p.i:], '"'); i >= 0 && p.s[p.i+i-1] != '\\' { - s := p.s[p.i : p.i+i] - p.i += i + 1 - return s - } - - b := make([]byte, 0, 16) - - for p.valid() { - switch c := p.read(); c { - case '\\': - b = append(b, p.read()) - case '"': - return string(b) - default: - b = append(b, c) - } - } - - return "" -} - -func (p *parser) skipPairs(start, end byte) { - var lvl int - for p.valid() { - switch c := p.read(); c { - case '"': - _ = p.parseQuotedValue() - case start: - lvl++ - case end: - if lvl == 0 { - return - } - lvl-- - } - } -} - -func (p *parser) valid() bool { - return p.i < len(p.s) -} - -func (p *parser) read() byte { - if !p.valid() { - return 0 - } - c := p.s[p.i] - p.i++ - return c -} - -func (p *parser) peek() byte { - if !p.valid() { - return 0 - } - c := p.s[p.i] - return c -} diff --git a/vendor/github.com/uptrace/bun/internal/time.go b/vendor/github.com/uptrace/bun/internal/time.go deleted file mode 100644 index 2cb69b46a..000000000 --- a/vendor/github.com/uptrace/bun/internal/time.go +++ /dev/null @@ -1,61 +0,0 @@ -package internal - -import ( - "fmt" - "time" -) - -const ( - dateFormat = "2006-01-02" - timeFormat = "15:04:05.999999999" - timetzFormat1 = "15:04:05.999999999-07:00:00" - timetzFormat2 = "15:04:05.999999999-07:00" - timetzFormat3 = "15:04:05.999999999-07" - timestampFormat = "2006-01-02 15:04:05.999999999" - timestamptzFormat1 = "2006-01-02 15:04:05.999999999-07:00:00" - timestamptzFormat2 = "2006-01-02 15:04:05.999999999-07:00" - timestamptzFormat3 = "2006-01-02 15:04:05.999999999-07" -) - -func ParseTime(s string) (time.Time, error) { - l := len(s) - - if l >= len("2006-01-02 15:04:05") { - switch s[10] { - case ' ': - if c := s[l-6]; c == '+' || c == '-' { - return time.Parse(timestamptzFormat2, s) - } - if c := s[l-3]; c == '+' || c == '-' { - return time.Parse(timestamptzFormat3, s) - } - if c := s[l-9]; c == '+' || c == '-' { - return time.Parse(timestamptzFormat1, s) - } - return time.ParseInLocation(timestampFormat, s, time.UTC) - case 'T': - return time.Parse(time.RFC3339Nano, s) - } - } - - if l >= len("15:04:05-07") { - if c := s[l-6]; c == '+' || c == '-' { - return time.Parse(timetzFormat2, s) - } - if c := s[l-3]; c == '+' || c == '-' { - return time.Parse(timetzFormat3, s) - } - if c := s[l-9]; c == '+' || c == '-' { - return time.Parse(timetzFormat1, s) - } - } - - if l < len("15:04:05") { - return time.Time{}, fmt.Errorf("bun: can't parse time=%q", s) - } - - if s[2] == ':' { - return time.ParseInLocation(timeFormat, s, time.UTC) - } - return time.ParseInLocation(dateFormat, s, time.UTC) -} diff --git a/vendor/github.com/uptrace/bun/internal/underscore.go b/vendor/github.com/uptrace/bun/internal/underscore.go deleted file mode 100644 index 9de52fb7b..000000000 --- a/vendor/github.com/uptrace/bun/internal/underscore.go +++ /dev/null @@ -1,67 +0,0 @@ -package internal - -func IsUpper(c byte) bool { - return c >= 'A' && c <= 'Z' -} - -func IsLower(c byte) bool { - return c >= 'a' && c <= 'z' -} - -func ToUpper(c byte) byte { - return c - 32 -} - -func ToLower(c byte) byte { - return c + 32 -} - -// Underscore converts "CamelCasedString" to "camel_cased_string". -func Underscore(s string) string { - r := make([]byte, 0, len(s)+5) - for i := 0; i < len(s); i++ { - c := s[i] - if IsUpper(c) { - if i > 0 && i+1 < len(s) && (IsLower(s[i-1]) || IsLower(s[i+1])) { - r = append(r, '_', ToLower(c)) - } else { - r = append(r, ToLower(c)) - } - } else { - r = append(r, c) - } - } - return string(r) -} - -func CamelCased(s string) string { - r := make([]byte, 0, len(s)) - upperNext := true - for i := 0; i < len(s); i++ { - c := s[i] - if c == '_' { - upperNext = true - continue - } - if upperNext { - if IsLower(c) { - c = ToUpper(c) - } - upperNext = false - } - r = append(r, c) - } - return string(r) -} - -func ToExported(s string) string { - if len(s) == 0 { - return s - } - if c := s[0]; IsLower(c) { - b := []byte(s) - b[0] = ToUpper(c) - return string(b) - } - return s -} diff --git a/vendor/github.com/uptrace/bun/internal/unsafe.go b/vendor/github.com/uptrace/bun/internal/unsafe.go deleted file mode 100644 index 4bc79701f..000000000 --- a/vendor/github.com/uptrace/bun/internal/unsafe.go +++ /dev/null @@ -1,20 +0,0 @@ -// +build !appengine - -package internal - -import "unsafe" - -// String converts byte slice to string. -func String(b []byte) string { - return *(*string)(unsafe.Pointer(&b)) -} - -// Bytes converts string to byte slice. -func Bytes(s string) []byte { - return *(*[]byte)(unsafe.Pointer( - &struct { - string - Cap int - }{s, len(s)}, - )) -} diff --git a/vendor/github.com/uptrace/bun/internal/util.go b/vendor/github.com/uptrace/bun/internal/util.go deleted file mode 100644 index c831dc659..000000000 --- a/vendor/github.com/uptrace/bun/internal/util.go +++ /dev/null @@ -1,57 +0,0 @@ -package internal - -import ( - "reflect" -) - -func MakeSliceNextElemFunc(v reflect.Value) func() reflect.Value { - if v.Kind() == reflect.Array { - var pos int - return func() reflect.Value { - v := v.Index(pos) - pos++ - return v - } - } - - elemType := v.Type().Elem() - - if elemType.Kind() == reflect.Ptr { - elemType = elemType.Elem() - return func() reflect.Value { - if v.Len() < v.Cap() { - v.Set(v.Slice(0, v.Len()+1)) - elem := v.Index(v.Len() - 1) - if elem.IsNil() { - elem.Set(reflect.New(elemType)) - } - return elem.Elem() - } - - elem := reflect.New(elemType) - v.Set(reflect.Append(v, elem)) - return elem.Elem() - } - } - - zero := reflect.Zero(elemType) - return func() reflect.Value { - if v.Len() < v.Cap() { - v.Set(v.Slice(0, v.Len()+1)) - return v.Index(v.Len() - 1) - } - - v.Set(reflect.Append(v, zero)) - return v.Index(v.Len() - 1) - } -} - -func Unwrap(err error) error { - u, ok := err.(interface { - Unwrap() error - }) - if !ok { - return nil - } - return u.Unwrap() -} |