aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/github.com/fatih
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2021-02-22 20:37:25 +0100
committerDmitry Vyukov <dvyukov@google.com>2021-02-22 21:02:12 +0100
commitfcc6d71be2c3ce7d9305c04fc2e87af554571bac (patch)
treeb01dbb3d1e2988e28ea158d2d543d603ec0b9569 /vendor/github.com/fatih
parent8f23c528ad5a943b9ffec5dcaf332fd0f614006e (diff)
go.mod: update golangci-lint to v1.37
Diffstat (limited to 'vendor/github.com/fatih')
-rw-r--r--vendor/github.com/fatih/color/README.md13
-rw-r--r--vendor/github.com/fatih/color/go.mod4
-rw-r--r--vendor/github.com/fatih/color/go.sum15
-rw-r--r--vendor/github.com/fatih/structtag/LICENSE60
-rw-r--r--vendor/github.com/fatih/structtag/README.md73
-rw-r--r--vendor/github.com/fatih/structtag/go.mod3
-rw-r--r--vendor/github.com/fatih/structtag/tags.go315
7 files changed, 462 insertions, 21 deletions
diff --git a/vendor/github.com/fatih/color/README.md b/vendor/github.com/fatih/color/README.md
index 42d9abc07..d62e4024a 100644
--- a/vendor/github.com/fatih/color/README.md
+++ b/vendor/github.com/fatih/color/README.md
@@ -1,20 +1,11 @@
-# Archived project. No maintenance.
-
-This project is not maintained anymore and is archived. Feel free to fork and
-make your own changes if needed. For more detail read my blog post: [Taking an indefinite sabbatical from my projects](https://arslan.io/2018/10/09/taking-an-indefinite-sabbatical-from-my-projects/)
-
-Thanks to everyone for their valuable feedback and contributions.
-
-
-# Color [![GoDoc](https://godoc.org/github.com/fatih/color?status.svg)](https://godoc.org/github.com/fatih/color)
+# color [![](https://github.com/fatih/color/workflows/build/badge.svg)](https://github.com/fatih/color/actions) [![PkgGoDev](https://pkg.go.dev/badge/github.com/fatih/color)](https://pkg.go.dev/github.com/fatih/color)
Color lets you use colorized outputs in terms of [ANSI Escape
Codes](http://en.wikipedia.org/wiki/ANSI_escape_code#Colors) in Go (Golang). It
has support for Windows too! The API can be used in several ways, pick one that
suits you.
-
-![Color](https://i.imgur.com/c1JI0lA.png)
+![Color](https://user-images.githubusercontent.com/438920/96832689-03b3e000-13f4-11eb-9803-46f4c4de3406.jpg)
## Install
diff --git a/vendor/github.com/fatih/color/go.mod b/vendor/github.com/fatih/color/go.mod
index bc0df7545..78872815e 100644
--- a/vendor/github.com/fatih/color/go.mod
+++ b/vendor/github.com/fatih/color/go.mod
@@ -3,6 +3,6 @@ module github.com/fatih/color
go 1.13
require (
- github.com/mattn/go-colorable v0.1.4
- github.com/mattn/go-isatty v0.0.11
+ github.com/mattn/go-colorable v0.1.8
+ github.com/mattn/go-isatty v0.0.12
)
diff --git a/vendor/github.com/fatih/color/go.sum b/vendor/github.com/fatih/color/go.sum
index 44328a8db..54f7c46e8 100644
--- a/vendor/github.com/fatih/color/go.sum
+++ b/vendor/github.com/fatih/color/go.sum
@@ -1,8 +1,7 @@
-github.com/mattn/go-colorable v0.1.4 h1:snbPLB8fVfU9iwbbo30TPtbLRzwWu6aJS6Xh4eaaviA=
-github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=
-github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
-github.com/mattn/go-isatty v0.0.11 h1:FxPOTFNqGkuDUGi3H/qkUbQO4ZiBa2brKq5r0l8TGeM=
-github.com/mattn/go-isatty v0.0.11/go.mod h1:PhnuNfih5lzO57/f3n+odYbM4JtupLOxQOAqxQCu2WE=
-golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
-golang.org/x/sys v0.0.0-20191026070338-33540a1f6037 h1:YyJpGZS1sBuBCzLAR1VEpK193GlqGZbnPFnPV/5Rsb4=
-golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+github.com/mattn/go-colorable v0.1.8 h1:c1ghPdyEDarC70ftn0y+A/Ee++9zz8ljHG1b13eJ0s8=
+github.com/mattn/go-colorable v0.1.8/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
+github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY=
+github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
+golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae h1:/WDfKMnPU+m5M4xB+6x4kaepxRw6jWvR5iDRdvjHgy8=
+golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
diff --git a/vendor/github.com/fatih/structtag/LICENSE b/vendor/github.com/fatih/structtag/LICENSE
new file mode 100644
index 000000000..4fd15f9f8
--- /dev/null
+++ b/vendor/github.com/fatih/structtag/LICENSE
@@ -0,0 +1,60 @@
+Copyright (c) 2017, Fatih Arslan
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+* Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+
+* Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+* Neither the name of structtag nor the names of its
+ contributors may be used to endorse or promote products derived from
+ this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+This software includes some portions from Go. Go is used under the terms of the
+BSD like license.
+
+Copyright (c) 2012 The Go Authors. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+
+ * Redistributions of source code must retain the above copyright
+notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above
+copyright notice, this list of conditions and the following disclaimer
+in the documentation and/or other materials provided with the
+distribution.
+ * Neither the name of Google Inc. nor the names of its
+contributors may be used to endorse or promote products derived from
+this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+The Go gopher was designed by Renee French. http://reneefrench.blogspot.com/ The design is licensed under the Creative Commons 3.0 Attributions license. Read this article for more details: https://blog.golang.org/gopher
diff --git a/vendor/github.com/fatih/structtag/README.md b/vendor/github.com/fatih/structtag/README.md
new file mode 100644
index 000000000..c4e8b1e86
--- /dev/null
+++ b/vendor/github.com/fatih/structtag/README.md
@@ -0,0 +1,73 @@
+# structtag [![GoDoc](http://img.shields.io/badge/go-documentation-blue.svg?style=flat-square)](http://godoc.org/github.com/fatih/structtag)
+
+structtag provides an easy way of parsing and manipulating struct tag fields.
+Please vendor the library as it might change in future versions.
+
+# Install
+
+```bash
+go get github.com/fatih/structtag
+```
+
+# Example
+
+```go
+package main
+
+import (
+ "fmt"
+ "reflect"
+ "sort"
+
+ "github.com/fatih/structtag"
+)
+
+func main() {
+ type t struct {
+ t string `json:"foo,omitempty,string" xml:"foo"`
+ }
+
+ // get field tag
+ tag := reflect.TypeOf(t{}).Field(0).Tag
+
+ // ... and start using structtag by parsing the tag
+ tags, err := structtag.Parse(string(tag))
+ if err != nil {
+ panic(err)
+ }
+
+ // iterate over all tags
+ for _, t := range tags.Tags() {
+ fmt.Printf("tag: %+v\n", t)
+ }
+
+ // get a single tag
+ jsonTag, err := tags.Get("json")
+ if err != nil {
+ panic(err)
+ }
+ fmt.Println(jsonTag) // Output: json:"foo,omitempty,string"
+ fmt.Println(jsonTag.Key) // Output: json
+ fmt.Println(jsonTag.Name) // Output: foo
+ fmt.Println(jsonTag.Options) // Output: [omitempty string]
+
+ // change existing tag
+ jsonTag.Name = "foo_bar"
+ jsonTag.Options = nil
+ tags.Set(jsonTag)
+
+ // add new tag
+ tags.Set(&structtag.Tag{
+ Key: "hcl",
+ Name: "foo",
+ Options: []string{"squash"},
+ })
+
+ // print the tags
+ fmt.Println(tags) // Output: json:"foo_bar" xml:"foo" hcl:"foo,squash"
+
+ // sort tags according to keys
+ sort.Sort(tags)
+ fmt.Println(tags) // Output: hcl:"foo,squash" json:"foo_bar" xml:"foo"
+}
+```
diff --git a/vendor/github.com/fatih/structtag/go.mod b/vendor/github.com/fatih/structtag/go.mod
new file mode 100644
index 000000000..660d6a1f1
--- /dev/null
+++ b/vendor/github.com/fatih/structtag/go.mod
@@ -0,0 +1,3 @@
+module github.com/fatih/structtag
+
+go 1.12
diff --git a/vendor/github.com/fatih/structtag/tags.go b/vendor/github.com/fatih/structtag/tags.go
new file mode 100644
index 000000000..c168fb21c
--- /dev/null
+++ b/vendor/github.com/fatih/structtag/tags.go
@@ -0,0 +1,315 @@
+package structtag
+
+import (
+ "bytes"
+ "errors"
+ "fmt"
+ "strconv"
+ "strings"
+)
+
+var (
+ errTagSyntax = errors.New("bad syntax for struct tag pair")
+ errTagKeySyntax = errors.New("bad syntax for struct tag key")
+ errTagValueSyntax = errors.New("bad syntax for struct tag value")
+
+ errKeyNotSet = errors.New("tag key does not exist")
+ errTagNotExist = errors.New("tag does not exist")
+ errTagKeyMismatch = errors.New("mismatch between key and tag.key")
+)
+
+// Tags represent a set of tags from a single struct field
+type Tags struct {
+ tags []*Tag
+}
+
+// Tag defines a single struct's string literal tag
+type Tag struct {
+ // Key is the tag key, such as json, xml, etc..
+ // i.e: `json:"foo,omitempty". Here key is: "json"
+ Key string
+
+ // Name is a part of the value
+ // i.e: `json:"foo,omitempty". Here name is: "foo"
+ Name string
+
+ // Options is a part of the value. It contains a slice of tag options i.e:
+ // `json:"foo,omitempty". Here options is: ["omitempty"]
+ Options []string
+}
+
+// Parse parses a single struct field tag and returns the set of tags.
+func Parse(tag string) (*Tags, error) {
+ var tags []*Tag
+
+ hasTag := tag != ""
+
+ // NOTE(arslan) following code is from reflect and vet package with some
+ // modifications to collect all necessary information and extend it with
+ // usable methods
+ for tag != "" {
+ // Skip leading space.
+ i := 0
+ for i < len(tag) && tag[i] == ' ' {
+ i++
+ }
+ tag = tag[i:]
+ if tag == "" {
+ break
+ }
+
+ // Scan to colon. A space, a quote or a control character is a syntax
+ // error. Strictly speaking, control chars include the range [0x7f,
+ // 0x9f], not just [0x00, 0x1f], but in practice, we ignore the
+ // multi-byte control characters as it is simpler to inspect the tag's
+ // bytes than the tag's runes.
+ i = 0
+ for i < len(tag) && tag[i] > ' ' && tag[i] != ':' && tag[i] != '"' && tag[i] != 0x7f {
+ i++
+ }
+
+ if i == 0 {
+ return nil, errTagKeySyntax
+ }
+ if i+1 >= len(tag) || tag[i] != ':' {
+ return nil, errTagSyntax
+ }
+ if tag[i+1] != '"' {
+ return nil, errTagValueSyntax
+ }
+
+ key := string(tag[:i])
+ tag = tag[i+1:]
+
+ // Scan quoted string to find value.
+ i = 1
+ for i < len(tag) && tag[i] != '"' {
+ if tag[i] == '\\' {
+ i++
+ }
+ i++
+ }
+ if i >= len(tag) {
+ return nil, errTagValueSyntax
+ }
+
+ qvalue := string(tag[:i+1])
+ tag = tag[i+1:]
+
+ value, err := strconv.Unquote(qvalue)
+ if err != nil {
+ return nil, errTagValueSyntax
+ }
+
+ res := strings.Split(value, ",")
+ name := res[0]
+ options := res[1:]
+ if len(options) == 0 {
+ options = nil
+ }
+
+ tags = append(tags, &Tag{
+ Key: key,
+ Name: name,
+ Options: options,
+ })
+ }
+
+ if hasTag && len(tags) == 0 {
+ return nil, nil
+ }
+
+ return &Tags{
+ tags: tags,
+ }, nil
+}
+
+// Get returns the tag associated with the given key. If the key is present
+// in the tag the value (which may be empty) is returned. Otherwise the
+// returned value will be the empty string. The ok return value reports whether
+// the tag exists or not (which the return value is nil).
+func (t *Tags) Get(key string) (*Tag, error) {
+ for _, tag := range t.tags {
+ if tag.Key == key {
+ return tag, nil
+ }
+ }
+
+ return nil, errTagNotExist
+}
+
+// Set sets the given tag. If the tag key already exists it'll override it
+func (t *Tags) Set(tag *Tag) error {
+ if tag.Key == "" {
+ return errKeyNotSet
+ }
+
+ added := false
+ for i, tg := range t.tags {
+ if tg.Key == tag.Key {
+ added = true
+ t.tags[i] = tag
+ }
+ }
+
+ if !added {
+ // this means this is a new tag, add it
+ t.tags = append(t.tags, tag)
+ }
+
+ return nil
+}
+
+// AddOptions adds the given option for the given key. If the option already
+// exists it doesn't add it again.
+func (t *Tags) AddOptions(key string, options ...string) {
+ for i, tag := range t.tags {
+ if tag.Key != key {
+ continue
+ }
+
+ for _, opt := range options {
+ if !tag.HasOption(opt) {
+ tag.Options = append(tag.Options, opt)
+ }
+ }
+
+ t.tags[i] = tag
+ }
+}
+
+// DeleteOptions deletes the given options for the given key
+func (t *Tags) DeleteOptions(key string, options ...string) {
+ hasOption := func(option string) bool {
+ for _, opt := range options {
+ if opt == option {
+ return true
+ }
+ }
+ return false
+ }
+
+ for i, tag := range t.tags {
+ if tag.Key != key {
+ continue
+ }
+
+ var updated []string
+ for _, opt := range tag.Options {
+ if !hasOption(opt) {
+ updated = append(updated, opt)
+ }
+ }
+
+ tag.Options = updated
+ t.tags[i] = tag
+ }
+}
+
+// Delete deletes the tag for the given keys
+func (t *Tags) Delete(keys ...string) {
+ hasKey := func(key string) bool {
+ for _, k := range keys {
+ if k == key {
+ return true
+ }
+ }
+ return false
+ }
+
+ var updated []*Tag
+ for _, tag := range t.tags {
+ if !hasKey(tag.Key) {
+ updated = append(updated, tag)
+ }
+ }
+
+ t.tags = updated
+}
+
+// Tags returns a slice of tags. The order is the original tag order unless it
+// was changed.
+func (t *Tags) Tags() []*Tag {
+ return t.tags
+}
+
+// Tags returns a slice of tags. The order is the original tag order unless it
+// was changed.
+func (t *Tags) Keys() []string {
+ var keys []string
+ for _, tag := range t.tags {
+ keys = append(keys, tag.Key)
+ }
+ return keys
+}
+
+// String reassembles the tags into a valid literal tag field representation
+func (t *Tags) String() string {
+ tags := t.Tags()
+ if len(tags) == 0 {
+ return ""
+ }
+
+ var buf bytes.Buffer
+ for i, tag := range t.Tags() {
+ buf.WriteString(tag.String())
+ if i != len(tags)-1 {
+ buf.WriteString(" ")
+ }
+ }
+ return buf.String()
+}
+
+// HasOption returns true if the given option is available in options
+func (t *Tag) HasOption(opt string) bool {
+ for _, tagOpt := range t.Options {
+ if tagOpt == opt {
+ return true
+ }
+ }
+
+ return false
+}
+
+// Value returns the raw value of the tag, i.e. if the tag is
+// `json:"foo,omitempty", the Value is "foo,omitempty"
+func (t *Tag) Value() string {
+ options := strings.Join(t.Options, ",")
+ if options != "" {
+ return fmt.Sprintf(`%s,%s`, t.Name, options)
+ }
+ return t.Name
+}
+
+// String reassembles the tag into a valid tag field representation
+func (t *Tag) String() string {
+ return fmt.Sprintf(`%s:%q`, t.Key, t.Value())
+}
+
+// GoString implements the fmt.GoStringer interface
+func (t *Tag) GoString() string {
+ template := `{
+ Key: '%s',
+ Name: '%s',
+ Option: '%s',
+ }`
+
+ if t.Options == nil {
+ return fmt.Sprintf(template, t.Key, t.Name, "nil")
+ }
+
+ options := strings.Join(t.Options, ",")
+ return fmt.Sprintf(template, t.Key, t.Name, options)
+}
+
+func (t *Tags) Len() int {
+ return len(t.tags)
+}
+
+func (t *Tags) Less(i int, j int) bool {
+ return t.tags[i].Key < t.tags[j].Key
+}
+
+func (t *Tags) Swap(i int, j int) {
+ t.tags[i], t.tags[j] = t.tags[j], t.tags[i]
+}