]
- 2018.04.18: mv.Xml/mv.XmlIndent encodes non-map[string]interface{} map values - map[string]string, map[int]uint, etc.
- 2018.03.29: mv.Gob/NewMapGob support gob encoding/decoding of Maps.
- 2018.03.26: Added mxj/x2j-wrapper sub-package for migrating from legacy x2j package.
- 2017.02.22: LeafNode paths can use ".N" syntax rather than "[N]" for list member indexing.
- 2017.02.10: SetFieldSeparator changes field separator for args in UpdateValuesForPath, ValuesFor... methods.
- 2017.02.06: Support XMPP stream processing - HandleXMPPStreamTag().
- 2016.11.07: Preserve name space prefix syntax in XmlSeq parser - NewMapXmlSeq(), etc.
- 2016.06.25: Support overriding default XML attribute prefix, "-", in Map keys - SetAttrPrefix().
- 2016.05.26: Support customization of xml.Decoder by exposing CustomDecoder variable.
- 2016.03.19: Escape invalid chars when encoding XML attribute and element values - XMLEscapeChars().
- 2016.03.02: By default decoding XML with float64 and bool value casting will not cast "NaN", "Inf", and "-Inf".
- To cast them to float64, first set flag with CastNanInf(true).
- 2016.02.22: New mv.Root(), mv.Elements(), mv.Attributes methods let you examine XML document structure.
- 2016.02.16: Add CoerceKeysToLower() option to handle tags with mixed capitalization.
- 2016.02.12: Seek for first xml.StartElement token; only return error if io.EOF is reached first (handles BOM).
- 2015.12.02: XML decoding/encoding that preserves original structure of document. See NewMapXmlSeq()
- and mv.XmlSeq() / mv.XmlSeqIndent().
- 2015-05-20: New: mv.StringIndentNoTypeInfo().
- Also, alphabetically sort map[string]interface{} values by key to prettify output for mv.Xml(),
- mv.XmlIndent(), mv.StringIndent(), mv.StringIndentNoTypeInfo().
- 2014-11-09: IncludeTagSeqNum() adds "_seq" key with XML doc positional information.
- (NOTE: PreserveXmlList() is similar and will be here soon.)
- 2014-09-18: inspired by NYTimes fork, added PrependAttrWithHyphen() to allow stripping hyphen from attribute tag.
- 2014-08-02: AnyXml() and AnyXmlIndent() will try to marshal arbitrary values to XML.
- 2014-04-28: ValuesForPath() and NewMap() now accept path with indexed array references.
-
-Basic Unmarshal XML to map[string]interface{}
-type Map map[string]interface{}
-
-Create a `Map` value, 'mv', from any `map[string]interface{}` value, 'v':
-mv := Map(v)
-
-Unmarshal / marshal XML as a `Map` value, 'mv':
-mv, err := NewMapXml(xmlValue) // unmarshal
-xmlValue, err := mv.Xml() // marshal
-
-Unmarshal XML from an `io.Reader` as a `Map` value, 'mv':
-mv, err := NewMapXmlReader(xmlReader) // repeated calls, as with an os.File Reader, will process stream
-mv, raw, err := NewMapXmlReaderRaw(xmlReader) // 'raw' is the raw XML that was decoded
-
-Marshal `Map` value, 'mv', to an XML Writer (`io.Writer`):
-err := mv.XmlWriter(xmlWriter)
-raw, err := mv.XmlWriterRaw(xmlWriter) // 'raw' is the raw XML that was written on xmlWriter
-
-Also, for prettified output:
-xmlValue, err := mv.XmlIndent(prefix, indent, ...)
-err := mv.XmlIndentWriter(xmlWriter, prefix, indent, ...)
-raw, err := mv.XmlIndentWriterRaw(xmlWriter, prefix, indent, ...)
-
-Bulk process XML with error handling (note: handlers must return a boolean value):
-err := HandleXmlReader(xmlReader, mapHandler(Map), errHandler(error))
-err := HandleXmlReaderRaw(xmlReader, mapHandler(Map, []byte), errHandler(error, []byte))
-
-Converting XML to JSON: see Examples for `NewMapXml` and `HandleXmlReader`.
-
-There are comparable functions and methods for JSON processing.
-
-Arbitrary structure values can be decoded to / encoded from `Map` values:
-mv, err := NewMapStruct(structVal)
-err := mv.Struct(structPointer)
-
-Extract / modify Map values
-To work with XML tag values, JSON or Map key values or structure field values, decode the XML, JSON
-or structure to a `Map` value, 'mv', or cast a `map[string]interface{}` value to a `Map` value, 'mv', then:
-paths := mv.PathsForKey(key)
-path := mv.PathForKeyShortest(key)
-values, err := mv.ValuesForKey(key, subkeys)
-values, err := mv.ValuesForPath(path, subkeys)
-count, err := mv.UpdateValuesForPath(newVal, path, subkeys)
-
-Get everything at once, irrespective of path depth:
-leafnodes := mv.LeafNodes()
-leafvalues := mv.LeafValues()
-
-A new `Map` with whatever keys are desired can be created from the current `Map` and then encoded in XML
-or JSON. (Note: keys can use dot-notation.)
-newMap, err := mv.NewMap("oldKey_1:newKey_1", "oldKey_2:newKey_2", ..., "oldKey_N:newKey_N")
-newMap, err := mv.NewMap("oldKey1", "oldKey3", "oldKey5") // a subset of 'mv'; see "examples/partial.go"
-newXml, err := newMap.Xml() // for example
-newJson, err := newMap.Json() // ditto
-
-Usage
-
-The package is fairly well [self-documented with examples](http://godoc.org/github.com/clbanning/mxj).
-
-Also, the subdirectory "examples" contains a wide range of examples, several taken from golang-nuts discussions.
-
-XML parsing conventions
-
-Using NewMapXml()
-
- - Attributes are parsed to `map[string]interface{}` values by prefixing a hyphen, `-`,
- to the attribute label. (Unless overridden by `PrependAttrWithHyphen(false)` or
- `SetAttrPrefix()`.)
- - If the element is a simple element and has attributes, the element value
- is given the key `#text` for its `map[string]interface{}` representation. (See
- the 'atomFeedString.xml' test data, below.)
- - XML comments, directives, and process instructions are ignored.
- - If CoerceKeysToLower() has been called, then the resultant keys will be lower case.
-
-Using NewMapXmlSeq()
-
- - Attributes are parsed to `map["#attr"]map[]map[string]interface{}`values
- where the `` value has "#text" and "#seq" keys - the "#text" key holds the
- value for ``.
- - All elements, except for the root, have a "#seq" key.
- - Comments, directives, and process instructions are unmarshalled into the Map using the
- keys "#comment", "#directive", and "#procinst", respectively. (See documentation for more
- specifics.)
- - Name space syntax is preserved:
- - `something` parses to `map["ns:key"]interface{}{"something"}`
- - `xmlns:ns="http://myns.com/ns"` parses to `map["xmlns:ns"]interface{}{"http://myns.com/ns"}`
-
-Both
-
- - By default, "Nan", "Inf", and "-Inf" values are not cast to float64. If you want them
- to be cast, set a flag to cast them using CastNanInf(true).
-
-XML encoding conventions
-
- - 'nil' `Map` values, which may represent 'null' JSON values, are encoded as ``.
- NOTE: the operation is not symmetric as `` elements are decoded as `tag:""` `Map` values,
- which, then, encode in JSON as `"tag":""` values.
- - ALSO: there is no guarantee that the encoded XML doc will be the same as the decoded one. (Go
- randomizes the walk through map[string]interface{} values.) If you plan to re-encode the
- Map value to XML and want the same sequencing of elements look at NewMapXmlSeq() and
- mv.XmlSeq() - these try to preserve the element sequencing but with added complexity when
- working with the Map representation.
-
-Running "go test"
-
-Because there are no guarantees on the sequence map elements are retrieved, the tests have been
-written for visual verification in most cases. One advantage is that you can easily use the
-output from running "go test" as examples of calling the various functions and methods.
-
-Motivation
-
-I make extensive use of JSON for messaging and typically unmarshal the messages into
-`map[string]interface{}` values. This is easily done using `json.Unmarshal` from the
-standard Go libraries. Unfortunately, many legacy solutions use structured
-XML messages; in those environments the applications would have to be refactored to
-interoperate with my components.
-
-The better solution is to just provide an alternative HTTP handler that receives
-XML messages and parses it into a `map[string]interface{}` value and then reuse
-all the JSON-based code. The Go `xml.Unmarshal()` function does not provide the same
-option of unmarshaling XML messages into `map[string]interface{}` values. So I wrote
-a couple of small functions to fill this gap and released them as the x2j package.
-
-Over the next year and a half additional features were added, and the companion j2x
-package was released to address XML encoding of arbitrary JSON and `map[string]interface{}`
-values. As part of a refactoring of our production system and looking at how we had been
-using the x2j and j2x packages we found that we rarely performed direct XML-to-JSON or
-JSON-to_XML conversion and that working with the XML or JSON as `map[string]interface{}`
-values was the primary value. Thus, everything was refactored into the mxj package.
-
diff --git a/vendor/github.com/clbanning/mxj/v2/remove.go b/vendor/github.com/clbanning/mxj/v2/remove.go
deleted file mode 100644
index 8362ab1..0000000
--- a/vendor/github.com/clbanning/mxj/v2/remove.go
+++ /dev/null
@@ -1,37 +0,0 @@
-package mxj
-
-import "strings"
-
-// Removes the path.
-func (mv Map) Remove(path string) error {
- m := map[string]interface{}(mv)
- return remove(m, path)
-}
-
-func remove(m interface{}, path string) error {
- val, err := prevValueByPath(m, path)
- if err != nil {
- return err
- }
-
- lastKey := lastKey(path)
- delete(val, lastKey)
-
- return nil
-}
-
-// returns the last key of the path.
-// lastKey("a.b.c") would had returned "c"
-func lastKey(path string) string {
- keys := strings.Split(path, ".")
- key := keys[len(keys)-1]
- return key
-}
-
-// returns the path without the last key
-// parentPath("a.b.c") whould had returned "a.b"
-func parentPath(path string) string {
- keys := strings.Split(path, ".")
- parentPath := strings.Join(keys[0:len(keys)-1], ".")
- return parentPath
-}
diff --git a/vendor/github.com/clbanning/mxj/v2/rename.go b/vendor/github.com/clbanning/mxj/v2/rename.go
deleted file mode 100644
index 4c655ed..0000000
--- a/vendor/github.com/clbanning/mxj/v2/rename.go
+++ /dev/null
@@ -1,61 +0,0 @@
-package mxj
-
-import (
- "errors"
- "strings"
-)
-
-// RenameKey renames a key in a Map.
-// It works only for nested maps.
-// It doesn't work for cases when the key is in a list.
-func (mv Map) RenameKey(path string, newName string) error {
- var v bool
- var err error
- if v, err = mv.Exists(path); err == nil && !v {
- return errors.New("RenameKey: path not found: " + path)
- } else if err != nil {
- return err
- }
- if v, err = mv.Exists(parentPath(path) + "." + newName); err == nil && v {
- return errors.New("RenameKey: key already exists: " + newName)
- } else if err != nil {
- return err
- }
-
- m := map[string]interface{}(mv)
- return renameKey(m, path, newName)
-}
-
-func renameKey(m interface{}, path string, newName string) error {
- val, err := prevValueByPath(m, path)
- if err != nil {
- return err
- }
-
- oldName := lastKey(path)
- val[newName] = val[oldName]
- delete(val, oldName)
-
- return nil
-}
-
-// returns a value which contains a last key in the path
-// For example: prevValueByPath("a.b.c", {a{b{c: 3}}}) returns {c: 3}
-func prevValueByPath(m interface{}, path string) (map[string]interface{}, error) {
- keys := strings.Split(path, ".")
-
- switch mValue := m.(type) {
- case map[string]interface{}:
- for key, value := range mValue {
- if key == keys[0] {
- if len(keys) == 1 {
- return mValue, nil
- } else {
- // keep looking for the full path to the key
- return prevValueByPath(value, strings.Join(keys[1:], "."))
- }
- }
- }
- }
- return nil, errors.New("prevValueByPath: didn't find path – " + path)
-}
diff --git a/vendor/github.com/clbanning/mxj/v2/set.go b/vendor/github.com/clbanning/mxj/v2/set.go
deleted file mode 100644
index a297fc3..0000000
--- a/vendor/github.com/clbanning/mxj/v2/set.go
+++ /dev/null
@@ -1,26 +0,0 @@
-package mxj
-
-import (
- "strings"
-)
-
-// Sets the value for the path
-func (mv Map) SetValueForPath(value interface{}, path string) error {
- pathAry := strings.Split(path, ".")
- parentPathAry := pathAry[0 : len(pathAry)-1]
- parentPath := strings.Join(parentPathAry, ".")
-
- val, err := mv.ValueForPath(parentPath)
- if err != nil {
- return err
- }
- if val == nil {
- return nil // we just ignore the request if there's no val
- }
-
- key := pathAry[len(pathAry)-1]
- cVal := val.(map[string]interface{})
- cVal[key] = value
-
- return nil
-}
diff --git a/vendor/github.com/clbanning/mxj/v2/setfieldsep.go b/vendor/github.com/clbanning/mxj/v2/setfieldsep.go
deleted file mode 100644
index b70715e..0000000
--- a/vendor/github.com/clbanning/mxj/v2/setfieldsep.go
+++ /dev/null
@@ -1,20 +0,0 @@
-package mxj
-
-// Per: https://github.com/clbanning/mxj/issues/37#issuecomment-278651862
-var fieldSep string = ":"
-
-// SetFieldSeparator changes the default field separator, ":", for the
-// newVal argument in mv.UpdateValuesForPath and the optional 'subkey' arguments
-// in mv.ValuesForKey and mv.ValuesForPath.
-//
-// E.g., if the newVal value is "http://blah/blah", setting the field separator
-// to "|" will allow the newVal specification, "|http://blah/blah" to parse
-// properly. If called with no argument or an empty string value, the field
-// separator is set to the default, ":".
-func SetFieldSeparator(s ...string) {
- if len(s) == 0 || s[0] == "" {
- fieldSep = ":" // the default
- return
- }
- fieldSep = s[0]
-}
diff --git a/vendor/github.com/clbanning/mxj/v2/songtext.xml b/vendor/github.com/clbanning/mxj/v2/songtext.xml
deleted file mode 100644
index 8c0f2be..0000000
--- a/vendor/github.com/clbanning/mxj/v2/songtext.xml
+++ /dev/null
@@ -1,29 +0,0 @@
-
- help me!
-
-
-
- Henry was a renegade
- Didn't like to play it safe
- One component at a time
- There's got to be a better way
- Oh, people came from miles around
- Searching for a steady job
- Welcome to the Motor Town
- Booming like an atom bomb
-
-
- Oh, Henry was the end of the story
- Then everything went wrong
- And we'll return it to its former glory
- But it just takes so long
-
-
-
- It's going to take a long time
- It's going to take it, but we'll make it one day
- It's going to take a long time
- It's going to take it, but we'll make it one day
-
-
-
diff --git a/vendor/github.com/clbanning/mxj/v2/strict.go b/vendor/github.com/clbanning/mxj/v2/strict.go
deleted file mode 100644
index 1e76956..0000000
--- a/vendor/github.com/clbanning/mxj/v2/strict.go
+++ /dev/null
@@ -1,30 +0,0 @@
-// Copyright 2016 Charles Banning. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file
-
-// strict.go actually addresses setting xml.Decoder attribute
-// values. This'll let you parse non-standard XML.
-
-package mxj
-
-import (
- "encoding/xml"
-)
-
-// CustomDecoder can be used to specify xml.Decoder attribute
-// values, e.g., Strict:false, to be used. By default CustomDecoder
-// is nil. If CustomeDecoder != nil, then mxj.XmlCharsetReader variable is
-// ignored and must be set as part of the CustomDecoder value, if needed.
-// Usage:
-// mxj.CustomDecoder = &xml.Decoder{Strict:false}
-var CustomDecoder *xml.Decoder
-
-// useCustomDecoder copy over public attributes from customDecoder
-func useCustomDecoder(d *xml.Decoder) {
- d.Strict = CustomDecoder.Strict
- d.AutoClose = CustomDecoder.AutoClose
- d.Entity = CustomDecoder.Entity
- d.CharsetReader = CustomDecoder.CharsetReader
- d.DefaultSpace = CustomDecoder.DefaultSpace
-}
-
diff --git a/vendor/github.com/clbanning/mxj/v2/struct.go b/vendor/github.com/clbanning/mxj/v2/struct.go
deleted file mode 100644
index 9be636c..0000000
--- a/vendor/github.com/clbanning/mxj/v2/struct.go
+++ /dev/null
@@ -1,54 +0,0 @@
-// Copyright 2012-2017 Charles Banning. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file
-
-package mxj
-
-import (
- "encoding/json"
- "errors"
- "reflect"
-
- // "github.com/fatih/structs"
-)
-
-// Create a new Map value from a structure. Error returned if argument is not a structure.
-// Only public structure fields are decoded in the Map value. See github.com/fatih/structs#Map
-// for handling of "structs" tags.
-
-// DEPRECATED - import github.com/fatih/structs and cast result of structs.Map to mxj.Map.
-// import "github.com/fatih/structs"
-// ...
-// sm, err := structs.Map()
-// if err != nil {
-// // handle error
-// }
-// m := mxj.Map(sm)
-// Alernatively uncomment the old source and import in struct.go.
-func NewMapStruct(structVal interface{}) (Map, error) {
- return nil, errors.New("deprecated - see package documentation")
- /*
- if !structs.IsStruct(structVal) {
- return nil, errors.New("NewMapStruct() error: argument is not type Struct")
- }
- return structs.Map(structVal), nil
- */
-}
-
-// Marshal a map[string]interface{} into a structure referenced by 'structPtr'. Error returned
-// if argument is not a pointer or if json.Unmarshal returns an error.
-// json.Unmarshal structure encoding rules are followed to encode public structure fields.
-func (mv Map) Struct(structPtr interface{}) error {
- // should check that we're getting a pointer.
- if reflect.ValueOf(structPtr).Kind() != reflect.Ptr {
- return errors.New("mv.Struct() error: argument is not type Ptr")
- }
-
- m := map[string]interface{}(mv)
- j, err := json.Marshal(m)
- if err != nil {
- return err
- }
-
- return json.Unmarshal(j, structPtr)
-}
diff --git a/vendor/github.com/clbanning/mxj/v2/updatevalues.go b/vendor/github.com/clbanning/mxj/v2/updatevalues.go
deleted file mode 100644
index 9e10d84..0000000
--- a/vendor/github.com/clbanning/mxj/v2/updatevalues.go
+++ /dev/null
@@ -1,258 +0,0 @@
-// Copyright 2012-2014, 2017 Charles Banning. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file
-
-// updatevalues.go - modify a value based on path and possibly sub-keys
-// TODO(clb): handle simple elements with attributes and NewMapXmlSeq Map values.
-
-package mxj
-
-import (
- "fmt"
- "strconv"
- "strings"
-)
-
-// Update value based on path and possible sub-key values.
-// A count of the number of values changed and any error are returned.
-// If the count == 0, then no path (and subkeys) matched.
-// 'newVal' can be a Map or map[string]interface{} value with a single 'key' that is the key to be modified
-// or a string value "key:value[:type]" where type is "bool" or "num" to cast the value.
-// 'path' is dot-notation list of keys to traverse; last key in path can be newVal key
-// NOTE: 'path' spec does not currently support indexed array references.
-// 'subkeys' are "key:value[:type]" entries that must match for path node
-// - For attributes prefix the label with the attribute prefix character, by default a
-// hyphen, '-', e.g., "-seq:3". (See SetAttrPrefix function.)
-// - The subkey can be wildcarded - "key:*" - to require that it's there with some value.
-// - If a subkey is preceeded with the '!' character, the key:value[:type] entry is treated as an
-// exclusion critera - e.g., "!author:William T. Gaddis".
-//
-// NOTES:
-// 1. Simple elements with attributes need a path terminated as ".#text" to modify the actual value.
-// 2. Values in Maps created using NewMapXmlSeq are map[string]interface{} values with a "#text" key.
-// 3. If values in 'newVal' or 'subkeys' args contain ":", use SetFieldSeparator to an unused symbol,
-// perhaps "|".
-func (mv Map) UpdateValuesForPath(newVal interface{}, path string, subkeys ...string) (int, error) {
- m := map[string]interface{}(mv)
-
- // extract the subkeys
- var subKeyMap map[string]interface{}
- if len(subkeys) > 0 {
- var err error
- subKeyMap, err = getSubKeyMap(subkeys...)
- if err != nil {
- return 0, err
- }
- }
-
- // extract key and value from newVal
- var key string
- var val interface{}
- switch newVal.(type) {
- case map[string]interface{}, Map:
- switch newVal.(type) { // "fallthrough is not permitted in type switch" (Spec)
- case Map:
- newVal = newVal.(Map).Old()
- }
- if len(newVal.(map[string]interface{})) != 1 {
- return 0, fmt.Errorf("newVal map can only have len == 1 - %+v", newVal)
- }
- for key, val = range newVal.(map[string]interface{}) {
- }
- case string: // split it as a key:value pair
- ss := strings.Split(newVal.(string), fieldSep)
- n := len(ss)
- if n < 2 || n > 3 {
- return 0, fmt.Errorf("unknown newVal spec - %+v", newVal)
- }
- key = ss[0]
- if n == 2 {
- val = interface{}(ss[1])
- } else if n == 3 {
- switch ss[2] {
- case "bool", "boolean":
- nv, err := strconv.ParseBool(ss[1])
- if err != nil {
- return 0, fmt.Errorf("can't convert newVal to bool - %+v", newVal)
- }
- val = interface{}(nv)
- case "num", "numeric", "float", "int":
- nv, err := strconv.ParseFloat(ss[1], 64)
- if err != nil {
- return 0, fmt.Errorf("can't convert newVal to float64 - %+v", newVal)
- }
- val = interface{}(nv)
- default:
- return 0, fmt.Errorf("unknown type for newVal value - %+v", newVal)
- }
- }
- default:
- return 0, fmt.Errorf("invalid newVal type - %+v", newVal)
- }
-
- // parse path
- keys := strings.Split(path, ".")
-
- var count int
- updateValuesForKeyPath(key, val, m, keys, subKeyMap, &count)
-
- return count, nil
-}
-
-// navigate the path
-func updateValuesForKeyPath(key string, value interface{}, m interface{}, keys []string, subkeys map[string]interface{}, cnt *int) {
- // ----- at end node: looking at possible node to get 'key' ----
- if len(keys) == 1 {
- updateValue(key, value, m, keys[0], subkeys, cnt)
- return
- }
-
- // ----- here we are navigating the path thru the penultimate node --------
- // key of interest is keys[0] - the next in the path
- switch keys[0] {
- case "*": // wildcard - scan all values
- switch m.(type) {
- case map[string]interface{}:
- for _, v := range m.(map[string]interface{}) {
- updateValuesForKeyPath(key, value, v, keys[1:], subkeys, cnt)
- }
- case []interface{}:
- for _, v := range m.([]interface{}) {
- switch v.(type) {
- // flatten out a list of maps - keys are processed
- case map[string]interface{}:
- for _, vv := range v.(map[string]interface{}) {
- updateValuesForKeyPath(key, value, vv, keys[1:], subkeys, cnt)
- }
- default:
- updateValuesForKeyPath(key, value, v, keys[1:], subkeys, cnt)
- }
- }
- }
- default: // key - must be map[string]interface{}
- switch m.(type) {
- case map[string]interface{}:
- if v, ok := m.(map[string]interface{})[keys[0]]; ok {
- updateValuesForKeyPath(key, value, v, keys[1:], subkeys, cnt)
- }
- case []interface{}: // may be buried in list
- for _, v := range m.([]interface{}) {
- switch v.(type) {
- case map[string]interface{}:
- if vv, ok := v.(map[string]interface{})[keys[0]]; ok {
- updateValuesForKeyPath(key, value, vv, keys[1:], subkeys, cnt)
- }
- }
- }
- }
- }
-}
-
-// change value if key and subkeys are present
-func updateValue(key string, value interface{}, m interface{}, keys0 string, subkeys map[string]interface{}, cnt *int) {
- // there are two possible options for the value of 'keys0': map[string]interface, []interface{}
- // and 'key' is a key in the map or is a key in a map in a list.
- switch m.(type) {
- case map[string]interface{}: // gotta have the last key
- if keys0 == "*" {
- for k := range m.(map[string]interface{}) {
- updateValue(key, value, m, k, subkeys, cnt)
- }
- return
- }
- endVal, _ := m.(map[string]interface{})[keys0]
-
- // if newV key is the end of path, replace the value for path-end
- // may be []interface{} - means replace just an entry w/ subkeys
- // otherwise replace the keys0 value if subkeys are there
- // NOTE: this will replace the subkeys, also
- if key == keys0 {
- switch endVal.(type) {
- case map[string]interface{}:
- if hasSubKeys(m, subkeys) {
- (m.(map[string]interface{}))[keys0] = value
- (*cnt)++
- }
- case []interface{}:
- // without subkeys can't select list member to modify
- // so key:value spec is it ...
- if hasSubKeys(m, subkeys) {
- (m.(map[string]interface{}))[keys0] = value
- (*cnt)++
- break
- }
- nv := make([]interface{}, 0)
- var valmodified bool
- for _, v := range endVal.([]interface{}) {
- // check entry subkeys
- if hasSubKeys(v, subkeys) {
- // replace v with value
- nv = append(nv, value)
- valmodified = true
- (*cnt)++
- continue
- }
- nv = append(nv, v)
- }
- if valmodified {
- (m.(map[string]interface{}))[keys0] = interface{}(nv)
- }
- default: // anything else is a strict replacement
- if hasSubKeys(m, subkeys) {
- (m.(map[string]interface{}))[keys0] = value
- (*cnt)++
- }
- }
- return
- }
-
- // so value is for an element of endVal
- // if endVal is a map then 'key' must be there w/ subkeys
- // if endVal is a list then 'key' must be in a list member w/ subkeys
- switch endVal.(type) {
- case map[string]interface{}:
- if !hasSubKeys(endVal, subkeys) {
- return
- }
- if _, ok := (endVal.(map[string]interface{}))[key]; ok {
- (endVal.(map[string]interface{}))[key] = value
- (*cnt)++
- }
- case []interface{}: // keys0 points to a list, check subkeys
- for _, v := range endVal.([]interface{}) {
- // got to be a map so we can replace value for 'key'
- vv, vok := v.(map[string]interface{})
- if !vok {
- continue
- }
- if _, ok := vv[key]; !ok {
- continue
- }
- if !hasSubKeys(vv, subkeys) {
- continue
- }
- vv[key] = value
- (*cnt)++
- }
- }
- case []interface{}: // key may be in a list member
- // don't need to handle keys0 == "*"; we're looking at everything, anyway.
- for _, v := range m.([]interface{}) {
- // only map values - we're looking for 'key'
- mm, ok := v.(map[string]interface{})
- if !ok {
- continue
- }
- if _, ok := mm[key]; !ok {
- continue
- }
- if !hasSubKeys(mm, subkeys) {
- continue
- }
- mm[key] = value
- (*cnt)++
- }
- }
-
- // return
-}
diff --git a/vendor/github.com/clbanning/mxj/v2/xml.go b/vendor/github.com/clbanning/mxj/v2/xml.go
deleted file mode 100644
index b72a146..0000000
--- a/vendor/github.com/clbanning/mxj/v2/xml.go
+++ /dev/null
@@ -1,1440 +0,0 @@
-// Copyright 2012-2016, 2018-2019 Charles Banning. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file
-
-// xml.go - basically the core of X2j for map[string]interface{} values.
-// NewMapXml, NewMapXmlReader, mv.Xml, mv.XmlWriter
-// see x2j and j2x for wrappers to provide end-to-end transformation of XML and JSON messages.
-
-package mxj
-
-import (
- "bytes"
- "encoding/json"
- "encoding/xml"
- "errors"
- "fmt"
- "io"
- "reflect"
- "sort"
- "strconv"
- "strings"
- "time"
-)
-
-var (
- textK = "#text"
- seqK = "#seq"
- commentK = "#comment"
- attrK = "#attr"
- directiveK = "#directive"
- procinstK = "#procinst"
- targetK = "#target"
- instK = "#inst"
-)
-
-// Support overriding default Map keys prefix
-
-func SetGlobalKeyMapPrefix(s string) {
- textK = strings.ReplaceAll(textK, textK[0:1], s)
- seqK = strings.ReplaceAll(seqK, seqK[0:1], s)
- commentK = strings.ReplaceAll(commentK, commentK[0:1], s)
- directiveK = strings.ReplaceAll(directiveK, directiveK[0:1], s)
- procinstK = strings.ReplaceAll(procinstK, procinstK[0:1], s)
- targetK = strings.ReplaceAll(targetK, targetK[0:1], s)
- instK = strings.ReplaceAll(instK, instK[0:1], s)
- attrK = strings.ReplaceAll(attrK, attrK[0:1], s)
-}
-
-// ------------------- NewMapXml & NewMapXmlReader ... -------------------------
-
-// If XmlCharsetReader != nil, it will be used to decode the XML, if required.
-// Note: if CustomDecoder != nil, then XmlCharsetReader is ignored;
-// set the CustomDecoder attribute instead.
-// import (
-// charset "code.google.com/p/go-charset/charset"
-// github.com/clbanning/mxj
-// )
-// ...
-// mxj.XmlCharsetReader = charset.NewReader
-// m, merr := mxj.NewMapXml(xmlValue)
-var XmlCharsetReader func(charset string, input io.Reader) (io.Reader, error)
-
-// NewMapXml - convert a XML doc into a Map
-// (This is analogous to unmarshalling a JSON string to map[string]interface{} using json.Unmarshal().)
-// If the optional argument 'cast' is 'true', then values will be converted to boolean or float64 if possible.
-//
-// Converting XML to JSON is a simple as:
-// ...
-// mapVal, merr := mxj.NewMapXml(xmlVal)
-// if merr != nil {
-// // handle error
-// }
-// jsonVal, jerr := mapVal.Json()
-// if jerr != nil {
-// // handle error
-// }
-//
-// NOTES:
-// 1. Declarations, directives, process instructions and comments are NOT parsed.
-// 2. The 'xmlVal' will be parsed looking for an xml.StartElement, so BOM and other
-// extraneous xml.CharData will be ignored unless io.EOF is reached first.
-// 3. If CoerceKeysToLower() has been called, then all key values will be lower case.
-// 4. If CoerceKeysToSnakeCase() has been called, then all key values will be converted to snake case.
-// 5. If DisableTrimWhiteSpace(b bool) has been called, then all values will be trimmed or not. 'true' by default.
-func NewMapXml(xmlVal []byte, cast ...bool) (Map, error) {
- var r bool
- if len(cast) == 1 {
- r = cast[0]
- }
- return xmlToMap(xmlVal, r)
-}
-
-// Get next XML doc from an io.Reader as a Map value. Returns Map value.
-// NOTES:
-// 1. Declarations, directives, process instructions and comments are NOT parsed.
-// 2. The 'xmlReader' will be parsed looking for an xml.StartElement, so BOM and other
-// extraneous xml.CharData will be ignored unless io.EOF is reached first.
-// 3. If CoerceKeysToLower() has been called, then all key values will be lower case.
-// 4. If CoerceKeysToSnakeCase() has been called, then all key values will be converted to snake case.
-func NewMapXmlReader(xmlReader io.Reader, cast ...bool) (Map, error) {
- var r bool
- if len(cast) == 1 {
- r = cast[0]
- }
-
- // We need to put an *os.File reader in a ByteReader or the xml.NewDecoder
- // will wrap it in a bufio.Reader and seek on the file beyond where the
- // xml.Decoder parses!
- if _, ok := xmlReader.(io.ByteReader); !ok {
- xmlReader = myByteReader(xmlReader) // see code at EOF
- }
-
- // build the map
- return xmlReaderToMap(xmlReader, r)
-}
-
-// Get next XML doc from an io.Reader as a Map value. Returns Map value and slice with the raw XML.
-// NOTES:
-// 1. Declarations, directives, process instructions and comments are NOT parsed.
-// 2. Due to the implementation of xml.Decoder, the raw XML off the reader is buffered to []byte
-// using a ByteReader. If the io.Reader is an os.File, there may be significant performance impact.
-// See the examples - getmetrics1.go through getmetrics4.go - for comparative use cases on a large
-// data set. If the io.Reader is wrapping a []byte value in-memory, however, such as http.Request.Body
-// you CAN use it to efficiently unmarshal a XML doc and retrieve the raw XML in a single call.
-// 3. The 'raw' return value may be larger than the XML text value.
-// 4. The 'xmlReader' will be parsed looking for an xml.StartElement, so BOM and other
-// extraneous xml.CharData will be ignored unless io.EOF is reached first.
-// 5. If CoerceKeysToLower() has been called, then all key values will be lower case.
-// 6. If CoerceKeysToSnakeCase() has been called, then all key values will be converted to snake case.
-func NewMapXmlReaderRaw(xmlReader io.Reader, cast ...bool) (Map, []byte, error) {
- var r bool
- if len(cast) == 1 {
- r = cast[0]
- }
- // create TeeReader so we can retrieve raw XML
- buf := make([]byte, 0)
- wb := bytes.NewBuffer(buf)
- trdr := myTeeReader(xmlReader, wb) // see code at EOF
-
- m, err := xmlReaderToMap(trdr, r)
-
- // retrieve the raw XML that was decoded
- b := wb.Bytes()
-
- if err != nil {
- return nil, b, err
- }
-
- return m, b, nil
-}
-
-// xmlReaderToMap() - parse a XML io.Reader to a map[string]interface{} value
-func xmlReaderToMap(rdr io.Reader, r bool) (map[string]interface{}, error) {
- // parse the Reader
- p := xml.NewDecoder(rdr)
- if CustomDecoder != nil {
- useCustomDecoder(p)
- } else {
- p.CharsetReader = XmlCharsetReader
- }
- return xmlToMapParser("", nil, p, r)
-}
-
-// xmlToMap - convert a XML doc into map[string]interface{} value
-func xmlToMap(doc []byte, r bool) (map[string]interface{}, error) {
- b := bytes.NewReader(doc)
- p := xml.NewDecoder(b)
- if CustomDecoder != nil {
- useCustomDecoder(p)
- } else {
- p.CharsetReader = XmlCharsetReader
- }
- return xmlToMapParser("", nil, p, r)
-}
-
-// ===================================== where the work happens =============================
-
-// PrependAttrWithHyphen. Prepend attribute tags with a hyphen.
-// Default is 'true'. (Not applicable to NewMapXmlSeq(), mv.XmlSeq(), etc.)
-// Note:
-// If 'false', unmarshaling and marshaling is not symmetric. Attributes will be
-// marshal'd as attr and may be part of a list.
-func PrependAttrWithHyphen(v bool) {
- if v {
- attrPrefix = "-"
- lenAttrPrefix = len(attrPrefix)
- return
- }
- attrPrefix = ""
- lenAttrPrefix = len(attrPrefix)
-}
-
-// Include sequence id with inner tags. - per Sean Murphy, murphysean84@gmail.com.
-var includeTagSeqNum bool
-
-// IncludeTagSeqNum - include a "_seq":N key:value pair with each inner tag, denoting
-// its position when parsed. This is of limited usefulness, since list values cannot
-// be tagged with "_seq" without changing their depth in the Map.
-// So THIS SHOULD BE USED WITH CAUTION - see the test cases. Here's a sample of what
-// you get.
-/*
-
-
-
-
- hello
-
-
- parses as:
-
- {
- Obj:{
- "-c":"la",
- "-h":"da",
- "-x":"dee",
- "intObj":[
- {
- "-id"="3",
- "_seq":"0" // if mxj.Cast is passed, then: "_seq":0
- },
- {
- "-id"="2",
- "_seq":"2"
- }],
- "intObj1":{
- "-id":"1",
- "_seq":"1"
- },
- "StrObj":{
- "#text":"hello", // simple element value gets "#text" tag
- "_seq":"3"
- }
- }
- }
-*/
-func IncludeTagSeqNum(b ...bool) {
- if len(b) == 0 {
- includeTagSeqNum = !includeTagSeqNum
- } else if len(b) == 1 {
- includeTagSeqNum = b[0]
- }
-}
-
-// all keys will be "lower case"
-var lowerCase bool
-
-// Coerce all tag values to keys in lower case. This is useful if you've got sources with variable
-// tag capitalization, and you want to use m.ValuesForKeys(), etc., with the key or path spec
-// in lower case.
-// CoerceKeysToLower() will toggle the coercion flag true|false - on|off
-// CoerceKeysToLower(true|false) will set the coercion flag on|off
-//
-// NOTE: only recognized by NewMapXml, NewMapXmlReader, and NewMapXmlReaderRaw functions as well as
-// the associated HandleXmlReader and HandleXmlReaderRaw.
-func CoerceKeysToLower(b ...bool) {
- if len(b) == 0 {
- lowerCase = !lowerCase
- } else if len(b) == 1 {
- lowerCase = b[0]
- }
-}
-
-// disableTrimWhiteSpace sets if the white space should be removed or not
-var disableTrimWhiteSpace bool
-var trimRunes = "\t\r\b\n "
-
-// DisableTrimWhiteSpace set if the white space should be trimmed or not. By default white space is always trimmed. If
-// no argument is provided, trim white space will be disabled.
-func DisableTrimWhiteSpace(b ...bool) {
- if len(b) == 0 {
- disableTrimWhiteSpace = true
- } else {
- disableTrimWhiteSpace = b[0]
- }
-
- if disableTrimWhiteSpace {
- trimRunes = "\t\r\b\n"
- } else {
- trimRunes = "\t\r\b\n "
- }
-}
-
-// 25jun16: Allow user to specify the "prefix" character for XML attribute key labels.
-// We do this by replacing '`' constant with attrPrefix var, replacing useHyphen with attrPrefix = "",
-// and adding a SetAttrPrefix(s string) function.
-
-var attrPrefix string = `-` // the default
-var lenAttrPrefix int = 1 // the default
-
-// SetAttrPrefix changes the default, "-", to the specified value, s.
-// SetAttrPrefix("") is the same as PrependAttrWithHyphen(false).
-// (Not applicable for NewMapXmlSeq(), mv.XmlSeq(), etc.)
-func SetAttrPrefix(s string) {
- attrPrefix = s
- lenAttrPrefix = len(attrPrefix)
-}
-
-// 18jan17: Allows user to specify if the map keys should be in snake case instead
-// of the default hyphenated notation.
-var snakeCaseKeys bool
-
-// CoerceKeysToSnakeCase changes the default, false, to the specified value, b.
-// Note: the attribute prefix will be a hyphen, '-', or what ever string value has
-// been specified using SetAttrPrefix.
-func CoerceKeysToSnakeCase(b ...bool) {
- if len(b) == 0 {
- snakeCaseKeys = !snakeCaseKeys
- } else if len(b) == 1 {
- snakeCaseKeys = b[0]
- }
-}
-
-// 10jan19: use of pull request #57 should be conditional - legacy code assumes
-// numeric values are float64.
-var castToInt bool
-
-// CastValuesToInt tries to coerce numeric valus to int64 or uint64 instead of the
-// default float64. Repeated calls with no argument will toggle this on/off, or this
-// handling will be set with the value of 'b'.
-func CastValuesToInt(b ...bool) {
- if len(b) == 0 {
- castToInt = !castToInt
- } else if len(b) == 1 {
- castToInt = b[0]
- }
-}
-
-// 05feb17: support processing XMPP streams (issue #36)
-var handleXMPPStreamTag bool
-
-// HandleXMPPStreamTag causes decoder to parse XMPP elements.
-// If called with no argument, XMPP stream element handling is toggled on/off.
-// (See xmppStream_test.go for example.)
-// If called with NewMapXml, NewMapXmlReader, New MapXmlReaderRaw the "stream"
-// element will be returned as:
-// map["stream"]interface{}{map[-]interface{}}.
-// If called with NewMapSeq, NewMapSeqReader, NewMapSeqReaderRaw the "stream"
-// element will be returned as:
-// map["stream:stream"]interface{}{map["#attr"]interface{}{map[string]interface{}}}
-// where the "#attr" values have "#text" and "#seq" keys. (See NewMapXmlSeq.)
-func HandleXMPPStreamTag(b ...bool) {
- if len(b) == 0 {
- handleXMPPStreamTag = !handleXMPPStreamTag
- } else if len(b) == 1 {
- handleXMPPStreamTag = b[0]
- }
-}
-
-// 21jan18 - decode all values as map["#text":value] (issue #56)
-var decodeSimpleValuesAsMap bool
-
-// DecodeSimpleValuesAsMap forces all values to be decoded as map["#text":].
-// If called with no argument, the decoding is toggled on/off.
-//
-// By default the NewMapXml functions decode simple values without attributes as
-// map[:]. This function causes simple values without attributes to be
-// decoded the same as simple values with attributes - map[:map["#text":]].
-func DecodeSimpleValuesAsMap(b ...bool) {
- if len(b) == 0 {
- decodeSimpleValuesAsMap = !decodeSimpleValuesAsMap
- } else if len(b) == 1 {
- decodeSimpleValuesAsMap = b[0]
- }
-}
-
-// xmlToMapParser (2015.11.12) - load a 'clean' XML doc into a map[string]interface{} directly.
-// A refactoring of xmlToTreeParser(), markDuplicate() and treeToMap() - here, all-in-one.
-// We've removed the intermediate *node tree with the allocation and subsequent rescanning.
-func xmlToMapParser(skey string, a []xml.Attr, p *xml.Decoder, r bool) (map[string]interface{}, error) {
- if lowerCase {
- skey = strings.ToLower(skey)
- }
- if snakeCaseKeys {
- skey = strings.Replace(skey, "-", "_", -1)
- }
-
- // NOTE: all attributes and sub-elements parsed into 'na', 'na' is returned as value for 'skey' in 'n'.
- // Unless 'skey' is a simple element w/o attributes, in which case the xml.CharData value is the value.
- var n, na map[string]interface{}
- var seq int // for includeTagSeqNum
-
- // Allocate maps and load attributes, if any.
- // NOTE: on entry from NewMapXml(), etc., skey=="", and we fall through
- // to get StartElement then recurse with skey==xml.StartElement.Name.Local
- // where we begin allocating map[string]interface{} values 'n' and 'na'.
- if skey != "" {
- n = make(map[string]interface{}) // old n
- na = make(map[string]interface{}) // old n.nodes
- if len(a) > 0 {
- for _, v := range a {
- if snakeCaseKeys {
- v.Name.Local = strings.Replace(v.Name.Local, "-", "_", -1)
- }
- var key string
- key = attrPrefix + v.Name.Local
- if lowerCase {
- key = strings.ToLower(key)
- }
- if xmlEscapeCharsDecoder { // per issue#84
- v.Value = escapeChars(v.Value)
- }
- na[key] = cast(v.Value, r, key)
- }
- }
- }
- // Return XMPP message.
- if handleXMPPStreamTag && skey == "stream" {
- n[skey] = na
- return n, nil
- }
-
- for {
- t, err := p.Token()
- if err != nil {
- if err != io.EOF {
- return nil, errors.New("xml.Decoder.Token() - " + err.Error())
- }
- return nil, err
- }
- switch t.(type) {
- case xml.StartElement:
- tt := t.(xml.StartElement)
-
- // First call to xmlToMapParser() doesn't pass xml.StartElement - the map key.
- // So when the loop is first entered, the first token is the root tag along
- // with any attributes, which we process here.
- //
- // Subsequent calls to xmlToMapParser() will pass in tag+attributes for
- // processing before getting the next token which is the element value,
- // which is done above.
- if skey == "" {
- return xmlToMapParser(tt.Name.Local, tt.Attr, p, r)
- }
-
- // If not initializing the map, parse the element.
- // len(nn) == 1, necessarily - it is just an 'n'.
- nn, err := xmlToMapParser(tt.Name.Local, tt.Attr, p, r)
- if err != nil {
- return nil, err
- }
-
- // The nn map[string]interface{} value is a na[nn_key] value.
- // We need to see if nn_key already exists - means we're parsing a list.
- // This may require converting na[nn_key] value into []interface{} type.
- // First, extract the key:val for the map - it's a singleton.
- // Note:
- // * if CoerceKeysToLower() called, then key will be lower case.
- // * if CoerceKeysToSnakeCase() called, then key will be converted to snake case.
- var key string
- var val interface{}
- for key, val = range nn {
- break
- }
-
- // IncludeTagSeqNum requests that the element be augmented with a "_seq" sub-element.
- // In theory, we don't need this if len(na) == 1. But, we don't know what might
- // come next - we're only parsing forward. So if you ask for 'includeTagSeqNum' you
- // get it on every element. (Personally, I never liked this, but I added it on request
- // and did get a $50 Amazon gift card in return - now we support it for backwards compatibility!)
- if includeTagSeqNum {
- switch val.(type) {
- case []interface{}:
- // noop - There's no clean way to handle this w/o changing message structure.
- case map[string]interface{}:
- val.(map[string]interface{})["_seq"] = seq // will overwrite an "_seq" XML tag
- seq++
- case interface{}: // a non-nil simple element: string, float64, bool
- v := map[string]interface{}{textK: val}
- v["_seq"] = seq
- seq++
- val = v
- }
- }
-
- // 'na' holding sub-elements of n.
- // See if 'key' already exists.
- // If 'key' exists, then this is a list, if not just add key:val to na.
- if v, ok := na[key]; ok {
- var a []interface{}
- switch v.(type) {
- case []interface{}:
- a = v.([]interface{})
- default: // anything else - note: v.(type) != nil
- a = []interface{}{v}
- }
- a = append(a, val)
- na[key] = a
- } else {
- na[key] = val // save it as a singleton
- }
- case xml.EndElement:
- // len(n) > 0 if this is a simple element w/o xml.Attrs - see xml.CharData case.
- if len(n) == 0 {
- // If len(na)==0 we have an empty element == "";
- // it has no xml.Attr nor xml.CharData.
- // Note: in original node-tree parser, val defaulted to "";
- // so we always had the default if len(node.nodes) == 0.
- if len(na) > 0 {
- n[skey] = na
- } else {
- n[skey] = "" // empty element
- }
- } else if len(n) == 1 && len(na) > 0 {
- // it's a simple element w/ no attributes w/ subelements
- for _, v := range n {
- na[textK] = v
- }
- n[skey] = na
- }
- return n, nil
- case xml.CharData:
- // clean up possible noise
- tt := strings.Trim(string(t.(xml.CharData)), trimRunes)
- if xmlEscapeCharsDecoder { // issue#84
- tt = escapeChars(tt)
- }
- if len(tt) > 0 {
- if len(na) > 0 || decodeSimpleValuesAsMap {
- na[textK] = cast(tt, r, textK)
- } else if skey != "" {
- n[skey] = cast(tt, r, skey)
- } else {
- // per Adrian (http://www.adrianlungu.com/) catch stray text
- // in decoder stream -
- // https://github.com/clbanning/mxj/pull/14#issuecomment-182816374
- // NOTE: CharSetReader must be set to non-UTF-8 CharSet or you'll get
- // a p.Token() decoding error when the BOM is UTF-16 or UTF-32.
- continue
- }
- }
- default:
- // noop
- }
- }
-}
-
-var castNanInf bool
-
-// Cast "Nan", "Inf", "-Inf" XML values to 'float64'.
-// By default, these values will be decoded as 'string'.
-func CastNanInf(b ...bool) {
- if len(b) == 0 {
- castNanInf = !castNanInf
- } else if len(b) == 1 {
- castNanInf = b[0]
- }
-}
-
-// cast - try to cast string values to bool or float64
-// 't' is the tag key that can be checked for 'not-casting'
-func cast(s string, r bool, t string) interface{} {
- if checkTagToSkip != nil && t != "" && checkTagToSkip(t) {
- // call the check-function here with 't[0]'
- // if 'true' return s
- return s
- }
-
- if r {
- // handle nan and inf
- if !castNanInf {
- switch strings.ToLower(s) {
- case "nan", "inf", "-inf":
- return s
- }
- }
-
- // handle numeric strings ahead of boolean
- if castToInt {
- if f, err := strconv.ParseInt(s, 10, 64); err == nil {
- return f
- }
- if f, err := strconv.ParseUint(s, 10, 64); err == nil {
- return f
- }
- }
-
- if castToFloat {
- if f, err := strconv.ParseFloat(s, 64); err == nil {
- return f
- }
- }
-
- // ParseBool treats "1"==true & "0"==false, we've already scanned those
- // values as float64. See if value has 't' or 'f' as initial screen to
- // minimize calls to ParseBool; also, see if len(s) < 6.
- if castToBool {
- if len(s) > 0 && len(s) < 6 {
- switch s[:1] {
- case "t", "T", "f", "F":
- if b, err := strconv.ParseBool(s); err == nil {
- return b
- }
- }
- }
- }
- }
- return s
-}
-
-// pull request, #59
-var castToFloat = true
-
-// CastValuesToFloat can be used to skip casting to float64 when
-// "cast" argument is 'true' in NewMapXml, etc.
-// Default is true.
-func CastValuesToFloat(b ...bool) {
- if len(b) == 0 {
- castToFloat = !castToFloat
- } else if len(b) == 1 {
- castToFloat = b[0]
- }
-}
-
-var castToBool = true
-
-// CastValuesToBool can be used to skip casting to bool when
-// "cast" argument is 'true' in NewMapXml, etc.
-// Default is true.
-func CastValuesToBool(b ...bool) {
- if len(b) == 0 {
- castToBool = !castToBool
- } else if len(b) == 1 {
- castToBool = b[0]
- }
-}
-
-// checkTagToSkip - switch to address Issue #58
-
-var checkTagToSkip func(string) bool
-
-// SetCheckTagToSkipFunc registers function to test whether the value
-// for a tag should be cast to bool or float64 when "cast" argument is 'true'.
-// (Dot tag path notation is not supported.)
-// NOTE: key may be "#text" if it's a simple element with attributes
-// or "decodeSimpleValuesAsMap == true".
-// NOTE: does not apply to NewMapXmlSeq... functions.
-func SetCheckTagToSkipFunc(fn func(string) bool) {
- checkTagToSkip = fn
-}
-
-// ------------------ END: NewMapXml & NewMapXmlReader -------------------------
-
-// ------------------ mv.Xml & mv.XmlWriter - from j2x ------------------------
-
-const (
- DefaultRootTag = "doc"
-)
-
-var useGoXmlEmptyElemSyntax bool
-
-// XmlGoEmptyElemSyntax() - rather than .
-// Go's encoding/xml package marshals empty XML elements as . By default this package
-// encodes empty elements as . If you're marshaling Map values that include structures
-// (which are passed to xml.Marshal for encoding), this will let you conform to the standard package.
-func XmlGoEmptyElemSyntax() {
- useGoXmlEmptyElemSyntax = true
-}
-
-// XmlDefaultEmptyElemSyntax() - rather than .
-// Return XML encoding for empty elements to the default package setting.
-// Reverses effect of XmlGoEmptyElemSyntax().
-func XmlDefaultEmptyElemSyntax() {
- useGoXmlEmptyElemSyntax = false
-}
-
-// ------- issue #88 ----------
-// xmlCheckIsValid set switch to force decoding the encoded XML to
-// see if it is valid XML.
-var xmlCheckIsValid bool
-
-// XmlCheckIsValid forces the encoded XML to be checked for validity.
-func XmlCheckIsValid(b ...bool) {
- if len(b) == 1 {
- xmlCheckIsValid = b[0]
- return
- }
- xmlCheckIsValid = !xmlCheckIsValid
-}
-
-// Encode a Map as XML. The companion of NewMapXml().
-// The following rules apply.
-// - The key label "#text" is treated as the value for a simple element with attributes.
-// - Map keys that begin with a hyphen, '-', are interpreted as attributes.
-// It is an error if the attribute doesn't have a []byte, string, number, or boolean value.
-// - Map value type encoding:
-// > string, bool, float64, int, int32, int64, float32: per "%v" formating
-// > []bool, []uint8: by casting to string
-// > structures, etc.: handed to xml.Marshal() - if there is an error, the element
-// value is "UNKNOWN"
-// - Elements with only attribute values or are null are terminated using "/>".
-// - If len(mv) == 1 and no rootTag is provided, then the map key is used as the root tag, possible.
-// Thus, `{ "key":"value" }` encodes as "value".
-// - To encode empty elements in a syntax consistent with encoding/xml call UseGoXmlEmptyElementSyntax().
-// The attributes tag=value pairs are alphabetized by "tag". Also, when encoding map[string]interface{} values -
-// complex elements, etc. - the key:value pairs are alphabetized by key so the resulting tags will appear sorted.
-func (mv Map) Xml(rootTag ...string) ([]byte, error) {
- m := map[string]interface{}(mv)
- var err error
- b := new(bytes.Buffer)
- p := new(pretty) // just a stub
-
- if len(m) == 1 && len(rootTag) == 0 {
- for key, value := range m {
- // if it an array, see if all values are map[string]interface{}
- // we force a new root tag if we'll end up with no key:value in the list
- // so: key:[string_val, bool:true] --> string_valtrue
- switch value.(type) {
- case []interface{}:
- for _, v := range value.([]interface{}) {
- switch v.(type) {
- case map[string]interface{}: // noop
- default: // anything else
- err = marshalMapToXmlIndent(false, b, DefaultRootTag, m, p)
- goto done
- }
- }
- }
- err = marshalMapToXmlIndent(false, b, key, value, p)
- }
- } else if len(rootTag) == 1 {
- err = marshalMapToXmlIndent(false, b, rootTag[0], m, p)
- } else {
- err = marshalMapToXmlIndent(false, b, DefaultRootTag, m, p)
- }
-done:
- if xmlCheckIsValid {
- d := xml.NewDecoder(bytes.NewReader(b.Bytes()))
- for {
- _, err = d.Token()
- if err == io.EOF {
- err = nil
- break
- } else if err != nil {
- return nil, err
- }
- }
- }
- return b.Bytes(), err
-}
-
-// The following implementation is provided only for symmetry with NewMapXmlReader[Raw]
-// The names will also provide a key for the number of return arguments.
-
-// Writes the Map as XML on the Writer.
-// See Xml() for encoding rules.
-func (mv Map) XmlWriter(xmlWriter io.Writer, rootTag ...string) error {
- x, err := mv.Xml(rootTag...)
- if err != nil {
- return err
- }
-
- _, err = xmlWriter.Write(x)
- return err
-}
-
-// Writes the Map as XML on the Writer. []byte is the raw XML that was written.
-// See Xml() for encoding rules.
-/*
-func (mv Map) XmlWriterRaw(xmlWriter io.Writer, rootTag ...string) ([]byte, error) {
- x, err := mv.Xml(rootTag...)
- if err != nil {
- return x, err
- }
-
- _, err = xmlWriter.Write(x)
- return x, err
-}
-*/
-
-// Writes the Map as pretty XML on the Writer.
-// See Xml() for encoding rules.
-func (mv Map) XmlIndentWriter(xmlWriter io.Writer, prefix, indent string, rootTag ...string) error {
- x, err := mv.XmlIndent(prefix, indent, rootTag...)
- if err != nil {
- return err
- }
-
- _, err = xmlWriter.Write(x)
- return err
-}
-
-// Writes the Map as pretty XML on the Writer. []byte is the raw XML that was written.
-// See Xml() for encoding rules.
-/*
-func (mv Map) XmlIndentWriterRaw(xmlWriter io.Writer, prefix, indent string, rootTag ...string) ([]byte, error) {
- x, err := mv.XmlIndent(prefix, indent, rootTag...)
- if err != nil {
- return x, err
- }
-
- _, err = xmlWriter.Write(x)
- return x, err
-}
-*/
-
-// -------------------- END: mv.Xml & mv.XmlWriter -------------------------------
-
-// -------------- Handle XML stream by processing Map value --------------------
-
-// Default poll delay to keep Handler from spinning on an open stream
-// like sitting on os.Stdin waiting for imput.
-var xhandlerPollInterval = time.Millisecond
-
-// Bulk process XML using handlers that process a Map value.
-// 'rdr' is an io.Reader for XML (stream)
-// 'mapHandler' is the Map processor. Return of 'false' stops io.Reader processing.
-// 'errHandler' is the error processor. Return of 'false' stops io.Reader processing and returns the error.
-// Note: mapHandler() and errHandler() calls are blocking, so reading and processing of messages is serialized.
-// This means that you can stop reading the file on error or after processing a particular message.
-// To have reading and handling run concurrently, pass argument to a go routine in handler and return 'true'.
-func HandleXmlReader(xmlReader io.Reader, mapHandler func(Map) bool, errHandler func(error) bool) error {
- var n int
- for {
- m, merr := NewMapXmlReader(xmlReader)
- n++
-
- // handle error condition with errhandler
- if merr != nil && merr != io.EOF {
- merr = fmt.Errorf("[xmlReader: %d] %s", n, merr.Error())
- if ok := errHandler(merr); !ok {
- // caused reader termination
- return merr
- }
- continue
- }
-
- // pass to maphandler
- if len(m) != 0 {
- if ok := mapHandler(m); !ok {
- break
- }
- } else if merr != io.EOF {
- time.Sleep(xhandlerPollInterval)
- }
-
- if merr == io.EOF {
- break
- }
- }
- return nil
-}
-
-// Bulk process XML using handlers that process a Map value and the raw XML.
-// 'rdr' is an io.Reader for XML (stream)
-// 'mapHandler' is the Map and raw XML - []byte - processor. Return of 'false' stops io.Reader processing.
-// 'errHandler' is the error and raw XML processor. Return of 'false' stops io.Reader processing and returns the error.
-// Note: mapHandler() and errHandler() calls are blocking, so reading and processing of messages is serialized.
-// This means that you can stop reading the file on error or after processing a particular message.
-// To have reading and handling run concurrently, pass argument(s) to a go routine in handler and return 'true'.
-// See NewMapXmlReaderRaw for comment on performance associated with retrieving raw XML from a Reader.
-func HandleXmlReaderRaw(xmlReader io.Reader, mapHandler func(Map, []byte) bool, errHandler func(error, []byte) bool) error {
- var n int
- for {
- m, raw, merr := NewMapXmlReaderRaw(xmlReader)
- n++
-
- // handle error condition with errhandler
- if merr != nil && merr != io.EOF {
- merr = fmt.Errorf("[xmlReader: %d] %s", n, merr.Error())
- if ok := errHandler(merr, raw); !ok {
- // caused reader termination
- return merr
- }
- continue
- }
-
- // pass to maphandler
- if len(m) != 0 {
- if ok := mapHandler(m, raw); !ok {
- break
- }
- } else if merr != io.EOF {
- time.Sleep(xhandlerPollInterval)
- }
-
- if merr == io.EOF {
- break
- }
- }
- return nil
-}
-
-// ----------------- END: Handle XML stream by processing Map value --------------
-
-// -------- a hack of io.TeeReader ... need one that's an io.ByteReader for xml.NewDecoder() ----------
-
-// This is a clone of io.TeeReader with the additional method t.ReadByte().
-// Thus, this TeeReader is also an io.ByteReader.
-// This is necessary because xml.NewDecoder uses a ByteReader not a Reader. It appears to have been written
-// with bufio.Reader or bytes.Reader in mind ... not a generic io.Reader, which doesn't have to have ReadByte()..
-// If NewDecoder is passed a Reader that does not satisfy ByteReader() it wraps the Reader with
-// bufio.NewReader and uses ReadByte rather than Read that runs the TeeReader pipe logic.
-
-type teeReader struct {
- r io.Reader
- w io.Writer
- b []byte
-}
-
-func myTeeReader(r io.Reader, w io.Writer) io.Reader {
- b := make([]byte, 1)
- return &teeReader{r, w, b}
-}
-
-// need for io.Reader - but we don't use it ...
-func (t *teeReader) Read(p []byte) (int, error) {
- return 0, nil
-}
-
-func (t *teeReader) ReadByte() (byte, error) {
- n, err := t.r.Read(t.b)
- if n > 0 {
- if _, err := t.w.Write(t.b[:1]); err != nil {
- return t.b[0], err
- }
- }
- return t.b[0], err
-}
-
-// For use with NewMapXmlReader & NewMapXmlSeqReader.
-type byteReader struct {
- r io.Reader
- b []byte
-}
-
-func myByteReader(r io.Reader) io.Reader {
- b := make([]byte, 1)
- return &byteReader{r, b}
-}
-
-// Need for io.Reader interface ...
-// Needed if reading a malformed http.Request.Body - issue #38.
-func (b *byteReader) Read(p []byte) (int, error) {
- return b.r.Read(p)
-}
-
-func (b *byteReader) ReadByte() (byte, error) {
- _, err := b.r.Read(b.b)
- if len(b.b) > 0 {
- // issue #38
- return b.b[0], err
- }
- var c byte
- return c, err
-}
-
-// ----------------------- END: io.TeeReader hack -----------------------------------
-
-// ---------------------- XmlIndent - from j2x package ----------------------------
-
-// Encode a map[string]interface{} as a pretty XML string.
-// See Xml for encoding rules.
-func (mv Map) XmlIndent(prefix, indent string, rootTag ...string) ([]byte, error) {
- m := map[string]interface{}(mv)
-
- var err error
- b := new(bytes.Buffer)
- p := new(pretty)
- p.indent = indent
- p.padding = prefix
-
- if len(m) == 1 && len(rootTag) == 0 {
- // this can extract the key for the single map element
- // use it if it isn't a key for a list
- for key, value := range m {
- if _, ok := value.([]interface{}); ok {
- err = marshalMapToXmlIndent(true, b, DefaultRootTag, m, p)
- } else {
- err = marshalMapToXmlIndent(true, b, key, value, p)
- }
- }
- } else if len(rootTag) == 1 {
- err = marshalMapToXmlIndent(true, b, rootTag[0], m, p)
- } else {
- err = marshalMapToXmlIndent(true, b, DefaultRootTag, m, p)
- }
- if xmlCheckIsValid {
- d := xml.NewDecoder(bytes.NewReader(b.Bytes()))
- for {
- _, err = d.Token()
- if err == io.EOF {
- err = nil
- break
- } else if err != nil {
- return nil, err
- }
- }
- }
- return b.Bytes(), err
-}
-
-type pretty struct {
- indent string
- cnt int
- padding string
- mapDepth int
- start int
-}
-
-func (p *pretty) Indent() {
- p.padding += p.indent
- p.cnt++
-}
-
-func (p *pretty) Outdent() {
- if p.cnt > 0 {
- p.padding = p.padding[:len(p.padding)-len(p.indent)]
- p.cnt--
- }
-}
-
-// where the work actually happens
-// returns an error if an attribute is not atomic
-// NOTE: 01may20 - replaces mapToXmlIndent(); uses bytes.Buffer instead for string appends.
-func marshalMapToXmlIndent(doIndent bool, b *bytes.Buffer, key string, value interface{}, pp *pretty) error {
- var err error
- var endTag bool
- var isSimple bool
- var elen int
- p := &pretty{pp.indent, pp.cnt, pp.padding, pp.mapDepth, pp.start}
-
- // per issue #48, 18apr18 - try and coerce maps to map[string]interface{}
- // Don't need for mapToXmlSeqIndent, since maps there are decoded by NewMapXmlSeq().
- if reflect.ValueOf(value).Kind() == reflect.Map {
- switch value.(type) {
- case map[string]interface{}:
- default:
- val := make(map[string]interface{})
- vv := reflect.ValueOf(value)
- keys := vv.MapKeys()
- for _, k := range keys {
- val[fmt.Sprint(k)] = vv.MapIndex(k).Interface()
- }
- value = val
- }
- }
-
- // 14jul20. The following block of code has become something of a catch all for odd stuff
- // that might be passed in as a result of casting an arbitrary map[] to an mxj.Map
- // value and then call m.Xml or m.XmlIndent. See issue #71 (and #73) for such edge cases.
- switch value.(type) {
- // these types are handled during encoding
- case map[string]interface{}, []byte, string, float64, bool, int, int32, int64, float32, json.Number:
- case []map[string]interface{}, []string, []float64, []bool, []int, []int32, []int64, []float32, []json.Number:
- case []interface{}:
- case nil:
- value = ""
- default:
- // see if value is a struct, if so marshal using encoding/xml package
- if reflect.ValueOf(value).Kind() == reflect.Struct {
- if v, err := xml.Marshal(value); err != nil {
- return err
- } else {
- value = string(v)
- }
- } else {
- // coerce eveything else into a string value
- value = fmt.Sprint(value)
- }
- }
-
- // start the XML tag with required indentaton and padding
- if doIndent {
- switch value.(type) {
- case []interface{}, []string:
- // list processing handles indentation for all elements
- default:
- if _, err = b.WriteString(p.padding); err != nil {
- return err
- }
- }
- }
- switch value.(type) {
- case []interface{}:
- default:
- if _, err = b.WriteString(`<` + key); err != nil {
- return err
- }
- }
-
- switch value.(type) {
- case map[string]interface{}:
- vv := value.(map[string]interface{})
- lenvv := len(vv)
- // scan out attributes - attribute keys have prepended attrPrefix
- attrlist := make([][2]string, len(vv))
- var n int
- var ss string
- for k, v := range vv {
- if lenAttrPrefix > 0 && lenAttrPrefix < len(k) && k[:lenAttrPrefix] == attrPrefix {
- switch v.(type) {
- case string:
- if xmlEscapeChars {
- ss = escapeChars(v.(string))
- } else {
- ss = v.(string)
- }
- attrlist[n][0] = k[lenAttrPrefix:]
- attrlist[n][1] = ss
- case float64, bool, int, int32, int64, float32, json.Number:
- attrlist[n][0] = k[lenAttrPrefix:]
- attrlist[n][1] = fmt.Sprintf("%v", v)
- case []byte:
- if xmlEscapeChars {
- ss = escapeChars(string(v.([]byte)))
- } else {
- ss = string(v.([]byte))
- }
- attrlist[n][0] = k[lenAttrPrefix:]
- attrlist[n][1] = ss
- default:
- return fmt.Errorf("invalid attribute value for: %s:<%T>", k, v)
- }
- n++
- }
- }
- if n > 0 {
- attrlist = attrlist[:n]
- sort.Sort(attrList(attrlist))
- for _, v := range attrlist {
- if _, err = b.WriteString(` ` + v[0] + `="` + v[1] + `"`); err != nil {
- return err
- }
- }
- }
- // only attributes?
- if n == lenvv {
- if useGoXmlEmptyElemSyntax {
- if _, err = b.WriteString(`` + key + ">"); err != nil {
- return err
- }
- } else {
- if _, err = b.WriteString(`/>`); err != nil {
- return err
- }
- }
- break
- }
-
- // simple element? Note: '#text" is an invalid XML tag.
- isComplex := false
- if v, ok := vv[textK]; ok && n+1 == lenvv {
- // just the value and attributes
- switch v.(type) {
- case string:
- if xmlEscapeChars {
- v = escapeChars(v.(string))
- } else {
- v = v.(string)
- }
- case []byte:
- if xmlEscapeChars {
- v = escapeChars(string(v.([]byte)))
- } else {
- v = string(v.([]byte))
- }
- }
- if _, err = b.WriteString(">" + fmt.Sprintf("%v", v)); err != nil {
- return err
- }
- endTag = true
- elen = 1
- isSimple = true
- break
- } else if ok {
- // need to handle when there are subelements in addition to the simple element value
- // issue #90
- switch v.(type) {
- case string:
- if xmlEscapeChars {
- v = escapeChars(v.(string))
- } else {
- v = v.(string)
- }
- case []byte:
- if xmlEscapeChars {
- v = escapeChars(string(v.([]byte)))
- } else {
- v = string(v.([]byte))
- }
- }
- if _, err = b.WriteString(">" + fmt.Sprintf("%v", v)); err != nil {
- return err
- }
- isComplex = true
- }
-
- // close tag with possible attributes
- if !isComplex {
- if _, err = b.WriteString(">"); err != nil {
- return err
- }
- }
- if doIndent {
- // *s += "\n"
- if _, err = b.WriteString("\n"); err != nil {
- return err
- }
- }
- // something more complex
- p.mapDepth++
- // extract the map k:v pairs and sort on key
- elemlist := make([][2]interface{}, len(vv))
- n = 0
- for k, v := range vv {
- if k == textK {
- // simple element handled above
- continue
- }
- if lenAttrPrefix > 0 && lenAttrPrefix < len(k) && k[:lenAttrPrefix] == attrPrefix {
- continue
- }
- elemlist[n][0] = k
- elemlist[n][1] = v
- n++
- }
- elemlist = elemlist[:n]
- sort.Sort(elemList(elemlist))
- var i int
- for _, v := range elemlist {
- switch v[1].(type) {
- case []interface{}:
- default:
- if i == 0 && doIndent {
- p.Indent()
- }
- }
- i++
- if err := marshalMapToXmlIndent(doIndent, b, v[0].(string), v[1], p); err != nil {
- return err
- }
- switch v[1].(type) {
- case []interface{}: // handled in []interface{} case
- default:
- if doIndent {
- p.Outdent()
- }
- }
- i--
- }
- p.mapDepth--
- endTag = true
- elen = 1 // we do have some content ...
- case []interface{}:
- // special case - found during implementing Issue #23
- if len(value.([]interface{})) == 0 {
- if doIndent {
- if _, err = b.WriteString(p.padding + p.indent); err != nil {
- return err
- }
- }
- if _, err = b.WriteString("<" + key); err != nil {
- return err
- }
- elen = 0
- endTag = true
- break
- }
- for _, v := range value.([]interface{}) {
- if doIndent {
- p.Indent()
- }
- if err := marshalMapToXmlIndent(doIndent, b, key, v, p); err != nil {
- return err
- }
- if doIndent {
- p.Outdent()
- }
- }
- return nil
- case []string:
- // This was added by https://github.com/slotix ... not a type that
- // would be encountered if mv generated from NewMapXml, NewMapJson.
- // Could be encountered in AnyXml(), so we'll let it stay, though
- // it should be merged with case []interface{}, above.
- //quick fix for []string type
- //[]string should be treated exaclty as []interface{}
- if len(value.([]string)) == 0 {
- if doIndent {
- if _, err = b.WriteString(p.padding + p.indent); err != nil {
- return err
- }
- }
- if _, err = b.WriteString("<" + key); err != nil {
- return err
- }
- elen = 0
- endTag = true
- break
- }
- for _, v := range value.([]string) {
- if doIndent {
- p.Indent()
- }
- if err := marshalMapToXmlIndent(doIndent, b, key, v, p); err != nil {
- return err
- }
- if doIndent {
- p.Outdent()
- }
- }
- return nil
- case nil:
- // terminate the tag
- if doIndent {
- // *s += p.padding
- if _, err = b.WriteString(p.padding); err != nil {
- return err
- }
- }
- if _, err = b.WriteString("<" + key); err != nil {
- return err
- }
- endTag, isSimple = true, true
- break
- default: // handle anything - even goofy stuff
- elen = 0
- switch value.(type) {
- case string:
- v := value.(string)
- if xmlEscapeChars {
- v = escapeChars(v)
- }
- elen = len(v)
- if elen > 0 {
- // *s += ">" + v
- if _, err = b.WriteString(">" + v); err != nil {
- return err
- }
- }
- case float64, bool, int, int32, int64, float32, json.Number:
- v := fmt.Sprintf("%v", value)
- elen = len(v) // always > 0
- if _, err = b.WriteString(">" + v); err != nil {
- return err
- }
- case []byte: // NOTE: byte is just an alias for uint8
- // similar to how xml.Marshal handles []byte structure members
- v := string(value.([]byte))
- if xmlEscapeChars {
- v = escapeChars(v)
- }
- elen = len(v)
- if elen > 0 {
- // *s += ">" + v
- if _, err = b.WriteString(">" + v); err != nil {
- return err
- }
- }
- default:
- if _, err = b.WriteString(">"); err != nil {
- return err
- }
- var v []byte
- var err error
- if doIndent {
- v, err = xml.MarshalIndent(value, p.padding, p.indent)
- } else {
- v, err = xml.Marshal(value)
- }
- if err != nil {
- if _, err = b.WriteString(">UNKNOWN"); err != nil {
- return err
- }
- } else {
- elen = len(v)
- if elen > 0 {
- if _, err = b.Write(v); err != nil {
- return err
- }
- }
- }
- }
- isSimple = true
- endTag = true
- }
- if endTag {
- if doIndent {
- if !isSimple {
- if _, err = b.WriteString(p.padding); err != nil {
- return err
- }
- }
- }
- if elen > 0 || useGoXmlEmptyElemSyntax {
- if elen == 0 {
- if _, err = b.WriteString(">"); err != nil {
- return err
- }
- }
- if _, err = b.WriteString(`` + key + ">"); err != nil {
- return err
- }
- } else {
- if _, err = b.WriteString(`/>`); err != nil {
- return err
- }
- }
- }
- if doIndent {
- if p.cnt > p.start {
- if _, err = b.WriteString("\n"); err != nil {
- return err
- }
- }
- p.Outdent()
- }
-
- return nil
-}
-
-// ============================ sort interface implementation =================
-
-type attrList [][2]string
-
-func (a attrList) Len() int {
- return len(a)
-}
-
-func (a attrList) Swap(i, j int) {
- a[i], a[j] = a[j], a[i]
-}
-
-func (a attrList) Less(i, j int) bool {
- return a[i][0] <= a[j][0]
-}
-
-type elemList [][2]interface{}
-
-func (e elemList) Len() int {
- return len(e)
-}
-
-func (e elemList) Swap(i, j int) {
- e[i], e[j] = e[j], e[i]
-}
-
-func (e elemList) Less(i, j int) bool {
- return e[i][0].(string) <= e[j][0].(string)
-}
diff --git a/vendor/github.com/clbanning/mxj/v2/xmlseq.go b/vendor/github.com/clbanning/mxj/v2/xmlseq.go
deleted file mode 100644
index 9732dec..0000000
--- a/vendor/github.com/clbanning/mxj/v2/xmlseq.go
+++ /dev/null
@@ -1,902 +0,0 @@
-// Copyright 2012-2016, 2019 Charles Banning. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file
-
-// xmlseq.go - version of xml.go with sequence # injection on Decoding and sorting on Encoding.
-// Also, handles comments, directives and process instructions.
-
-package mxj
-
-import (
- "bytes"
- "encoding/xml"
- "errors"
- "fmt"
- "io"
- "regexp"
- "sort"
- "strings"
-)
-
-// MapSeq is like Map but contains seqencing indices to allow recovering the original order of
-// the XML elements when the map[string]interface{} is marshaled. Element attributes are
-// stored as a map["#attr"]map[]map[string]interface{}{"#text":"", "#seq":}
-// value instead of denoting the keys with a prefix character. Also, comments, directives and
-// process instructions are preserved.
-type MapSeq map[string]interface{}
-
-// NoRoot is returned by NewXmlSeq, etc., when a comment, directive or procinstr element is parsed
-// in the XML data stream and the element is not contained in an XML object with a root element.
-var NoRoot = errors.New("no root key")
-var NO_ROOT = NoRoot // maintain backwards compatibility
-
-// ------------------- NewMapXmlSeq & NewMapXmlSeqReader ... -------------------------
-
-// NewMapXmlSeq converts a XML doc into a MapSeq value with elements id'd with decoding sequence key represented
-// as map["#seq"].
-// If the optional argument 'cast' is 'true', then values will be converted to boolean or float64 if possible.
-// NOTE: "#seq" key/value pairs are removed on encoding with msv.Xml() / msv.XmlIndent().
-// • attributes are a map - map["#attr"]map["attr_key"]map[string]interface{}{"#text":, "#seq":}
-// • all simple elements are decoded as map["#text"]interface{} with a "#seq" k:v pair, as well.
-// • lists always decode as map["list_tag"][]map[string]interface{} where the array elements are maps that
-// include a "#seq" k:v pair based on sequence they are decoded. Thus, XML like:
-//
-// value 1
-// value 2
-// value 3
-//
-// is decoded as:
-// doc :
-// ltag :[[]interface{}]
-// [item: 0]
-// #seq :[int] 0
-// #text :[string] value 1
-// [item: 1]
-// #seq :[int] 2
-// #text :[string] value 3
-// newtag :
-// #seq :[int] 1
-// #text :[string] value 2
-// It will encode in proper sequence even though the MapSeq representation merges all "ltag" elements in an array.
-// • comments - "" - are decoded as map["#comment"]map["#text"]"cmnt_text" with a "#seq" k:v pair.
-// • directives - "" - are decoded as map["#directive"]map[#text"]"directive_text" with a "#seq" k:v pair.
-// • process instructions - "" - are decoded as map["#procinst"]interface{} where the #procinst value
-// is of map[string]interface{} type with the following keys: #target, #inst, and #seq.
-// • comments, directives, and procinsts that are NOT part of a document with a root key will be returned as
-// map[string]interface{} and the error value 'NoRoot'.
-// • note: ": tag preserve the
-// ":" notation rather than stripping it as with NewMapXml().
-// 2. Attribute keys for name space prefix declarations preserve "xmlns:" notation.
-//
-// ERRORS:
-// 1. If a NoRoot error, "no root key," is returned, check the initial map key for a "#comment",
-// "#directive" or #procinst" key.
-// 2. Unmarshaling an XML doc that is formatted using the whitespace character, " ", will error, since
-// Decoder.RawToken treats such occurances as significant. See NewMapFormattedXmlSeq().
-func NewMapXmlSeq(xmlVal []byte, cast ...bool) (MapSeq, error) {
- var r bool
- if len(cast) == 1 {
- r = cast[0]
- }
- return xmlSeqToMap(xmlVal, r)
-}
-
-// NewMapFormattedXmlSeq performs the same as NewMapXmlSeq but is useful for processing XML objects that
-// are formatted using the whitespace character, " ". (The stdlib xml.Decoder, by default, treats all
-// whitespace as significant; Decoder.Token() and Decoder.RawToken() will return strings of one or more
-// whitespace characters and without alphanumeric or punctuation characters as xml.CharData values.)
-//
-// If you're processing such XML, then this will convert all occurrences of whitespace-only strings
-// into an empty string, "", prior to parsing the XML - irrespective of whether the occurrence is
-// formatting or is a actual element value.
-func NewMapFormattedXmlSeq(xmlVal []byte, cast ...bool) (MapSeq, error) {
- var c bool
- if len(cast) == 1 {
- c = cast[0]
- }
-
- // Per PR #104 - clean out formatting characters so they don't show up in Decoder.RawToken() stream.
- // NOTE: Also replaces element values that are solely comprised of formatting/whitespace characters
- // with empty string, "".
- r := regexp.MustCompile(`>[\n\t\r ]*<`)
- xmlVal = r.ReplaceAll(xmlVal, []byte("><"))
- return xmlSeqToMap(xmlVal, c)
-}
-
-// NewMpaXmlSeqReader returns next XML doc from an io.Reader as a MapSeq value.
-// NOTES:
-// 1. The 'xmlReader' will be parsed looking for an xml.StartElement, xml.Comment, etc., so BOM and other
-// extraneous xml.CharData will be ignored unless io.EOF is reached first.
-// 2. CoerceKeysToLower() is NOT recognized, since the intent here is to eventually call m.XmlSeq() to
-// re-encode the message in its original structure.
-// 3. If CoerceKeysToSnakeCase() has been called, then all key values will be converted to snake case.
-//
-// ERRORS:
-// 1. If a NoRoot error, "no root key," is returned, check the initial map key for a "#comment",
-// "#directive" or #procinst" key.
-func NewMapXmlSeqReader(xmlReader io.Reader, cast ...bool) (MapSeq, error) {
- var r bool
- if len(cast) == 1 {
- r = cast[0]
- }
-
- // We need to put an *os.File reader in a ByteReader or the xml.NewDecoder
- // will wrap it in a bufio.Reader and seek on the file beyond where the
- // xml.Decoder parses!
- if _, ok := xmlReader.(io.ByteReader); !ok {
- xmlReader = myByteReader(xmlReader) // see code at EOF
- }
-
- // build the map
- return xmlSeqReaderToMap(xmlReader, r)
-}
-
-// NewMapXmlSeqReaderRaw returns the next XML doc from an io.Reader as a MapSeq value.
-// Returns MapSeq value, slice with the raw XML, and any error.
-// NOTES:
-// 1. Due to the implementation of xml.Decoder, the raw XML off the reader is buffered to []byte
-// using a ByteReader. If the io.Reader is an os.File, there may be significant performance impact.
-// See the examples - getmetrics1.go through getmetrics4.go - for comparative use cases on a large
-// data set. If the io.Reader is wrapping a []byte value in-memory, however, such as http.Request.Body
-// you CAN use it to efficiently unmarshal a XML doc and retrieve the raw XML in a single call.
-// 2. The 'raw' return value may be larger than the XML text value.
-// 3. The 'xmlReader' will be parsed looking for an xml.StartElement, xml.Comment, etc., so BOM and other
-// extraneous xml.CharData will be ignored unless io.EOF is reached first.
-// 4. CoerceKeysToLower() is NOT recognized, since the intent here is to eventually call m.XmlSeq() to
-// re-encode the message in its original structure.
-// 5. If CoerceKeysToSnakeCase() has been called, then all key values will be converted to snake case.
-//
-// ERRORS:
-// 1. If a NoRoot error, "no root key," is returned, check if the initial map key is "#comment",
-// "#directive" or #procinst" key.
-func NewMapXmlSeqReaderRaw(xmlReader io.Reader, cast ...bool) (MapSeq, []byte, error) {
- var r bool
- if len(cast) == 1 {
- r = cast[0]
- }
- // create TeeReader so we can retrieve raw XML
- buf := make([]byte, 0)
- wb := bytes.NewBuffer(buf)
- trdr := myTeeReader(xmlReader, wb)
-
- m, err := xmlSeqReaderToMap(trdr, r)
-
- // retrieve the raw XML that was decoded
- b := wb.Bytes()
-
- // err may be NoRoot
- return m, b, err
-}
-
-// xmlSeqReaderToMap() - parse a XML io.Reader to a map[string]interface{} value
-func xmlSeqReaderToMap(rdr io.Reader, r bool) (map[string]interface{}, error) {
- // parse the Reader
- p := xml.NewDecoder(rdr)
- if CustomDecoder != nil {
- useCustomDecoder(p)
- } else {
- p.CharsetReader = XmlCharsetReader
- }
- return xmlSeqToMapParser("", nil, p, r)
-}
-
-// xmlSeqToMap - convert a XML doc into map[string]interface{} value
-func xmlSeqToMap(doc []byte, r bool) (map[string]interface{}, error) {
- b := bytes.NewReader(doc)
- p := xml.NewDecoder(b)
- if CustomDecoder != nil {
- useCustomDecoder(p)
- } else {
- p.CharsetReader = XmlCharsetReader
- }
- return xmlSeqToMapParser("", nil, p, r)
-}
-
-// ===================================== where the work happens =============================
-
-// xmlSeqToMapParser - load a 'clean' XML doc into a map[string]interface{} directly.
-// Add #seq tag value for each element decoded - to be used for Encoding later.
-func xmlSeqToMapParser(skey string, a []xml.Attr, p *xml.Decoder, r bool) (map[string]interface{}, error) {
- if snakeCaseKeys {
- skey = strings.Replace(skey, "-", "_", -1)
- }
-
- // NOTE: all attributes and sub-elements parsed into 'na', 'na' is returned as value for 'skey' in 'n'.
- var n, na map[string]interface{}
- var seq int // for including seq num when decoding
-
- // Allocate maps and load attributes, if any.
- // NOTE: on entry from NewMapXml(), etc., skey=="", and we fall through
- // to get StartElement then recurse with skey==xml.StartElement.Name.Local
- // where we begin allocating map[string]interface{} values 'n' and 'na'.
- if skey != "" {
- // 'n' only needs one slot - save call to runtime•hashGrow()
- // 'na' we don't know
- n = make(map[string]interface{}, 1)
- na = make(map[string]interface{})
- if len(a) > 0 {
- // xml.Attr is decoded into: map["#attr"]map[]interface{}
- // where interface{} is map[string]interface{}{"#text":, "#seq":}
- aa := make(map[string]interface{}, len(a))
- for i, v := range a {
- if snakeCaseKeys {
- v.Name.Local = strings.Replace(v.Name.Local, "-", "_", -1)
- }
- if xmlEscapeCharsDecoder { // per issue#84
- v.Value = escapeChars(v.Value)
- }
- if len(v.Name.Space) > 0 {
- aa[v.Name.Space+`:`+v.Name.Local] = map[string]interface{}{textK: cast(v.Value, r, ""), seqK: i}
- } else {
- aa[v.Name.Local] = map[string]interface{}{textK: cast(v.Value, r, ""), seqK: i}
- }
- }
- na[attrK] = aa
- }
- }
-
- // Return XMPP message.
- if handleXMPPStreamTag && skey == "stream:stream" {
- n[skey] = na
- return n, nil
- }
-
- for {
- t, err := p.RawToken()
- if err != nil {
- if err != io.EOF {
- return nil, errors.New("xml.Decoder.Token() - " + err.Error())
- }
- return nil, err
- }
- switch t.(type) {
- case xml.StartElement:
- tt := t.(xml.StartElement)
-
- // First call to xmlSeqToMapParser() doesn't pass xml.StartElement - the map key.
- // So when the loop is first entered, the first token is the root tag along
- // with any attributes, which we process here.
- //
- // Subsequent calls to xmlSeqToMapParser() will pass in tag+attributes for
- // processing before getting the next token which is the element value,
- // which is done above.
- if skey == "" {
- if len(tt.Name.Space) > 0 {
- return xmlSeqToMapParser(tt.Name.Space+`:`+tt.Name.Local, tt.Attr, p, r)
- } else {
- return xmlSeqToMapParser(tt.Name.Local, tt.Attr, p, r)
- }
- }
-
- // If not initializing the map, parse the element.
- // len(nn) == 1, necessarily - it is just an 'n'.
- var nn map[string]interface{}
- if len(tt.Name.Space) > 0 {
- nn, err = xmlSeqToMapParser(tt.Name.Space+`:`+tt.Name.Local, tt.Attr, p, r)
- } else {
- nn, err = xmlSeqToMapParser(tt.Name.Local, tt.Attr, p, r)
- }
- if err != nil {
- return nil, err
- }
-
- // The nn map[string]interface{} value is a na[nn_key] value.
- // We need to see if nn_key already exists - means we're parsing a list.
- // This may require converting na[nn_key] value into []interface{} type.
- // First, extract the key:val for the map - it's a singleton.
- var key string
- var val interface{}
- for key, val = range nn {
- break
- }
-
- // add "#seq" k:v pair -
- // Sequence number included even in list elements - this should allow us
- // to properly resequence even something goofy like:
- // item 1
- // item 2
- // item 3
- // where all the "list" subelements are decoded into an array.
- switch val.(type) {
- case map[string]interface{}:
- val.(map[string]interface{})[seqK] = seq
- seq++
- case interface{}: // a non-nil simple element: string, float64, bool
- v := map[string]interface{}{textK: val, seqK: seq}
- seq++
- val = v
- }
-
- // 'na' holding sub-elements of n.
- // See if 'key' already exists.
- // If 'key' exists, then this is a list, if not just add key:val to na.
- if v, ok := na[key]; ok {
- var a []interface{}
- switch v.(type) {
- case []interface{}:
- a = v.([]interface{})
- default: // anything else - note: v.(type) != nil
- a = []interface{}{v}
- }
- a = append(a, val)
- na[key] = a
- } else {
- na[key] = val // save it as a singleton
- }
- case xml.EndElement:
- if skey != "" {
- tt := t.(xml.EndElement)
- if snakeCaseKeys {
- tt.Name.Local = strings.Replace(tt.Name.Local, "-", "_", -1)
- }
- var name string
- if len(tt.Name.Space) > 0 {
- name = tt.Name.Space + `:` + tt.Name.Local
- } else {
- name = tt.Name.Local
- }
- if skey != name {
- return nil, fmt.Errorf("element %s not properly terminated, got %s at #%d",
- skey, name, p.InputOffset())
- }
- }
- // len(n) > 0 if this is a simple element w/o xml.Attrs - see xml.CharData case.
- if len(n) == 0 {
- // If len(na)==0 we have an empty element == "";
- // it has no xml.Attr nor xml.CharData.
- // Empty element content will be map["etag"]map["#text"]""
- // after #seq injection - map["etag"]map["#seq"]seq - after return.
- if len(na) > 0 {
- n[skey] = na
- } else {
- n[skey] = "" // empty element
- }
- }
- return n, nil
- case xml.CharData:
- // clean up possible noise
- tt := strings.Trim(string(t.(xml.CharData)), trimRunes)
- if xmlEscapeCharsDecoder { // issue#84
- tt = escapeChars(tt)
- }
- if skey == "" {
- // per Adrian (http://www.adrianlungu.com/) catch stray text
- // in decoder stream -
- // https://github.com/clbanning/mxj/pull/14#issuecomment-182816374
- // NOTE: CharSetReader must be set to non-UTF-8 CharSet or you'll get
- // a p.Token() decoding error when the BOM is UTF-16 or UTF-32.
- continue
- }
- if len(tt) > 0 {
- // every simple element is a #text and has #seq associated with it
- na[textK] = cast(tt, r, "")
- na[seqK] = seq
- seq++
- }
- case xml.Comment:
- if n == nil { // no root 'key'
- n = map[string]interface{}{commentK: string(t.(xml.Comment))}
- return n, NoRoot
- }
- cm := make(map[string]interface{}, 2)
- cm[textK] = string(t.(xml.Comment))
- cm[seqK] = seq
- seq++
- na[commentK] = cm
- case xml.Directive:
- if n == nil { // no root 'key'
- n = map[string]interface{}{directiveK: string(t.(xml.Directive))}
- return n, NoRoot
- }
- dm := make(map[string]interface{}, 2)
- dm[textK] = string(t.(xml.Directive))
- dm[seqK] = seq
- seq++
- na[directiveK] = dm
- case xml.ProcInst:
- if n == nil {
- na = map[string]interface{}{targetK: t.(xml.ProcInst).Target, instK: string(t.(xml.ProcInst).Inst)}
- n = map[string]interface{}{procinstK: na}
- return n, NoRoot
- }
- pm := make(map[string]interface{}, 3)
- pm[targetK] = t.(xml.ProcInst).Target
- pm[instK] = string(t.(xml.ProcInst).Inst)
- pm[seqK] = seq
- seq++
- na[procinstK] = pm
- default:
- // noop - shouldn't ever get here, now, since we handle all token types
- }
- }
-}
-
-// ------------------ END: NewMapXml & NewMapXmlReader -------------------------
-
-// --------------------- mv.XmlSeq & mv.XmlSeqWriter -------------------------
-
-// Xml encodes a MapSeq as XML with elements sorted on #seq. The companion of NewMapXmlSeq().
-// The following rules apply.
-// - The "#seq" key value is used to seqence the subelements or attributes only.
-// - The "#attr" map key identifies the map of attribute map[string]interface{} values with "#text" key.
-// - The "#comment" map key identifies a comment in the value "#text" map entry - .
-// - The "#directive" map key identifies a directive in the value "#text" map entry - .
-// - The "#procinst" map key identifies a process instruction in the value "#target" and "#inst"
-// map entries - .
-// - Value type encoding:
-// > string, bool, float64, int, int32, int64, float32: per "%v" formating
-// > []bool, []uint8: by casting to string
-// > structures, etc.: handed to xml.Marshal() - if there is an error, the element
-// value is "UNKNOWN"
-// - Elements with only attribute values or are null are terminated using "/>" unless XmlGoEmptyElemSystax() called.
-// - If len(mv) == 1 and no rootTag is provided, then the map key is used as the root tag, possible.
-// Thus, `{ "key":"value" }` encodes as "value".
-func (mv MapSeq) Xml(rootTag ...string) ([]byte, error) {
- m := map[string]interface{}(mv)
- var err error
- s := new(string)
- p := new(pretty) // just a stub
-
- if len(m) == 1 && len(rootTag) == 0 {
- for key, value := range m {
- // if it's an array, see if all values are map[string]interface{}
- // we force a new root tag if we'll end up with no key:value in the list
- // so: key:[string_val, bool:true] --> string_valtrue
- switch value.(type) {
- case []interface{}:
- for _, v := range value.([]interface{}) {
- switch v.(type) {
- case map[string]interface{}: // noop
- default: // anything else
- err = mapToXmlSeqIndent(false, s, DefaultRootTag, m, p)
- goto done
- }
- }
- }
- err = mapToXmlSeqIndent(false, s, key, value, p)
- }
- } else if len(rootTag) == 1 {
- err = mapToXmlSeqIndent(false, s, rootTag[0], m, p)
- } else {
- err = mapToXmlSeqIndent(false, s, DefaultRootTag, m, p)
- }
-done:
- if xmlCheckIsValid {
- d := xml.NewDecoder(bytes.NewReader([]byte(*s)))
- for {
- _, err = d.Token()
- if err == io.EOF {
- err = nil
- break
- } else if err != nil {
- return nil, err
- }
- }
- }
- return []byte(*s), err
-}
-
-// The following implementation is provided only for symmetry with NewMapXmlReader[Raw]
-// The names will also provide a key for the number of return arguments.
-
-// XmlWriter Writes the MapSeq value as XML on the Writer.
-// See MapSeq.Xml() for encoding rules.
-func (mv MapSeq) XmlWriter(xmlWriter io.Writer, rootTag ...string) error {
- x, err := mv.Xml(rootTag...)
- if err != nil {
- return err
- }
-
- _, err = xmlWriter.Write(x)
- return err
-}
-
-// XmlWriteRaw writes the MapSeq value as XML on the Writer. []byte is the raw XML that was written.
-// See Map.XmlSeq() for encoding rules.
-/*
-func (mv MapSeq) XmlWriterRaw(xmlWriter io.Writer, rootTag ...string) ([]byte, error) {
- x, err := mv.Xml(rootTag...)
- if err != nil {
- return x, err
- }
-
- _, err = xmlWriter.Write(x)
- return x, err
-}
-*/
-
-// XmlIndentWriter writes the MapSeq value as pretty XML on the Writer.
-// See MapSeq.Xml() for encoding rules.
-func (mv MapSeq) XmlIndentWriter(xmlWriter io.Writer, prefix, indent string, rootTag ...string) error {
- x, err := mv.XmlIndent(prefix, indent, rootTag...)
- if err != nil {
- return err
- }
-
- _, err = xmlWriter.Write(x)
- return err
-}
-
-// XmlIndentWriterRaw writes the Map as pretty XML on the Writer. []byte is the raw XML that was written.
-// See Map.XmlSeq() for encoding rules.
-/*
-func (mv MapSeq) XmlIndentWriterRaw(xmlWriter io.Writer, prefix, indent string, rootTag ...string) ([]byte, error) {
- x, err := mv.XmlSeqIndent(prefix, indent, rootTag...)
- if err != nil {
- return x, err
- }
-
- _, err = xmlWriter.Write(x)
- return x, err
-}
-*/
-
-// -------------------- END: mv.Xml & mv.XmlWriter -------------------------------
-
-// ---------------------- XmlSeqIndent ----------------------------
-
-// XmlIndent encodes a map[string]interface{} as a pretty XML string.
-// See MapSeq.XmlSeq() for encoding rules.
-func (mv MapSeq) XmlIndent(prefix, indent string, rootTag ...string) ([]byte, error) {
- m := map[string]interface{}(mv)
-
- var err error
- s := new(string)
- p := new(pretty)
- p.indent = indent
- p.padding = prefix
-
- if len(m) == 1 && len(rootTag) == 0 {
- // this can extract the key for the single map element
- // use it if it isn't a key for a list
- for key, value := range m {
- if _, ok := value.([]interface{}); ok {
- err = mapToXmlSeqIndent(true, s, DefaultRootTag, m, p)
- } else {
- err = mapToXmlSeqIndent(true, s, key, value, p)
- }
- }
- } else if len(rootTag) == 1 {
- err = mapToXmlSeqIndent(true, s, rootTag[0], m, p)
- } else {
- err = mapToXmlSeqIndent(true, s, DefaultRootTag, m, p)
- }
- if xmlCheckIsValid {
- if _, err = NewMapXml([]byte(*s)); err != nil {
- return nil, err
- }
- d := xml.NewDecoder(bytes.NewReader([]byte(*s)))
- for {
- _, err = d.Token()
- if err == io.EOF {
- err = nil
- break
- } else if err != nil {
- return nil, err
- }
- }
- }
- return []byte(*s), err
-}
-
-// where the work actually happens
-// returns an error if an attribute is not atomic
-func mapToXmlSeqIndent(doIndent bool, s *string, key string, value interface{}, pp *pretty) error {
- var endTag bool
- var isSimple bool
- var noEndTag bool
- var elen int
- var ss string
- p := &pretty{pp.indent, pp.cnt, pp.padding, pp.mapDepth, pp.start}
-
- switch value.(type) {
- case map[string]interface{}, []byte, string, float64, bool, int, int32, int64, float32:
- if doIndent {
- *s += p.padding
- }
- if key != commentK && key != directiveK && key != procinstK {
- *s += `<` + key
- }
- }
- switch value.(type) {
- case map[string]interface{}:
- val := value.(map[string]interface{})
-
- if key == commentK {
- *s += ``
- noEndTag = true
- break
- }
-
- if key == directiveK {
- *s += ``
- noEndTag = true
- break
- }
-
- if key == procinstK {
- *s += `` + val[targetK].(string) + ` ` + val[instK].(string) + `?>`
- noEndTag = true
- break
- }
-
- haveAttrs := false
- // process attributes first
- if v, ok := val[attrK].(map[string]interface{}); ok {
- // First, unroll the map[string]interface{} into a []keyval array.
- // Then sequence it.
- kv := make([]keyval, len(v))
- n := 0
- for ak, av := range v {
- kv[n] = keyval{ak, av}
- n++
- }
- sort.Sort(elemListSeq(kv))
- // Now encode the attributes in original decoding sequence, using keyval array.
- for _, a := range kv {
- vv := a.v.(map[string]interface{})
- switch vv[textK].(type) {
- case string:
- if xmlEscapeChars {
- ss = escapeChars(vv[textK].(string))
- } else {
- ss = vv[textK].(string)
- }
- *s += ` ` + a.k + `="` + ss + `"`
- case float64, bool, int, int32, int64, float32:
- *s += ` ` + a.k + `="` + fmt.Sprintf("%v", vv[textK]) + `"`
- case []byte:
- if xmlEscapeChars {
- ss = escapeChars(string(vv[textK].([]byte)))
- } else {
- ss = string(vv[textK].([]byte))
- }
- *s += ` ` + a.k + `="` + ss + `"`
- default:
- return fmt.Errorf("invalid attribute value for: %s", a.k)
- }
- }
- haveAttrs = true
- }
-
- // simple element?
- // every map value has, at least, "#seq" and, perhaps, "#text" and/or "#attr"
- _, seqOK := val[seqK] // have key
- if v, ok := val[textK]; ok && ((len(val) == 3 && haveAttrs) || (len(val) == 2 && !haveAttrs)) && seqOK {
- if stmp, ok := v.(string); ok && stmp != "" {
- if xmlEscapeChars {
- stmp = escapeChars(stmp)
- }
- *s += ">" + stmp
- endTag = true
- elen = 1
- }
- isSimple = true
- break
- } else if !ok && ((len(val) == 2 && haveAttrs) || (len(val) == 1 && !haveAttrs)) && seqOK {
- // here no #text but have #seq or #seq+#attr
- endTag = false
- break
- }
-
- // we now need to sequence everything except attributes
- // 'kv' will hold everything that needs to be written
- kv := make([]keyval, 0)
- for k, v := range val {
- if k == attrK { // already processed
- continue
- }
- if k == seqK { // ignore - just for sorting
- continue
- }
- switch v.(type) {
- case []interface{}:
- // unwind the array as separate entries
- for _, vv := range v.([]interface{}) {
- kv = append(kv, keyval{k, vv})
- }
- default:
- kv = append(kv, keyval{k, v})
- }
- }
-
- // close tag with possible attributes
- *s += ">"
- if doIndent {
- *s += "\n"
- }
- // something more complex
- p.mapDepth++
- sort.Sort(elemListSeq(kv))
- i := 0
- for _, v := range kv {
- switch v.v.(type) {
- case []interface{}:
- default:
- if i == 0 && doIndent {
- p.Indent()
- }
- }
- i++
- if err := mapToXmlSeqIndent(doIndent, s, v.k, v.v, p); err != nil {
- return err
- }
- switch v.v.(type) {
- case []interface{}: // handled in []interface{} case
- default:
- if doIndent {
- p.Outdent()
- }
- }
- i--
- }
- p.mapDepth--
- endTag = true
- elen = 1 // we do have some content other than attrs
- case []interface{}:
- for _, v := range value.([]interface{}) {
- if doIndent {
- p.Indent()
- }
- if err := mapToXmlSeqIndent(doIndent, s, key, v, p); err != nil {
- return err
- }
- if doIndent {
- p.Outdent()
- }
- }
- return nil
- case nil:
- // terminate the tag
- if doIndent {
- *s += p.padding
- }
- *s += "<" + key
- endTag, isSimple = true, true
- break
- default: // handle anything - even goofy stuff
- elen = 0
- switch value.(type) {
- case string:
- if xmlEscapeChars {
- ss = escapeChars(value.(string))
- } else {
- ss = value.(string)
- }
- elen = len(ss)
- if elen > 0 {
- *s += ">" + ss
- }
- case float64, bool, int, int32, int64, float32:
- v := fmt.Sprintf("%v", value)
- elen = len(v)
- if elen > 0 {
- *s += ">" + v
- }
- case []byte: // NOTE: byte is just an alias for uint8
- // similar to how xml.Marshal handles []byte structure members
- if xmlEscapeChars {
- ss = escapeChars(string(value.([]byte)))
- } else {
- ss = string(value.([]byte))
- }
- elen = len(ss)
- if elen > 0 {
- *s += ">" + ss
- }
- default:
- var v []byte
- var err error
- if doIndent {
- v, err = xml.MarshalIndent(value, p.padding, p.indent)
- } else {
- v, err = xml.Marshal(value)
- }
- if err != nil {
- *s += ">UNKNOWN"
- } else {
- elen = len(v)
- if elen > 0 {
- *s += string(v)
- }
- }
- }
- isSimple = true
- endTag = true
- }
- if endTag && !noEndTag {
- if doIndent {
- if !isSimple {
- *s += p.padding
- }
- }
- switch value.(type) {
- case map[string]interface{}, []byte, string, float64, bool, int, int32, int64, float32:
- if elen > 0 || useGoXmlEmptyElemSyntax {
- if elen == 0 {
- *s += ">"
- }
- *s += `` + key + ">"
- } else {
- *s += `/>`
- }
- }
- } else if !noEndTag {
- if useGoXmlEmptyElemSyntax {
- *s += `` + key + ">"
- // *s += ">" + key + ">"
- } else {
- *s += "/>"
- }
- }
- if doIndent {
- if p.cnt > p.start {
- *s += "\n"
- }
- p.Outdent()
- }
-
- return nil
-}
-
-// the element sort implementation
-
-type keyval struct {
- k string
- v interface{}
-}
-type elemListSeq []keyval
-
-func (e elemListSeq) Len() int {
- return len(e)
-}
-
-func (e elemListSeq) Swap(i, j int) {
- e[i], e[j] = e[j], e[i]
-}
-
-func (e elemListSeq) Less(i, j int) bool {
- var iseq, jseq int
- var fiseq, fjseq float64
- var ok bool
- if iseq, ok = e[i].v.(map[string]interface{})[seqK].(int); !ok {
- if fiseq, ok = e[i].v.(map[string]interface{})[seqK].(float64); ok {
- iseq = int(fiseq)
- } else {
- iseq = 9999999
- }
- }
-
- if jseq, ok = e[j].v.(map[string]interface{})[seqK].(int); !ok {
- if fjseq, ok = e[j].v.(map[string]interface{})[seqK].(float64); ok {
- jseq = int(fjseq)
- } else {
- jseq = 9999999
- }
- }
-
- return iseq <= jseq
-}
-
-// =============== https://groups.google.com/forum/#!topic/golang-nuts/lHPOHD-8qio
-
-// BeautifyXml (re)formats an XML doc similar to Map.XmlIndent().
-// It preserves comments, directives and process instructions,
-func BeautifyXml(b []byte, prefix, indent string) ([]byte, error) {
- x, err := NewMapXmlSeq(b)
- if err != nil {
- return nil, err
- }
- return x.XmlIndent(prefix, indent)
-}
diff --git a/vendor/github.com/clbanning/mxj/v2/xmlseq2.go b/vendor/github.com/clbanning/mxj/v2/xmlseq2.go
deleted file mode 100644
index 467fd07..0000000
--- a/vendor/github.com/clbanning/mxj/v2/xmlseq2.go
+++ /dev/null
@@ -1,18 +0,0 @@
-// Copyright 2012-2016, 2019 Charles Banning. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file
-
-package mxj
-
-// ---------------- expose Map methods to MapSeq type ---------------------------
-
-// Pretty print a Map.
-func (msv MapSeq) StringIndent(offset ...int) string {
- return writeMap(map[string]interface{}(msv), true, true, offset...)
-}
-
-// Pretty print a Map without the value type information - just key:value entries.
-func (msv MapSeq) StringIndentNoTypeInfo(offset ...int) string {
- return writeMap(map[string]interface{}(msv), false, true, offset...)
-}
-
diff --git a/vendor/github.com/coreos/go-systemd/v22/LICENSE b/vendor/github.com/coreos/go-systemd/v22/LICENSE
deleted file mode 100644
index 37ec93a..0000000
--- a/vendor/github.com/coreos/go-systemd/v22/LICENSE
+++ /dev/null
@@ -1,191 +0,0 @@
-Apache License
-Version 2.0, January 2004
-http://www.apache.org/licenses/
-
-TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
-1. Definitions.
-
-"License" shall mean the terms and conditions for use, reproduction, and
-distribution as defined by Sections 1 through 9 of this document.
-
-"Licensor" shall mean the copyright owner or entity authorized by the copyright
-owner that is granting the License.
-
-"Legal Entity" shall mean the union of the acting entity and all other entities
-that control, are controlled by, or are under common control with that entity.
-For the purposes of this definition, "control" means (i) the power, direct or
-indirect, to cause the direction or management of such entity, whether by
-contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the
-outstanding shares, or (iii) beneficial ownership of such entity.
-
-"You" (or "Your") shall mean an individual or Legal Entity exercising
-permissions granted by this License.
-
-"Source" form shall mean the preferred form for making modifications, including
-but not limited to software source code, documentation source, and configuration
-files.
-
-"Object" form shall mean any form resulting from mechanical transformation or
-translation of a Source form, including but not limited to compiled object code,
-generated documentation, and conversions to other media types.
-
-"Work" shall mean the work of authorship, whether in Source or Object form, made
-available under the License, as indicated by a copyright notice that is included
-in or attached to the work (an example is provided in the Appendix below).
-
-"Derivative Works" shall mean any work, whether in Source or Object form, that
-is based on (or derived from) the Work and for which the editorial revisions,
-annotations, elaborations, or other modifications represent, as a whole, an
-original work of authorship. For the purposes of this License, Derivative Works
-shall not include works that remain separable from, or merely link (or bind by
-name) to the interfaces of, the Work and Derivative Works thereof.
-
-"Contribution" shall mean any work of authorship, including the original version
-of the Work and any modifications or additions to that Work or Derivative Works
-thereof, that is intentionally submitted to Licensor for inclusion in the Work
-by the copyright owner or by an individual or Legal Entity authorized to submit
-on behalf of the copyright owner. For the purposes of this definition,
-"submitted" means any form of electronic, verbal, or written communication sent
-to the Licensor or its representatives, including but not limited to
-communication on electronic mailing lists, source code control systems, and
-issue tracking systems that are managed by, or on behalf of, the Licensor for
-the purpose of discussing and improving the Work, but excluding communication
-that is conspicuously marked or otherwise designated in writing by the copyright
-owner as "Not a Contribution."
-
-"Contributor" shall mean Licensor and any individual or Legal Entity on behalf
-of whom a Contribution has been received by Licensor and subsequently
-incorporated within the Work.
-
-2. Grant of Copyright License.
-
-Subject to the terms and conditions of this License, each Contributor hereby
-grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free,
-irrevocable copyright license to reproduce, prepare Derivative Works of,
-publicly display, publicly perform, sublicense, and distribute the Work and such
-Derivative Works in Source or Object form.
-
-3. Grant of Patent License.
-
-Subject to the terms and conditions of this License, each Contributor hereby
-grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free,
-irrevocable (except as stated in this section) patent license to make, have
-made, use, offer to sell, sell, import, and otherwise transfer the Work, where
-such license applies only to those patent claims licensable by such Contributor
-that are necessarily infringed by their Contribution(s) alone or by combination
-of their Contribution(s) with the Work to which such Contribution(s) was
-submitted. If You institute patent litigation against any entity (including a
-cross-claim or counterclaim in a lawsuit) alleging that the Work or a
-Contribution incorporated within the Work constitutes direct or contributory
-patent infringement, then any patent licenses granted to You under this License
-for that Work shall terminate as of the date such litigation is filed.
-
-4. Redistribution.
-
-You may reproduce and distribute copies of the Work or Derivative Works thereof
-in any medium, with or without modifications, and in Source or Object form,
-provided that You meet the following conditions:
-
-You must give any other recipients of the Work or Derivative Works a copy of
-this License; and
-You must cause any modified files to carry prominent notices stating that You
-changed the files; and
-You must retain, in the Source form of any Derivative Works that You distribute,
-all copyright, patent, trademark, and attribution notices from the Source form
-of the Work, excluding those notices that do not pertain to any part of the
-Derivative Works; and
-If the Work includes a "NOTICE" text file as part of its distribution, then any
-Derivative Works that You distribute must include a readable copy of the
-attribution notices contained within such NOTICE file, excluding those notices
-that do not pertain to any part of the Derivative Works, in at least one of the
-following places: within a NOTICE text file distributed as part of the
-Derivative Works; within the Source form or documentation, if provided along
-with the Derivative Works; or, within a display generated by the Derivative
-Works, if and wherever such third-party notices normally appear. The contents of
-the NOTICE file are for informational purposes only and do not modify the
-License. You may add Your own attribution notices within Derivative Works that
-You distribute, alongside or as an addendum to the NOTICE text from the Work,
-provided that such additional attribution notices cannot be construed as
-modifying the License.
-You may add Your own copyright statement to Your modifications and may provide
-additional or different license terms and conditions for use, reproduction, or
-distribution of Your modifications, or for any such Derivative Works as a whole,
-provided Your use, reproduction, and distribution of the Work otherwise complies
-with the conditions stated in this License.
-
-5. Submission of Contributions.
-
-Unless You explicitly state otherwise, any Contribution intentionally submitted
-for inclusion in the Work by You to the Licensor shall be under the terms and
-conditions of this License, without any additional terms or conditions.
-Notwithstanding the above, nothing herein shall supersede or modify the terms of
-any separate license agreement you may have executed with Licensor regarding
-such Contributions.
-
-6. Trademarks.
-
-This License does not grant permission to use the trade names, trademarks,
-service marks, or product names of the Licensor, except as required for
-reasonable and customary use in describing the origin of the Work and
-reproducing the content of the NOTICE file.
-
-7. Disclaimer of Warranty.
-
-Unless required by applicable law or agreed to in writing, Licensor provides the
-Work (and each Contributor provides its Contributions) on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied,
-including, without limitation, any warranties or conditions of TITLE,
-NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are
-solely responsible for determining the appropriateness of using or
-redistributing the Work and assume any risks associated with Your exercise of
-permissions under this License.
-
-8. Limitation of Liability.
-
-In no event and under no legal theory, whether in tort (including negligence),
-contract, or otherwise, unless required by applicable law (such as deliberate
-and grossly negligent acts) or agreed to in writing, shall any Contributor be
-liable to You for damages, including any direct, indirect, special, incidental,
-or consequential damages of any character arising as a result of this License or
-out of the use or inability to use the Work (including but not limited to
-damages for loss of goodwill, work stoppage, computer failure or malfunction, or
-any and all other commercial damages or losses), even if such Contributor has
-been advised of the possibility of such damages.
-
-9. Accepting Warranty or Additional Liability.
-
-While redistributing the Work or Derivative Works thereof, You may choose to
-offer, and charge a fee for, acceptance of support, warranty, indemnity, or
-other liability obligations and/or rights consistent with this License. However,
-in accepting such obligations, You may act only on Your own behalf and on Your
-sole responsibility, not on behalf of any other Contributor, and only if You
-agree to indemnify, defend, and hold each Contributor harmless for any liability
-incurred by, or claims asserted against, such Contributor by reason of your
-accepting any such warranty or additional liability.
-
-END OF TERMS AND CONDITIONS
-
-APPENDIX: How to apply the Apache License to your work
-
-To apply the Apache License to your work, attach the following boilerplate
-notice, with the fields enclosed by brackets "[]" replaced with your own
-identifying information. (Don't include the brackets!) The text should be
-enclosed in the appropriate comment syntax for the file format. We also
-recommend that a file or class name and description of purpose be included on
-the same "printed page" as the copyright notice for easier identification within
-third-party archives.
-
- Copyright [yyyy] [name of copyright owner]
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
diff --git a/vendor/github.com/coreos/go-systemd/v22/NOTICE b/vendor/github.com/coreos/go-systemd/v22/NOTICE
deleted file mode 100644
index 23a0ada..0000000
--- a/vendor/github.com/coreos/go-systemd/v22/NOTICE
+++ /dev/null
@@ -1,5 +0,0 @@
-CoreOS Project
-Copyright 2018 CoreOS, Inc
-
-This product includes software developed at CoreOS, Inc.
-(http://www.coreos.com/).
diff --git a/vendor/github.com/coreos/go-systemd/v22/activation/files_unix.go b/vendor/github.com/coreos/go-systemd/v22/activation/files_unix.go
deleted file mode 100644
index bf7671d..0000000
--- a/vendor/github.com/coreos/go-systemd/v22/activation/files_unix.go
+++ /dev/null
@@ -1,70 +0,0 @@
-// Copyright 2015 CoreOS, Inc.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-//go:build !windows
-// +build !windows
-
-// Package activation implements primitives for systemd socket activation.
-package activation
-
-import (
- "os"
- "strconv"
- "strings"
- "syscall"
-)
-
-const (
- // listenFdsStart corresponds to `SD_LISTEN_FDS_START`.
- listenFdsStart = 3
-)
-
-// Files returns a slice containing a `os.File` object for each
-// file descriptor passed to this process via systemd fd-passing protocol.
-//
-// The order of the file descriptors is preserved in the returned slice.
-// `unsetEnv` is typically set to `true` in order to avoid clashes in
-// fd usage and to avoid leaking environment flags to child processes.
-func Files(unsetEnv bool) []*os.File {
- if unsetEnv {
- defer os.Unsetenv("LISTEN_PID")
- defer os.Unsetenv("LISTEN_FDS")
- defer os.Unsetenv("LISTEN_FDNAMES")
- }
-
- pid, err := strconv.Atoi(os.Getenv("LISTEN_PID"))
- if err != nil || pid != os.Getpid() {
- return nil
- }
-
- nfds, err := strconv.Atoi(os.Getenv("LISTEN_FDS"))
- if err != nil || nfds == 0 {
- return nil
- }
-
- names := strings.Split(os.Getenv("LISTEN_FDNAMES"), ":")
-
- files := make([]*os.File, 0, nfds)
- for fd := listenFdsStart; fd < listenFdsStart+nfds; fd++ {
- syscall.CloseOnExec(fd)
- name := "LISTEN_FD_" + strconv.Itoa(fd)
- offset := fd - listenFdsStart
- if offset < len(names) && len(names[offset]) > 0 {
- name = names[offset]
- }
- files = append(files, os.NewFile(uintptr(fd), name))
- }
-
- return files
-}
diff --git a/vendor/github.com/coreos/go-systemd/v22/activation/files_windows.go b/vendor/github.com/coreos/go-systemd/v22/activation/files_windows.go
deleted file mode 100644
index d391bf0..0000000
--- a/vendor/github.com/coreos/go-systemd/v22/activation/files_windows.go
+++ /dev/null
@@ -1,21 +0,0 @@
-// Copyright 2015 CoreOS, Inc.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package activation
-
-import "os"
-
-func Files(unsetEnv bool) []*os.File {
- return nil
-}
diff --git a/vendor/github.com/coreos/go-systemd/v22/activation/listeners.go b/vendor/github.com/coreos/go-systemd/v22/activation/listeners.go
deleted file mode 100644
index 3dbe2b0..0000000
--- a/vendor/github.com/coreos/go-systemd/v22/activation/listeners.go
+++ /dev/null
@@ -1,103 +0,0 @@
-// Copyright 2015 CoreOS, Inc.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package activation
-
-import (
- "crypto/tls"
- "net"
-)
-
-// Listeners returns a slice containing a net.Listener for each matching socket type
-// passed to this process.
-//
-// The order of the file descriptors is preserved in the returned slice.
-// Nil values are used to fill any gaps. For example if systemd were to return file descriptors
-// corresponding with "udp, tcp, tcp", then the slice would contain {nil, net.Listener, net.Listener}
-func Listeners() ([]net.Listener, error) {
- files := Files(true)
- listeners := make([]net.Listener, len(files))
-
- for i, f := range files {
- if pc, err := net.FileListener(f); err == nil {
- listeners[i] = pc
- f.Close()
- }
- }
- return listeners, nil
-}
-
-// ListenersWithNames maps a listener name to a set of net.Listener instances.
-func ListenersWithNames() (map[string][]net.Listener, error) {
- files := Files(true)
- listeners := map[string][]net.Listener{}
-
- for _, f := range files {
- if pc, err := net.FileListener(f); err == nil {
- current, ok := listeners[f.Name()]
- if !ok {
- listeners[f.Name()] = []net.Listener{pc}
- } else {
- listeners[f.Name()] = append(current, pc)
- }
- f.Close()
- }
- }
- return listeners, nil
-}
-
-// TLSListeners returns a slice containing a net.listener for each matching TCP socket type
-// passed to this process.
-// It uses default Listeners func and forces TCP sockets handlers to use TLS based on tlsConfig.
-func TLSListeners(tlsConfig *tls.Config) ([]net.Listener, error) {
- listeners, err := Listeners()
-
- if listeners == nil || err != nil {
- return nil, err
- }
-
- if tlsConfig != nil {
- for i, l := range listeners {
- // Activate TLS only for TCP sockets
- if l.Addr().Network() == "tcp" {
- listeners[i] = tls.NewListener(l, tlsConfig)
- }
- }
- }
-
- return listeners, err
-}
-
-// TLSListenersWithNames maps a listener name to a net.Listener with
-// the associated TLS configuration.
-func TLSListenersWithNames(tlsConfig *tls.Config) (map[string][]net.Listener, error) {
- listeners, err := ListenersWithNames()
-
- if listeners == nil || err != nil {
- return nil, err
- }
-
- if tlsConfig != nil {
- for _, ll := range listeners {
- // Activate TLS only for TCP sockets
- for i, l := range ll {
- if l.Addr().Network() == "tcp" {
- ll[i] = tls.NewListener(l, tlsConfig)
- }
- }
- }
- }
-
- return listeners, err
-}
diff --git a/vendor/github.com/coreos/go-systemd/v22/activation/packetconns.go b/vendor/github.com/coreos/go-systemd/v22/activation/packetconns.go
deleted file mode 100644
index a972067..0000000
--- a/vendor/github.com/coreos/go-systemd/v22/activation/packetconns.go
+++ /dev/null
@@ -1,38 +0,0 @@
-// Copyright 2015 CoreOS, Inc.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package activation
-
-import (
- "net"
-)
-
-// PacketConns returns a slice containing a net.PacketConn for each matching socket type
-// passed to this process.
-//
-// The order of the file descriptors is preserved in the returned slice.
-// Nil values are used to fill any gaps. For example if systemd were to return file descriptors
-// corresponding with "udp, tcp, udp", then the slice would contain {net.PacketConn, nil, net.PacketConn}
-func PacketConns() ([]net.PacketConn, error) {
- files := Files(true)
- conns := make([]net.PacketConn, len(files))
-
- for i, f := range files {
- if pc, err := net.FilePacketConn(f); err == nil {
- conns[i] = pc
- f.Close()
- }
- }
- return conns, nil
-}
diff --git a/vendor/github.com/dustin/go-humanize/.travis.yml b/vendor/github.com/dustin/go-humanize/.travis.yml
deleted file mode 100644
index ac12e48..0000000
--- a/vendor/github.com/dustin/go-humanize/.travis.yml
+++ /dev/null
@@ -1,21 +0,0 @@
-sudo: false
-language: go
-go_import_path: github.com/dustin/go-humanize
-go:
- - 1.13.x
- - 1.14.x
- - 1.15.x
- - 1.16.x
- - stable
- - master
-matrix:
- allow_failures:
- - go: master
- fast_finish: true
-install:
- - # Do nothing. This is needed to prevent default install action "go get -t -v ./..." from happening here (we want it to happen inside script step).
-script:
- - diff -u <(echo -n) <(gofmt -d -s .)
- - go vet .
- - go install -v -race ./...
- - go test -v -race ./...
diff --git a/vendor/github.com/dustin/go-humanize/LICENSE b/vendor/github.com/dustin/go-humanize/LICENSE
deleted file mode 100644
index 8d9a94a..0000000
--- a/vendor/github.com/dustin/go-humanize/LICENSE
+++ /dev/null
@@ -1,21 +0,0 @@
-Copyright (c) 2005-2008 Dustin Sallings
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-SOFTWARE.
-
-
diff --git a/vendor/github.com/dustin/go-humanize/README.markdown b/vendor/github.com/dustin/go-humanize/README.markdown
deleted file mode 100644
index 7d0b16b..0000000
--- a/vendor/github.com/dustin/go-humanize/README.markdown
+++ /dev/null
@@ -1,124 +0,0 @@
-# Humane Units [](https://travis-ci.org/dustin/go-humanize) [](https://godoc.org/github.com/dustin/go-humanize)
-
-Just a few functions for helping humanize times and sizes.
-
-`go get` it as `github.com/dustin/go-humanize`, import it as
-`"github.com/dustin/go-humanize"`, use it as `humanize`.
-
-See [godoc](https://pkg.go.dev/github.com/dustin/go-humanize) for
-complete documentation.
-
-## Sizes
-
-This lets you take numbers like `82854982` and convert them to useful
-strings like, `83 MB` or `79 MiB` (whichever you prefer).
-
-Example:
-
-```go
-fmt.Printf("That file is %s.", humanize.Bytes(82854982)) // That file is 83 MB.
-```
-
-## Times
-
-This lets you take a `time.Time` and spit it out in relative terms.
-For example, `12 seconds ago` or `3 days from now`.
-
-Example:
-
-```go
-fmt.Printf("This was touched %s.", humanize.Time(someTimeInstance)) // This was touched 7 hours ago.
-```
-
-Thanks to Kyle Lemons for the time implementation from an IRC
-conversation one day. It's pretty neat.
-
-## Ordinals
-
-From a [mailing list discussion][odisc] where a user wanted to be able
-to label ordinals.
-
- 0 -> 0th
- 1 -> 1st
- 2 -> 2nd
- 3 -> 3rd
- 4 -> 4th
- [...]
-
-Example:
-
-```go
-fmt.Printf("You're my %s best friend.", humanize.Ordinal(193)) // You are my 193rd best friend.
-```
-
-## Commas
-
-Want to shove commas into numbers? Be my guest.
-
- 0 -> 0
- 100 -> 100
- 1000 -> 1,000
- 1000000000 -> 1,000,000,000
- -100000 -> -100,000
-
-Example:
-
-```go
-fmt.Printf("You owe $%s.\n", humanize.Comma(6582491)) // You owe $6,582,491.
-```
-
-## Ftoa
-
-Nicer float64 formatter that removes trailing zeros.
-
-```go
-fmt.Printf("%f", 2.24) // 2.240000
-fmt.Printf("%s", humanize.Ftoa(2.24)) // 2.24
-fmt.Printf("%f", 2.0) // 2.000000
-fmt.Printf("%s", humanize.Ftoa(2.0)) // 2
-```
-
-## SI notation
-
-Format numbers with [SI notation][sinotation].
-
-Example:
-
-```go
-humanize.SI(0.00000000223, "M") // 2.23 nM
-```
-
-## English-specific functions
-
-The following functions are in the `humanize/english` subpackage.
-
-### Plurals
-
-Simple English pluralization
-
-```go
-english.PluralWord(1, "object", "") // object
-english.PluralWord(42, "object", "") // objects
-english.PluralWord(2, "bus", "") // buses
-english.PluralWord(99, "locus", "loci") // loci
-
-english.Plural(1, "object", "") // 1 object
-english.Plural(42, "object", "") // 42 objects
-english.Plural(2, "bus", "") // 2 buses
-english.Plural(99, "locus", "loci") // 99 loci
-```
-
-### Word series
-
-Format comma-separated words lists with conjuctions:
-
-```go
-english.WordSeries([]string{"foo"}, "and") // foo
-english.WordSeries([]string{"foo", "bar"}, "and") // foo and bar
-english.WordSeries([]string{"foo", "bar", "baz"}, "and") // foo, bar and baz
-
-english.OxfordWordSeries([]string{"foo", "bar", "baz"}, "and") // foo, bar, and baz
-```
-
-[odisc]: https://groups.google.com/d/topic/golang-nuts/l8NhI74jl-4/discussion
-[sinotation]: http://en.wikipedia.org/wiki/Metric_prefix
diff --git a/vendor/github.com/dustin/go-humanize/big.go b/vendor/github.com/dustin/go-humanize/big.go
deleted file mode 100644
index f49dc33..0000000
--- a/vendor/github.com/dustin/go-humanize/big.go
+++ /dev/null
@@ -1,31 +0,0 @@
-package humanize
-
-import (
- "math/big"
-)
-
-// order of magnitude (to a max order)
-func oomm(n, b *big.Int, maxmag int) (float64, int) {
- mag := 0
- m := &big.Int{}
- for n.Cmp(b) >= 0 {
- n.DivMod(n, b, m)
- mag++
- if mag == maxmag && maxmag >= 0 {
- break
- }
- }
- return float64(n.Int64()) + (float64(m.Int64()) / float64(b.Int64())), mag
-}
-
-// total order of magnitude
-// (same as above, but with no upper limit)
-func oom(n, b *big.Int) (float64, int) {
- mag := 0
- m := &big.Int{}
- for n.Cmp(b) >= 0 {
- n.DivMod(n, b, m)
- mag++
- }
- return float64(n.Int64()) + (float64(m.Int64()) / float64(b.Int64())), mag
-}
diff --git a/vendor/github.com/dustin/go-humanize/bigbytes.go b/vendor/github.com/dustin/go-humanize/bigbytes.go
deleted file mode 100644
index 3b015fd..0000000
--- a/vendor/github.com/dustin/go-humanize/bigbytes.go
+++ /dev/null
@@ -1,189 +0,0 @@
-package humanize
-
-import (
- "fmt"
- "math/big"
- "strings"
- "unicode"
-)
-
-var (
- bigIECExp = big.NewInt(1024)
-
- // BigByte is one byte in bit.Ints
- BigByte = big.NewInt(1)
- // BigKiByte is 1,024 bytes in bit.Ints
- BigKiByte = (&big.Int{}).Mul(BigByte, bigIECExp)
- // BigMiByte is 1,024 k bytes in bit.Ints
- BigMiByte = (&big.Int{}).Mul(BigKiByte, bigIECExp)
- // BigGiByte is 1,024 m bytes in bit.Ints
- BigGiByte = (&big.Int{}).Mul(BigMiByte, bigIECExp)
- // BigTiByte is 1,024 g bytes in bit.Ints
- BigTiByte = (&big.Int{}).Mul(BigGiByte, bigIECExp)
- // BigPiByte is 1,024 t bytes in bit.Ints
- BigPiByte = (&big.Int{}).Mul(BigTiByte, bigIECExp)
- // BigEiByte is 1,024 p bytes in bit.Ints
- BigEiByte = (&big.Int{}).Mul(BigPiByte, bigIECExp)
- // BigZiByte is 1,024 e bytes in bit.Ints
- BigZiByte = (&big.Int{}).Mul(BigEiByte, bigIECExp)
- // BigYiByte is 1,024 z bytes in bit.Ints
- BigYiByte = (&big.Int{}).Mul(BigZiByte, bigIECExp)
- // BigRiByte is 1,024 y bytes in bit.Ints
- BigRiByte = (&big.Int{}).Mul(BigYiByte, bigIECExp)
- // BigQiByte is 1,024 r bytes in bit.Ints
- BigQiByte = (&big.Int{}).Mul(BigRiByte, bigIECExp)
-)
-
-var (
- bigSIExp = big.NewInt(1000)
-
- // BigSIByte is one SI byte in big.Ints
- BigSIByte = big.NewInt(1)
- // BigKByte is 1,000 SI bytes in big.Ints
- BigKByte = (&big.Int{}).Mul(BigSIByte, bigSIExp)
- // BigMByte is 1,000 SI k bytes in big.Ints
- BigMByte = (&big.Int{}).Mul(BigKByte, bigSIExp)
- // BigGByte is 1,000 SI m bytes in big.Ints
- BigGByte = (&big.Int{}).Mul(BigMByte, bigSIExp)
- // BigTByte is 1,000 SI g bytes in big.Ints
- BigTByte = (&big.Int{}).Mul(BigGByte, bigSIExp)
- // BigPByte is 1,000 SI t bytes in big.Ints
- BigPByte = (&big.Int{}).Mul(BigTByte, bigSIExp)
- // BigEByte is 1,000 SI p bytes in big.Ints
- BigEByte = (&big.Int{}).Mul(BigPByte, bigSIExp)
- // BigZByte is 1,000 SI e bytes in big.Ints
- BigZByte = (&big.Int{}).Mul(BigEByte, bigSIExp)
- // BigYByte is 1,000 SI z bytes in big.Ints
- BigYByte = (&big.Int{}).Mul(BigZByte, bigSIExp)
- // BigRByte is 1,000 SI y bytes in big.Ints
- BigRByte = (&big.Int{}).Mul(BigYByte, bigSIExp)
- // BigQByte is 1,000 SI r bytes in big.Ints
- BigQByte = (&big.Int{}).Mul(BigRByte, bigSIExp)
-)
-
-var bigBytesSizeTable = map[string]*big.Int{
- "b": BigByte,
- "kib": BigKiByte,
- "kb": BigKByte,
- "mib": BigMiByte,
- "mb": BigMByte,
- "gib": BigGiByte,
- "gb": BigGByte,
- "tib": BigTiByte,
- "tb": BigTByte,
- "pib": BigPiByte,
- "pb": BigPByte,
- "eib": BigEiByte,
- "eb": BigEByte,
- "zib": BigZiByte,
- "zb": BigZByte,
- "yib": BigYiByte,
- "yb": BigYByte,
- "rib": BigRiByte,
- "rb": BigRByte,
- "qib": BigQiByte,
- "qb": BigQByte,
- // Without suffix
- "": BigByte,
- "ki": BigKiByte,
- "k": BigKByte,
- "mi": BigMiByte,
- "m": BigMByte,
- "gi": BigGiByte,
- "g": BigGByte,
- "ti": BigTiByte,
- "t": BigTByte,
- "pi": BigPiByte,
- "p": BigPByte,
- "ei": BigEiByte,
- "e": BigEByte,
- "z": BigZByte,
- "zi": BigZiByte,
- "y": BigYByte,
- "yi": BigYiByte,
- "r": BigRByte,
- "ri": BigRiByte,
- "q": BigQByte,
- "qi": BigQiByte,
-}
-
-var ten = big.NewInt(10)
-
-func humanateBigBytes(s, base *big.Int, sizes []string) string {
- if s.Cmp(ten) < 0 {
- return fmt.Sprintf("%d B", s)
- }
- c := (&big.Int{}).Set(s)
- val, mag := oomm(c, base, len(sizes)-1)
- suffix := sizes[mag]
- f := "%.0f %s"
- if val < 10 {
- f = "%.1f %s"
- }
-
- return fmt.Sprintf(f, val, suffix)
-
-}
-
-// BigBytes produces a human readable representation of an SI size.
-//
-// See also: ParseBigBytes.
-//
-// BigBytes(82854982) -> 83 MB
-func BigBytes(s *big.Int) string {
- sizes := []string{"B", "kB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB", "RB", "QB"}
- return humanateBigBytes(s, bigSIExp, sizes)
-}
-
-// BigIBytes produces a human readable representation of an IEC size.
-//
-// See also: ParseBigBytes.
-//
-// BigIBytes(82854982) -> 79 MiB
-func BigIBytes(s *big.Int) string {
- sizes := []string{"B", "KiB", "MiB", "GiB", "TiB", "PiB", "EiB", "ZiB", "YiB", "RiB", "QiB"}
- return humanateBigBytes(s, bigIECExp, sizes)
-}
-
-// ParseBigBytes parses a string representation of bytes into the number
-// of bytes it represents.
-//
-// See also: BigBytes, BigIBytes.
-//
-// ParseBigBytes("42 MB") -> 42000000, nil
-// ParseBigBytes("42 mib") -> 44040192, nil
-func ParseBigBytes(s string) (*big.Int, error) {
- lastDigit := 0
- hasComma := false
- for _, r := range s {
- if !(unicode.IsDigit(r) || r == '.' || r == ',') {
- break
- }
- if r == ',' {
- hasComma = true
- }
- lastDigit++
- }
-
- num := s[:lastDigit]
- if hasComma {
- num = strings.Replace(num, ",", "", -1)
- }
-
- val := &big.Rat{}
- _, err := fmt.Sscanf(num, "%f", val)
- if err != nil {
- return nil, err
- }
-
- extra := strings.ToLower(strings.TrimSpace(s[lastDigit:]))
- if m, ok := bigBytesSizeTable[extra]; ok {
- mv := (&big.Rat{}).SetInt(m)
- val.Mul(val, mv)
- rv := &big.Int{}
- rv.Div(val.Num(), val.Denom())
- return rv, nil
- }
-
- return nil, fmt.Errorf("unhandled size name: %v", extra)
-}
diff --git a/vendor/github.com/dustin/go-humanize/bytes.go b/vendor/github.com/dustin/go-humanize/bytes.go
deleted file mode 100644
index 0b498f4..0000000
--- a/vendor/github.com/dustin/go-humanize/bytes.go
+++ /dev/null
@@ -1,143 +0,0 @@
-package humanize
-
-import (
- "fmt"
- "math"
- "strconv"
- "strings"
- "unicode"
-)
-
-// IEC Sizes.
-// kibis of bits
-const (
- Byte = 1 << (iota * 10)
- KiByte
- MiByte
- GiByte
- TiByte
- PiByte
- EiByte
-)
-
-// SI Sizes.
-const (
- IByte = 1
- KByte = IByte * 1000
- MByte = KByte * 1000
- GByte = MByte * 1000
- TByte = GByte * 1000
- PByte = TByte * 1000
- EByte = PByte * 1000
-)
-
-var bytesSizeTable = map[string]uint64{
- "b": Byte,
- "kib": KiByte,
- "kb": KByte,
- "mib": MiByte,
- "mb": MByte,
- "gib": GiByte,
- "gb": GByte,
- "tib": TiByte,
- "tb": TByte,
- "pib": PiByte,
- "pb": PByte,
- "eib": EiByte,
- "eb": EByte,
- // Without suffix
- "": Byte,
- "ki": KiByte,
- "k": KByte,
- "mi": MiByte,
- "m": MByte,
- "gi": GiByte,
- "g": GByte,
- "ti": TiByte,
- "t": TByte,
- "pi": PiByte,
- "p": PByte,
- "ei": EiByte,
- "e": EByte,
-}
-
-func logn(n, b float64) float64 {
- return math.Log(n) / math.Log(b)
-}
-
-func humanateBytes(s uint64, base float64, sizes []string) string {
- if s < 10 {
- return fmt.Sprintf("%d B", s)
- }
- e := math.Floor(logn(float64(s), base))
- suffix := sizes[int(e)]
- val := math.Floor(float64(s)/math.Pow(base, e)*10+0.5) / 10
- f := "%.0f %s"
- if val < 10 {
- f = "%.1f %s"
- }
-
- return fmt.Sprintf(f, val, suffix)
-}
-
-// Bytes produces a human readable representation of an SI size.
-//
-// See also: ParseBytes.
-//
-// Bytes(82854982) -> 83 MB
-func Bytes(s uint64) string {
- sizes := []string{"B", "kB", "MB", "GB", "TB", "PB", "EB"}
- return humanateBytes(s, 1000, sizes)
-}
-
-// IBytes produces a human readable representation of an IEC size.
-//
-// See also: ParseBytes.
-//
-// IBytes(82854982) -> 79 MiB
-func IBytes(s uint64) string {
- sizes := []string{"B", "KiB", "MiB", "GiB", "TiB", "PiB", "EiB"}
- return humanateBytes(s, 1024, sizes)
-}
-
-// ParseBytes parses a string representation of bytes into the number
-// of bytes it represents.
-//
-// See Also: Bytes, IBytes.
-//
-// ParseBytes("42 MB") -> 42000000, nil
-// ParseBytes("42 mib") -> 44040192, nil
-func ParseBytes(s string) (uint64, error) {
- lastDigit := 0
- hasComma := false
- for _, r := range s {
- if !(unicode.IsDigit(r) || r == '.' || r == ',') {
- break
- }
- if r == ',' {
- hasComma = true
- }
- lastDigit++
- }
-
- num := s[:lastDigit]
- if hasComma {
- num = strings.Replace(num, ",", "", -1)
- }
-
- f, err := strconv.ParseFloat(num, 64)
- if err != nil {
- return 0, err
- }
-
- extra := strings.ToLower(strings.TrimSpace(s[lastDigit:]))
- if m, ok := bytesSizeTable[extra]; ok {
- f *= float64(m)
- if f >= math.MaxUint64 {
- return 0, fmt.Errorf("too large: %v", s)
- }
- return uint64(f), nil
- }
-
- return 0, fmt.Errorf("unhandled size name: %v", extra)
-}
diff --git a/vendor/github.com/dustin/go-humanize/comma.go b/vendor/github.com/dustin/go-humanize/comma.go
deleted file mode 100644
index 520ae3e..0000000
--- a/vendor/github.com/dustin/go-humanize/comma.go
+++ /dev/null
@@ -1,116 +0,0 @@
-package humanize
-
-import (
- "bytes"
- "math"
- "math/big"
- "strconv"
- "strings"
-)
-
-// Comma produces a string form of the given number in base 10 with
-// commas after every three orders of magnitude.
-//
-// e.g. Comma(834142) -> 834,142
-func Comma(v int64) string {
- sign := ""
-
- // Min int64 can't be negated to a usable value, so it has to be special cased.
- if v == math.MinInt64 {
- return "-9,223,372,036,854,775,808"
- }
-
- if v < 0 {
- sign = "-"
- v = 0 - v
- }
-
- parts := []string{"", "", "", "", "", "", ""}
- j := len(parts) - 1
-
- for v > 999 {
- parts[j] = strconv.FormatInt(v%1000, 10)
- switch len(parts[j]) {
- case 2:
- parts[j] = "0" + parts[j]
- case 1:
- parts[j] = "00" + parts[j]
- }
- v = v / 1000
- j--
- }
- parts[j] = strconv.Itoa(int(v))
- return sign + strings.Join(parts[j:], ",")
-}
-
-// Commaf produces a string form of the given number in base 10 with
-// commas after every three orders of magnitude.
-//
-// e.g. Commaf(834142.32) -> 834,142.32
-func Commaf(v float64) string {
- buf := &bytes.Buffer{}
- if v < 0 {
- buf.Write([]byte{'-'})
- v = 0 - v
- }
-
- comma := []byte{','}
-
- parts := strings.Split(strconv.FormatFloat(v, 'f', -1, 64), ".")
- pos := 0
- if len(parts[0])%3 != 0 {
- pos += len(parts[0]) % 3
- buf.WriteString(parts[0][:pos])
- buf.Write(comma)
- }
- for ; pos < len(parts[0]); pos += 3 {
- buf.WriteString(parts[0][pos : pos+3])
- buf.Write(comma)
- }
- buf.Truncate(buf.Len() - 1)
-
- if len(parts) > 1 {
- buf.Write([]byte{'.'})
- buf.WriteString(parts[1])
- }
- return buf.String()
-}
-
-// CommafWithDigits works like the Commaf but limits the resulting
-// string to the given number of decimal places.
-//
-// e.g. CommafWithDigits(834142.32, 1) -> 834,142.3
-func CommafWithDigits(f float64, decimals int) string {
- return stripTrailingDigits(Commaf(f), decimals)
-}
-
-// BigComma produces a string form of the given big.Int in base 10
-// with commas after every three orders of magnitude.
-func BigComma(b *big.Int) string {
- sign := ""
- if b.Sign() < 0 {
- sign = "-"
- b.Abs(b)
- }
-
- athousand := big.NewInt(1000)
- c := (&big.Int{}).Set(b)
- _, m := oom(c, athousand)
- parts := make([]string, m+1)
- j := len(parts) - 1
-
- mod := &big.Int{}
- for b.Cmp(athousand) >= 0 {
- b.DivMod(b, athousand, mod)
- parts[j] = strconv.FormatInt(mod.Int64(), 10)
- switch len(parts[j]) {
- case 2:
- parts[j] = "0" + parts[j]
- case 1:
- parts[j] = "00" + parts[j]
- }
- j--
- }
- parts[j] = strconv.Itoa(int(b.Int64()))
- return sign + strings.Join(parts[j:], ",")
-}
diff --git a/vendor/github.com/dustin/go-humanize/commaf.go b/vendor/github.com/dustin/go-humanize/commaf.go
deleted file mode 100644
index 2bc83a0..0000000
--- a/vendor/github.com/dustin/go-humanize/commaf.go
+++ /dev/null
@@ -1,41 +0,0 @@
-//go:build go1.6
-// +build go1.6
-
-package humanize
-
-import (
- "bytes"
- "math/big"
- "strings"
-)
-
-// BigCommaf produces a string form of the given big.Float in base 10
-// with commas after every three orders of magnitude.
-func BigCommaf(v *big.Float) string {
- buf := &bytes.Buffer{}
- if v.Sign() < 0 {
- buf.Write([]byte{'-'})
- v.Abs(v)
- }
-
- comma := []byte{','}
-
- parts := strings.Split(v.Text('f', -1), ".")
- pos := 0
- if len(parts[0])%3 != 0 {
- pos += len(parts[0]) % 3
- buf.WriteString(parts[0][:pos])
- buf.Write(comma)
- }
- for ; pos < len(parts[0]); pos += 3 {
- buf.WriteString(parts[0][pos : pos+3])
- buf.Write(comma)
- }
- buf.Truncate(buf.Len() - 1)
-
- if len(parts) > 1 {
- buf.Write([]byte{'.'})
- buf.WriteString(parts[1])
- }
- return buf.String()
-}
diff --git a/vendor/github.com/dustin/go-humanize/ftoa.go b/vendor/github.com/dustin/go-humanize/ftoa.go
deleted file mode 100644
index bce923f..0000000
--- a/vendor/github.com/dustin/go-humanize/ftoa.go
+++ /dev/null
@@ -1,49 +0,0 @@
-package humanize
-
-import (
- "strconv"
- "strings"
-)
-
-func stripTrailingZeros(s string) string {
- if !strings.ContainsRune(s, '.') {
- return s
- }
- offset := len(s) - 1
- for offset > 0 {
- if s[offset] == '.' {
- offset--
- break
- }
- if s[offset] != '0' {
- break
- }
- offset--
- }
- return s[:offset+1]
-}
-
-func stripTrailingDigits(s string, digits int) string {
- if i := strings.Index(s, "."); i >= 0 {
- if digits <= 0 {
- return s[:i]
- }
- i++
- if i+digits >= len(s) {
- return s
- }
- return s[:i+digits]
- }
- return s
-}
-
-// Ftoa converts a float to a string with no trailing zeros.
-func Ftoa(num float64) string {
- return stripTrailingZeros(strconv.FormatFloat(num, 'f', 6, 64))
-}
-
-// FtoaWithDigits converts a float to a string but limits the resulting string
-// to the given number of decimal places, and no trailing zeros.
-func FtoaWithDigits(num float64, digits int) string {
- return stripTrailingZeros(stripTrailingDigits(strconv.FormatFloat(num, 'f', 6, 64), digits))
-}
diff --git a/vendor/github.com/dustin/go-humanize/humanize.go b/vendor/github.com/dustin/go-humanize/humanize.go
deleted file mode 100644
index a2c2da3..0000000
--- a/vendor/github.com/dustin/go-humanize/humanize.go
+++ /dev/null
@@ -1,8 +0,0 @@
-/*
-Package humanize converts boring ugly numbers to human-friendly strings and back.
-
-Durations can be turned into strings such as "3 days ago", numbers
-representing sizes like 82854982 into useful strings like, "83 MB" or
-"79 MiB" (whichever you prefer).
-*/
-package humanize
diff --git a/vendor/github.com/dustin/go-humanize/number.go b/vendor/github.com/dustin/go-humanize/number.go
deleted file mode 100644
index 6470d0d..0000000
--- a/vendor/github.com/dustin/go-humanize/number.go
+++ /dev/null
@@ -1,192 +0,0 @@
-package humanize
-
-/*
-Slightly adapted from the source to fit go-humanize.
-
-Author: https://github.com/gorhill
-Source: https://gist.github.com/gorhill/5285193
-
-*/
-
-import (
- "math"
- "strconv"
-)
-
-var (
- renderFloatPrecisionMultipliers = [...]float64{
- 1,
- 10,
- 100,
- 1000,
- 10000,
- 100000,
- 1000000,
- 10000000,
- 100000000,
- 1000000000,
- }
-
- renderFloatPrecisionRounders = [...]float64{
- 0.5,
- 0.05,
- 0.005,
- 0.0005,
- 0.00005,
- 0.000005,
- 0.0000005,
- 0.00000005,
- 0.000000005,
- 0.0000000005,
- }
-)
-
-// FormatFloat produces a formatted number as string based on the following user-specified criteria:
-// * thousands separator
-// * decimal separator
-// * decimal precision
-//
-// Usage: s := RenderFloat(format, n)
-// The format parameter tells how to render the number n.
-//
-// See examples: http://play.golang.org/p/LXc1Ddm1lJ
-//
-// Examples of format strings, given n = 12345.6789:
-// "#,###.##" => "12,345.67"
-// "#,###." => "12,345"
-// "#,###" => "12345,678"
-// "#\u202F###,##" => "12 345,68"
-// "#.###,###### => 12.345,678900
-// "" (aka default format) => 12,345.67
-//
-// The highest precision allowed is 9 digits after the decimal symbol.
-// There is also a version for integer number, FormatInteger(),
-// which is convenient for calls within template.
-func FormatFloat(format string, n float64) string {
- // Special cases:
- // NaN = "NaN"
- // +Inf = "+Infinity"
- // -Inf = "-Infinity"
- if math.IsNaN(n) {
- return "NaN"
- }
- if n > math.MaxFloat64 {
- return "Infinity"
- }
- if n < (0.0 - math.MaxFloat64) {
- return "-Infinity"
- }
-
- // default format
- precision := 2
- decimalStr := "."
- thousandStr := ","
- positiveStr := ""
- negativeStr := "-"
-
- if len(format) > 0 {
- format := []rune(format)
-
- // If there is an explicit format directive,
- // then default values are these:
- precision = 9
- thousandStr = ""
-
- // collect indices of meaningful formatting directives
- formatIndx := []int{}
- for i, char := range format {
- if char != '#' && char != '0' {
- formatIndx = append(formatIndx, i)
- }
- }
-
- if len(formatIndx) > 0 {
- // Directive at index 0:
- // Must be a '+'
- // Raise an error if not the case
- // index: 0123456789
- // +0.000,000
- // +000,000.0
- // +0000.00
- // +0000
- if formatIndx[0] == 0 {
- if format[formatIndx[0]] != '+' {
- panic("RenderFloat(): invalid positive sign directive")
- }
- positiveStr = "+"
- formatIndx = formatIndx[1:]
- }
-
- // Two directives:
- // First is thousands separator
- // Raise an error if not followed by 3-digit
- // 0123456789
- // 0.000,000
- // 000,000.00
- if len(formatIndx) == 2 {
- if (formatIndx[1] - formatIndx[0]) != 4 {
- panic("RenderFloat(): thousands separator directive must be followed by 3 digit-specifiers")
- }
- thousandStr = string(format[formatIndx[0]])
- formatIndx = formatIndx[1:]
- }
-
- // One directive:
- // Directive is decimal separator
- // The number of digit-specifier following the separator indicates wanted precision
- // 0123456789
- // 0.00
- // 000,0000
- if len(formatIndx) == 1 {
- decimalStr = string(format[formatIndx[0]])
- precision = len(format) - formatIndx[0] - 1
- }
- }
- }
-
- // generate sign part
- var signStr string
- if n >= 0.000000001 {
- signStr = positiveStr
- } else if n <= -0.000000001 {
- signStr = negativeStr
- n = -n
- } else {
- signStr = ""
- n = 0.0
- }
-
- // split number into integer and fractional parts
- intf, fracf := math.Modf(n + renderFloatPrecisionRounders[precision])
-
- // generate integer part string
- intStr := strconv.FormatInt(int64(intf), 10)
-
- // add thousand separator if required
- if len(thousandStr) > 0 {
- for i := len(intStr); i > 3; {
- i -= 3
- intStr = intStr[:i] + thousandStr + intStr[i:]
- }
- }
-
- // no fractional part, we can leave now
- if precision == 0 {
- return signStr + intStr
- }
-
- // generate fractional part
- fracStr := strconv.Itoa(int(fracf * renderFloatPrecisionMultipliers[precision]))
- // may need padding
- if len(fracStr) < precision {
- fracStr = "000000000000000"[:precision-len(fracStr)] + fracStr
- }
-
- return signStr + intStr + decimalStr + fracStr
-}
-
-// FormatInteger produces a formatted number as string.
-// See FormatFloat.
-func FormatInteger(format string, n int) string {
- return FormatFloat(format, float64(n))
-}
diff --git a/vendor/github.com/dustin/go-humanize/ordinals.go b/vendor/github.com/dustin/go-humanize/ordinals.go
deleted file mode 100644
index 43d88a8..0000000
--- a/vendor/github.com/dustin/go-humanize/ordinals.go
+++ /dev/null
@@ -1,25 +0,0 @@
-package humanize
-
-import "strconv"
-
-// Ordinal gives you the input number in a rank/ordinal format.
-//
-// Ordinal(3) -> 3rd
-func Ordinal(x int) string {
- suffix := "th"
- switch x % 10 {
- case 1:
- if x%100 != 11 {
- suffix = "st"
- }
- case 2:
- if x%100 != 12 {
- suffix = "nd"
- }
- case 3:
- if x%100 != 13 {
- suffix = "rd"
- }
- }
- return strconv.Itoa(x) + suffix
-}
diff --git a/vendor/github.com/dustin/go-humanize/si.go b/vendor/github.com/dustin/go-humanize/si.go
deleted file mode 100644
index 8b85019..0000000
--- a/vendor/github.com/dustin/go-humanize/si.go
+++ /dev/null
@@ -1,127 +0,0 @@
-package humanize
-
-import (
- "errors"
- "math"
- "regexp"
- "strconv"
-)
-
-var siPrefixTable = map[float64]string{
- -30: "q", // quecto
- -27: "r", // ronto
- -24: "y", // yocto
- -21: "z", // zepto
- -18: "a", // atto
- -15: "f", // femto
- -12: "p", // pico
- -9: "n", // nano
- -6: "µ", // micro
- -3: "m", // milli
- 0: "",
- 3: "k", // kilo
- 6: "M", // mega
- 9: "G", // giga
- 12: "T", // tera
- 15: "P", // peta
- 18: "E", // exa
- 21: "Z", // zetta
- 24: "Y", // yotta
- 27: "R", // ronna
- 30: "Q", // quetta
-}
-
-var revSIPrefixTable = revfmap(siPrefixTable)
-
-// revfmap reverses the map and precomputes the power multiplier
-func revfmap(in map[float64]string) map[string]float64 {
- rv := map[string]float64{}
- for k, v := range in {
- rv[v] = math.Pow(10, k)
- }
- return rv
-}
-
-var riParseRegex *regexp.Regexp
-
-func init() {
- ri := `^([\-0-9.]+)\s?([`
- for _, v := range siPrefixTable {
- ri += v
- }
- ri += `]?)(.*)`
-
- riParseRegex = regexp.MustCompile(ri)
-}
-
-// ComputeSI finds the most appropriate SI prefix for the given number
-// and returns the prefix along with the value adjusted to be within
-// that prefix.
-//
-// See also: SI, ParseSI.
-//
-// e.g. ComputeSI(2.2345e-12) -> (2.2345, "p")
-func ComputeSI(input float64) (float64, string) {
- if input == 0 {
- return 0, ""
- }
- mag := math.Abs(input)
- exponent := math.Floor(logn(mag, 10))
- exponent = math.Floor(exponent/3) * 3
-
- value := mag / math.Pow(10, exponent)
-
- // Handle special case where value is exactly 1000.0
- // Should return 1 M instead of 1000 k
- if value == 1000.0 {
- exponent += 3
- value = mag / math.Pow(10, exponent)
- }
-
- value = math.Copysign(value, input)
-
- prefix := siPrefixTable[exponent]
- return value, prefix
-}
-
-// SI returns a string with default formatting.
-//
-// SI uses Ftoa to format float value, removing trailing zeros.
-//
-// See also: ComputeSI, ParseSI.
-//
-// e.g. SI(1000000, "B") -> 1 MB
-// e.g. SI(2.2345e-12, "F") -> 2.2345 pF
-func SI(input float64, unit string) string {
- value, prefix := ComputeSI(input)
- return Ftoa(value) + " " + prefix + unit
-}
-
-// SIWithDigits works like SI but limits the resulting string to the
-// given number of decimal places.
-//
-// e.g. SIWithDigits(1000000, 0, "B") -> 1 MB
-// e.g. SIWithDigits(2.2345e-12, 2, "F") -> 2.23 pF
-func SIWithDigits(input float64, decimals int, unit string) string {
- value, prefix := ComputeSI(input)
- return FtoaWithDigits(value, decimals) + " " + prefix + unit
-}
-
-var errInvalid = errors.New("invalid input")
-
-// ParseSI parses an SI string back into the number and unit.
-//
-// See also: SI, ComputeSI.
-//
-// e.g. ParseSI("2.2345 pF") -> (2.2345e-12, "F", nil)
-func ParseSI(input string) (float64, string, error) {
- found := riParseRegex.FindStringSubmatch(input)
- if len(found) != 4 {
- return 0, "", errInvalid
- }
- mag := revSIPrefixTable[found[2]]
- unit := found[3]
-
- base, err := strconv.ParseFloat(found[1], 64)
- return base * mag, unit, err
-}
diff --git a/vendor/github.com/dustin/go-humanize/times.go b/vendor/github.com/dustin/go-humanize/times.go
deleted file mode 100644
index dd3fbf5..0000000
--- a/vendor/github.com/dustin/go-humanize/times.go
+++ /dev/null
@@ -1,117 +0,0 @@
-package humanize
-
-import (
- "fmt"
- "math"
- "sort"
- "time"
-)
-
-// Seconds-based time units
-const (
- Day = 24 * time.Hour
- Week = 7 * Day
- Month = 30 * Day
- Year = 12 * Month
- LongTime = 37 * Year
-)
-
-// Time formats a time into a relative string.
-//
-// Time(someT) -> "3 weeks ago"
-func Time(then time.Time) string {
- return RelTime(then, time.Now(), "ago", "from now")
-}
-
-// A RelTimeMagnitude struct contains a relative time point at which
-// the relative format of time will switch to a new format string. A
-// slice of these in ascending order by their "D" field is passed to
-// CustomRelTime to format durations.
-//
-// The Format field is a string that may contain a "%s" which will be
-// replaced with the appropriate signed label (e.g. "ago" or "from
-// now") and a "%d" that will be replaced by the quantity.
-//
-// The DivBy field is the amount of time the time difference must be
-// divided by in order to display correctly.
-//
-// e.g. if D is 2*time.Minute and you want to display "%d minutes %s"
-// DivBy should be time.Minute so whatever the duration is will be
-// expressed in minutes.
-type RelTimeMagnitude struct {
- D time.Duration
- Format string
- DivBy time.Duration
-}
-
-var defaultMagnitudes = []RelTimeMagnitude{
- {time.Second, "now", time.Second},
- {2 * time.Second, "1 second %s", 1},
- {time.Minute, "%d seconds %s", time.Second},
- {2 * time.Minute, "1 minute %s", 1},
- {time.Hour, "%d minutes %s", time.Minute},
- {2 * time.Hour, "1 hour %s", 1},
- {Day, "%d hours %s", time.Hour},
- {2 * Day, "1 day %s", 1},
- {Week, "%d days %s", Day},
- {2 * Week, "1 week %s", 1},
- {Month, "%d weeks %s", Week},
- {2 * Month, "1 month %s", 1},
- {Year, "%d months %s", Month},
- {18 * Month, "1 year %s", 1},
- {2 * Year, "2 years %s", 1},
- {LongTime, "%d years %s", Year},
- {math.MaxInt64, "a long while %s", 1},
-}
-
-// RelTime formats a time into a relative string.
-//
-// It takes two times and two labels. In addition to the generic time
-// delta string (e.g. 5 minutes), the labels are used applied so that
-// the label corresponding to the smaller time is applied.
-//
-// RelTime(timeInPast, timeInFuture, "earlier", "later") -> "3 weeks earlier"
-func RelTime(a, b time.Time, albl, blbl string) string {
- return CustomRelTime(a, b, albl, blbl, defaultMagnitudes)
-}
-
-// CustomRelTime formats a time into a relative string.
-//
-// It takes two times two labels and a table of relative time formats.
-// In addition to the generic time delta string (e.g. 5 minutes), the
-// labels are used applied so that the label corresponding to the
-// smaller time is applied.
-func CustomRelTime(a, b time.Time, albl, blbl string, magnitudes []RelTimeMagnitude) string {
- lbl := albl
- diff := b.Sub(a)
-
- if a.After(b) {
- lbl = blbl
- diff = a.Sub(b)
- }
-
- n := sort.Search(len(magnitudes), func(i int) bool {
- return magnitudes[i].D > diff
- })
-
- if n >= len(magnitudes) {
- n = len(magnitudes) - 1
- }
- mag := magnitudes[n]
- args := []interface{}{}
- escaped := false
- for _, ch := range mag.Format {
- if escaped {
- switch ch {
- case 's':
- args = append(args, lbl)
- case 'd':
- args = append(args, diff/mag.DivBy)
- }
- escaped = false
- } else {
- escaped = ch == '%'
- }
- }
- return fmt.Sprintf(mag.Format, args...)
-}
diff --git a/vendor/github.com/fsnotify/fsnotify/.cirrus.yml b/vendor/github.com/fsnotify/fsnotify/.cirrus.yml
deleted file mode 100644
index ffc7b99..0000000
--- a/vendor/github.com/fsnotify/fsnotify/.cirrus.yml
+++ /dev/null
@@ -1,13 +0,0 @@
-freebsd_task:
- name: 'FreeBSD'
- freebsd_instance:
- image_family: freebsd-13-2
- install_script:
- - pkg update -f
- - pkg install -y go
- test_script:
- # run tests as user "cirrus" instead of root
- - pw useradd cirrus -m
- - chown -R cirrus:cirrus .
- - FSNOTIFY_BUFFER=4096 sudo --preserve-env=FSNOTIFY_BUFFER -u cirrus go test -parallel 1 -race ./...
- - sudo --preserve-env=FSNOTIFY_BUFFER -u cirrus go test -parallel 1 -race ./...
diff --git a/vendor/github.com/fsnotify/fsnotify/.editorconfig b/vendor/github.com/fsnotify/fsnotify/.editorconfig
deleted file mode 100644
index fad8958..0000000
--- a/vendor/github.com/fsnotify/fsnotify/.editorconfig
+++ /dev/null
@@ -1,12 +0,0 @@
-root = true
-
-[*.go]
-indent_style = tab
-indent_size = 4
-insert_final_newline = true
-
-[*.{yml,yaml}]
-indent_style = space
-indent_size = 2
-insert_final_newline = true
-trim_trailing_whitespace = true
diff --git a/vendor/github.com/fsnotify/fsnotify/.gitattributes b/vendor/github.com/fsnotify/fsnotify/.gitattributes
deleted file mode 100644
index 32f1001..0000000
--- a/vendor/github.com/fsnotify/fsnotify/.gitattributes
+++ /dev/null
@@ -1 +0,0 @@
-go.sum linguist-generated
diff --git a/vendor/github.com/fsnotify/fsnotify/.gitignore b/vendor/github.com/fsnotify/fsnotify/.gitignore
deleted file mode 100644
index 391cc07..0000000
--- a/vendor/github.com/fsnotify/fsnotify/.gitignore
+++ /dev/null
@@ -1,7 +0,0 @@
-# go test -c output
-*.test
-*.test.exe
-
-# Output of go build ./cmd/fsnotify
-/fsnotify
-/fsnotify.exe
diff --git a/vendor/github.com/fsnotify/fsnotify/.mailmap b/vendor/github.com/fsnotify/fsnotify/.mailmap
deleted file mode 100644
index a04f290..0000000
--- a/vendor/github.com/fsnotify/fsnotify/.mailmap
+++ /dev/null
@@ -1,2 +0,0 @@
-Chris Howey
-Nathan Youngman <4566+nathany@users.noreply.github.com>
diff --git a/vendor/github.com/fsnotify/fsnotify/CHANGELOG.md b/vendor/github.com/fsnotify/fsnotify/CHANGELOG.md
deleted file mode 100644
index e0e5757..0000000
--- a/vendor/github.com/fsnotify/fsnotify/CHANGELOG.md
+++ /dev/null
@@ -1,541 +0,0 @@
-# Changelog
-
-Unreleased
-----------
-Nothing yet.
-
-1.7.0 - 2023-10-22
-------------------
-This version of fsnotify needs Go 1.17.
-
-### Additions
-
-- illumos: add FEN backend to support illumos and Solaris. ([#371])
-
-- all: add `NewBufferedWatcher()` to use a buffered channel, which can be useful
- in cases where you can't control the kernel buffer and receive a large number
- of events in bursts. ([#550], [#572])
-
-- all: add `AddWith()`, which is identical to `Add()` but allows passing
- options. ([#521])
-
-- windows: allow setting the ReadDirectoryChangesW() buffer size with
- `fsnotify.WithBufferSize()`; the default of 64K is the highest value that
- works on all platforms and is enough for most purposes, but in some cases a
- highest buffer is needed. ([#521])
-
-### Changes and fixes
-
-- inotify: remove watcher if a watched path is renamed ([#518])
-
- After a rename the reported name wasn't updated, or even an empty string.
- Inotify doesn't provide any good facilities to update it, so just remove the
- watcher. This is already how it worked on kqueue and FEN.
-
- On Windows this does work, and remains working.
-
-- windows: don't listen for file attribute changes ([#520])
-
- File attribute changes are sent as `FILE_ACTION_MODIFIED` by the Windows API,
- with no way to see if they're a file write or attribute change, so would show
- up as a fsnotify.Write event. This is never useful, and could result in many
- spurious Write events.
-
-- windows: return `ErrEventOverflow` if the buffer is full ([#525])
-
- Before it would merely return "short read", making it hard to detect this
- error.
-
-- kqueue: make sure events for all files are delivered properly when removing a
- watched directory ([#526])
-
- Previously they would get sent with `""` (empty string) or `"."` as the path
- name.
-
-- kqueue: don't emit spurious Create events for symbolic links ([#524])
-
- The link would get resolved but kqueue would "forget" it already saw the link
- itself, resulting on a Create for every Write event for the directory.
-
-- all: return `ErrClosed` on `Add()` when the watcher is closed ([#516])
-
-- other: add `Watcher.Errors` and `Watcher.Events` to the no-op `Watcher` in
- `backend_other.go`, making it easier to use on unsupported platforms such as
- WASM, AIX, etc. ([#528])
-
-- other: use the `backend_other.go` no-op if the `appengine` build tag is set;
- Google AppEngine forbids usage of the unsafe package so the inotify backend
- won't compile there.
-
-[#371]: https://github.com/fsnotify/fsnotify/pull/371
-[#516]: https://github.com/fsnotify/fsnotify/pull/516
-[#518]: https://github.com/fsnotify/fsnotify/pull/518
-[#520]: https://github.com/fsnotify/fsnotify/pull/520
-[#521]: https://github.com/fsnotify/fsnotify/pull/521
-[#524]: https://github.com/fsnotify/fsnotify/pull/524
-[#525]: https://github.com/fsnotify/fsnotify/pull/525
-[#526]: https://github.com/fsnotify/fsnotify/pull/526
-[#528]: https://github.com/fsnotify/fsnotify/pull/528
-[#537]: https://github.com/fsnotify/fsnotify/pull/537
-[#550]: https://github.com/fsnotify/fsnotify/pull/550
-[#572]: https://github.com/fsnotify/fsnotify/pull/572
-
-1.6.0 - 2022-10-13
-------------------
-This version of fsnotify needs Go 1.16 (this was already the case since 1.5.1,
-but not documented). It also increases the minimum Linux version to 2.6.32.
-
-### Additions
-
-- all: add `Event.Has()` and `Op.Has()` ([#477])
-
- This makes checking events a lot easier; for example:
-
- if event.Op&Write == Write && !(event.Op&Remove == Remove) {
- }
-
- Becomes:
-
- if event.Has(Write) && !event.Has(Remove) {
- }
-
-- all: add cmd/fsnotify ([#463])
-
- A command-line utility for testing and some examples.
-
-### Changes and fixes
-
-- inotify: don't ignore events for files that don't exist ([#260], [#470])
-
- Previously the inotify watcher would call `os.Lstat()` to check if a file
- still exists before emitting events.
-
- This was inconsistent with other platforms and resulted in inconsistent event
- reporting (e.g. when a file is quickly removed and re-created), and generally
- a source of confusion. It was added in 2013 to fix a memory leak that no
- longer exists.
-
-- all: return `ErrNonExistentWatch` when `Remove()` is called on a path that's
- not watched ([#460])
-
-- inotify: replace epoll() with non-blocking inotify ([#434])
-
- Non-blocking inotify was not generally available at the time this library was
- written in 2014, but now it is. As a result, the minimum Linux version is
- bumped from 2.6.27 to 2.6.32. This hugely simplifies the code and is faster.
-
-- kqueue: don't check for events every 100ms ([#480])
-
- The watcher would wake up every 100ms, even when there was nothing to do. Now
- it waits until there is something to do.
-
-- macos: retry opening files on EINTR ([#475])
-
-- kqueue: skip unreadable files ([#479])
-
- kqueue requires a file descriptor for every file in a directory; this would
- fail if a file was unreadable by the current user. Now these files are simply
- skipped.
-
-- windows: fix renaming a watched directory if the parent is also watched ([#370])
-
-- windows: increase buffer size from 4K to 64K ([#485])
-
-- windows: close file handle on Remove() ([#288])
-
-- kqueue: put pathname in the error if watching a file fails ([#471])
-
-- inotify, windows: calling Close() more than once could race ([#465])
-
-- kqueue: improve Close() performance ([#233])
-
-- all: various documentation additions and clarifications.
-
-[#233]: https://github.com/fsnotify/fsnotify/pull/233
-[#260]: https://github.com/fsnotify/fsnotify/pull/260
-[#288]: https://github.com/fsnotify/fsnotify/pull/288
-[#370]: https://github.com/fsnotify/fsnotify/pull/370
-[#434]: https://github.com/fsnotify/fsnotify/pull/434
-[#460]: https://github.com/fsnotify/fsnotify/pull/460
-[#463]: https://github.com/fsnotify/fsnotify/pull/463
-[#465]: https://github.com/fsnotify/fsnotify/pull/465
-[#470]: https://github.com/fsnotify/fsnotify/pull/470
-[#471]: https://github.com/fsnotify/fsnotify/pull/471
-[#475]: https://github.com/fsnotify/fsnotify/pull/475
-[#477]: https://github.com/fsnotify/fsnotify/pull/477
-[#479]: https://github.com/fsnotify/fsnotify/pull/479
-[#480]: https://github.com/fsnotify/fsnotify/pull/480
-[#485]: https://github.com/fsnotify/fsnotify/pull/485
-
-## [1.5.4] - 2022-04-25
-
-* Windows: add missing defer to `Watcher.WatchList` [#447](https://github.com/fsnotify/fsnotify/pull/447)
-* go.mod: use latest x/sys [#444](https://github.com/fsnotify/fsnotify/pull/444)
-* Fix compilation for OpenBSD [#443](https://github.com/fsnotify/fsnotify/pull/443)
-
-## [1.5.3] - 2022-04-22
-
-* This version is retracted. An incorrect branch is published accidentally [#445](https://github.com/fsnotify/fsnotify/issues/445)
-
-## [1.5.2] - 2022-04-21
-
-* Add a feature to return the directories and files that are being monitored [#374](https://github.com/fsnotify/fsnotify/pull/374)
-* Fix potential crash on windows if `raw.FileNameLength` exceeds `syscall.MAX_PATH` [#361](https://github.com/fsnotify/fsnotify/pull/361)
-* Allow build on unsupported GOOS [#424](https://github.com/fsnotify/fsnotify/pull/424)
-* Don't set `poller.fd` twice in `newFdPoller` [#406](https://github.com/fsnotify/fsnotify/pull/406)
-* fix go vet warnings: call to `(*T).Fatalf` from a non-test goroutine [#416](https://github.com/fsnotify/fsnotify/pull/416)
-
-## [1.5.1] - 2021-08-24
-
-* Revert Add AddRaw to not follow symlinks [#394](https://github.com/fsnotify/fsnotify/pull/394)
-
-## [1.5.0] - 2021-08-20
-
-* Go: Increase minimum required version to Go 1.12 [#381](https://github.com/fsnotify/fsnotify/pull/381)
-* Feature: Add AddRaw method which does not follow symlinks when adding a watch [#289](https://github.com/fsnotify/fsnotify/pull/298)
-* Windows: Follow symlinks by default like on all other systems [#289](https://github.com/fsnotify/fsnotify/pull/289)
-* CI: Use GitHub Actions for CI and cover go 1.12-1.17
- [#378](https://github.com/fsnotify/fsnotify/pull/378)
- [#381](https://github.com/fsnotify/fsnotify/pull/381)
- [#385](https://github.com/fsnotify/fsnotify/pull/385)
-* Go 1.14+: Fix unsafe pointer conversion [#325](https://github.com/fsnotify/fsnotify/pull/325)
-
-## [1.4.9] - 2020-03-11
-
-* Move example usage to the readme #329. This may resolve #328.
-
-## [1.4.8] - 2020-03-10
-
-* CI: test more go versions (@nathany 1d13583d846ea9d66dcabbfefbfb9d8e6fb05216)
-* Tests: Queued inotify events could have been read by the test before max_queued_events was hit (@matthias-stone #265)
-* Tests: t.Fatalf -> t.Errorf in go routines (@gdey #266)
-* CI: Less verbosity (@nathany #267)
-* Tests: Darwin: Exchangedata is deprecated on 10.13 (@nathany #267)
-* Tests: Check if channels are closed in the example (@alexeykazakov #244)
-* CI: Only run golint on latest version of go and fix issues (@cpuguy83 #284)
-* CI: Add windows to travis matrix (@cpuguy83 #284)
-* Docs: Remover appveyor badge (@nathany 11844c0959f6fff69ba325d097fce35bd85a8e93)
-* Linux: create epoll and pipe fds with close-on-exec (@JohannesEbke #219)
-* Linux: open files with close-on-exec (@linxiulei #273)
-* Docs: Plan to support fanotify (@nathany ab058b44498e8b7566a799372a39d150d9ea0119 )
-* Project: Add go.mod (@nathany #309)
-* Project: Revise editor config (@nathany #309)
-* Project: Update copyright for 2019 (@nathany #309)
-* CI: Drop go1.8 from CI matrix (@nathany #309)
-* Docs: Updating the FAQ section for supportability with NFS & FUSE filesystems (@Pratik32 4bf2d1fec78374803a39307bfb8d340688f4f28e )
-
-## [1.4.7] - 2018-01-09
-
-* BSD/macOS: Fix possible deadlock on closing the watcher on kqueue (thanks @nhooyr and @glycerine)
-* Tests: Fix missing verb on format string (thanks @rchiossi)
-* Linux: Fix deadlock in Remove (thanks @aarondl)
-* Linux: Watch.Add improvements (avoid race, fix consistency, reduce garbage) (thanks @twpayne)
-* Docs: Moved FAQ into the README (thanks @vahe)
-* Linux: Properly handle inotify's IN_Q_OVERFLOW event (thanks @zeldovich)
-* Docs: replace references to OS X with macOS
-
-## [1.4.2] - 2016-10-10
-
-* Linux: use InotifyInit1 with IN_CLOEXEC to stop leaking a file descriptor to a child process when using fork/exec [#178](https://github.com/fsnotify/fsnotify/pull/178) (thanks @pattyshack)
-
-## [1.4.1] - 2016-10-04
-
-* Fix flaky inotify stress test on Linux [#177](https://github.com/fsnotify/fsnotify/pull/177) (thanks @pattyshack)
-
-## [1.4.0] - 2016-10-01
-
-* add a String() method to Event.Op [#165](https://github.com/fsnotify/fsnotify/pull/165) (thanks @oozie)
-
-## [1.3.1] - 2016-06-28
-
-* Windows: fix for double backslash when watching the root of a drive [#151](https://github.com/fsnotify/fsnotify/issues/151) (thanks @brunoqc)
-
-## [1.3.0] - 2016-04-19
-
-* Support linux/arm64 by [patching](https://go-review.googlesource.com/#/c/21971/) x/sys/unix and switching to to it from syscall (thanks @suihkulokki) [#135](https://github.com/fsnotify/fsnotify/pull/135)
-
-## [1.2.10] - 2016-03-02
-
-* Fix golint errors in windows.go [#121](https://github.com/fsnotify/fsnotify/pull/121) (thanks @tiffanyfj)
-
-## [1.2.9] - 2016-01-13
-
-kqueue: Fix logic for CREATE after REMOVE [#111](https://github.com/fsnotify/fsnotify/pull/111) (thanks @bep)
-
-## [1.2.8] - 2015-12-17
-
-* kqueue: fix race condition in Close [#105](https://github.com/fsnotify/fsnotify/pull/105) (thanks @djui for reporting the issue and @ppknap for writing a failing test)
-* inotify: fix race in test
-* enable race detection for continuous integration (Linux, Mac, Windows)
-
-## [1.2.5] - 2015-10-17
-
-* inotify: use epoll_create1 for arm64 support (requires Linux 2.6.27 or later) [#100](https://github.com/fsnotify/fsnotify/pull/100) (thanks @suihkulokki)
-* inotify: fix path leaks [#73](https://github.com/fsnotify/fsnotify/pull/73) (thanks @chamaken)
-* kqueue: watch for rename events on subdirectories [#83](https://github.com/fsnotify/fsnotify/pull/83) (thanks @guotie)
-* kqueue: avoid infinite loops from symlinks cycles [#101](https://github.com/fsnotify/fsnotify/pull/101) (thanks @illicitonion)
-
-## [1.2.1] - 2015-10-14
-
-* kqueue: don't watch named pipes [#98](https://github.com/fsnotify/fsnotify/pull/98) (thanks @evanphx)
-
-## [1.2.0] - 2015-02-08
-
-* inotify: use epoll to wake up readEvents [#66](https://github.com/fsnotify/fsnotify/pull/66) (thanks @PieterD)
-* inotify: closing watcher should now always shut down goroutine [#63](https://github.com/fsnotify/fsnotify/pull/63) (thanks @PieterD)
-* kqueue: close kqueue after removing watches, fixes [#59](https://github.com/fsnotify/fsnotify/issues/59)
-
-## [1.1.1] - 2015-02-05
-
-* inotify: Retry read on EINTR [#61](https://github.com/fsnotify/fsnotify/issues/61) (thanks @PieterD)
-
-## [1.1.0] - 2014-12-12
-
-* kqueue: rework internals [#43](https://github.com/fsnotify/fsnotify/pull/43)
- * add low-level functions
- * only need to store flags on directories
- * less mutexes [#13](https://github.com/fsnotify/fsnotify/issues/13)
- * done can be an unbuffered channel
- * remove calls to os.NewSyscallError
-* More efficient string concatenation for Event.String() [#52](https://github.com/fsnotify/fsnotify/pull/52) (thanks @mdlayher)
-* kqueue: fix regression in rework causing subdirectories to be watched [#48](https://github.com/fsnotify/fsnotify/issues/48)
-* kqueue: cleanup internal watch before sending remove event [#51](https://github.com/fsnotify/fsnotify/issues/51)
-
-## [1.0.4] - 2014-09-07
-
-* kqueue: add dragonfly to the build tags.
-* Rename source code files, rearrange code so exported APIs are at the top.
-* Add done channel to example code. [#37](https://github.com/fsnotify/fsnotify/pull/37) (thanks @chenyukang)
-
-## [1.0.3] - 2014-08-19
-
-* [Fix] Windows MOVED_TO now translates to Create like on BSD and Linux. [#36](https://github.com/fsnotify/fsnotify/issues/36)
-
-## [1.0.2] - 2014-08-17
-
-* [Fix] Missing create events on macOS. [#14](https://github.com/fsnotify/fsnotify/issues/14) (thanks @zhsso)
-* [Fix] Make ./path and path equivalent. (thanks @zhsso)
-
-## [1.0.0] - 2014-08-15
-
-* [API] Remove AddWatch on Windows, use Add.
-* Improve documentation for exported identifiers. [#30](https://github.com/fsnotify/fsnotify/issues/30)
-* Minor updates based on feedback from golint.
-
-## dev / 2014-07-09
-
-* Moved to [github.com/fsnotify/fsnotify](https://github.com/fsnotify/fsnotify).
-* Use os.NewSyscallError instead of returning errno (thanks @hariharan-uno)
-
-## dev / 2014-07-04
-
-* kqueue: fix incorrect mutex used in Close()
-* Update example to demonstrate usage of Op.
-
-## dev / 2014-06-28
-
-* [API] Don't set the Write Op for attribute notifications [#4](https://github.com/fsnotify/fsnotify/issues/4)
-* Fix for String() method on Event (thanks Alex Brainman)
-* Don't build on Plan 9 or Solaris (thanks @4ad)
-
-## dev / 2014-06-21
-
-* Events channel of type Event rather than *Event.
-* [internal] use syscall constants directly for inotify and kqueue.
-* [internal] kqueue: rename events to kevents and fileEvent to event.
-
-## dev / 2014-06-19
-
-* Go 1.3+ required on Windows (uses syscall.ERROR_MORE_DATA internally).
-* [internal] remove cookie from Event struct (unused).
-* [internal] Event struct has the same definition across every OS.
-* [internal] remove internal watch and removeWatch methods.
-
-## dev / 2014-06-12
-
-* [API] Renamed Watch() to Add() and RemoveWatch() to Remove().
-* [API] Pluralized channel names: Events and Errors.
-* [API] Renamed FileEvent struct to Event.
-* [API] Op constants replace methods like IsCreate().
-
-## dev / 2014-06-12
-
-* Fix data race on kevent buffer (thanks @tilaks) [#98](https://github.com/howeyc/fsnotify/pull/98)
-
-## dev / 2014-05-23
-
-* [API] Remove current implementation of WatchFlags.
- * current implementation doesn't take advantage of OS for efficiency
- * provides little benefit over filtering events as they are received, but has extra bookkeeping and mutexes
- * no tests for the current implementation
- * not fully implemented on Windows [#93](https://github.com/howeyc/fsnotify/issues/93#issuecomment-39285195)
-
-## [0.9.3] - 2014-12-31
-
-* kqueue: cleanup internal watch before sending remove event [#51](https://github.com/fsnotify/fsnotify/issues/51)
-
-## [0.9.2] - 2014-08-17
-
-* [Backport] Fix missing create events on macOS. [#14](https://github.com/fsnotify/fsnotify/issues/14) (thanks @zhsso)
-
-## [0.9.1] - 2014-06-12
-
-* Fix data race on kevent buffer (thanks @tilaks) [#98](https://github.com/howeyc/fsnotify/pull/98)
-
-## [0.9.0] - 2014-01-17
-
-* IsAttrib() for events that only concern a file's metadata [#79][] (thanks @abustany)
-* [Fix] kqueue: fix deadlock [#77][] (thanks @cespare)
-* [NOTICE] Development has moved to `code.google.com/p/go.exp/fsnotify` in preparation for inclusion in the Go standard library.
-
-## [0.8.12] - 2013-11-13
-
-* [API] Remove FD_SET and friends from Linux adapter
-
-## [0.8.11] - 2013-11-02
-
-* [Doc] Add Changelog [#72][] (thanks @nathany)
-* [Doc] Spotlight and double modify events on macOS [#62][] (reported by @paulhammond)
-
-## [0.8.10] - 2013-10-19
-
-* [Fix] kqueue: remove file watches when parent directory is removed [#71][] (reported by @mdwhatcott)
-* [Fix] kqueue: race between Close and readEvents [#70][] (reported by @bernerdschaefer)
-* [Doc] specify OS-specific limits in README (thanks @debrando)
-
-## [0.8.9] - 2013-09-08
-
-* [Doc] Contributing (thanks @nathany)
-* [Doc] update package path in example code [#63][] (thanks @paulhammond)
-* [Doc] GoCI badge in README (Linux only) [#60][]
-* [Doc] Cross-platform testing with Vagrant [#59][] (thanks @nathany)
-
-## [0.8.8] - 2013-06-17
-
-* [Fix] Windows: handle `ERROR_MORE_DATA` on Windows [#49][] (thanks @jbowtie)
-
-## [0.8.7] - 2013-06-03
-
-* [API] Make syscall flags internal
-* [Fix] inotify: ignore event changes
-* [Fix] race in symlink test [#45][] (reported by @srid)
-* [Fix] tests on Windows
-* lower case error messages
-
-## [0.8.6] - 2013-05-23
-
-* kqueue: Use EVT_ONLY flag on Darwin
-* [Doc] Update README with full example
-
-## [0.8.5] - 2013-05-09
-
-* [Fix] inotify: allow monitoring of "broken" symlinks (thanks @tsg)
-
-## [0.8.4] - 2013-04-07
-
-* [Fix] kqueue: watch all file events [#40][] (thanks @ChrisBuchholz)
-
-## [0.8.3] - 2013-03-13
-
-* [Fix] inoitfy/kqueue memory leak [#36][] (reported by @nbkolchin)
-* [Fix] kqueue: use fsnFlags for watching a directory [#33][] (reported by @nbkolchin)
-
-## [0.8.2] - 2013-02-07
-
-* [Doc] add Authors
-* [Fix] fix data races for map access [#29][] (thanks @fsouza)
-
-## [0.8.1] - 2013-01-09
-
-* [Fix] Windows path separators
-* [Doc] BSD License
-
-## [0.8.0] - 2012-11-09
-
-* kqueue: directory watching improvements (thanks @vmirage)
-* inotify: add `IN_MOVED_TO` [#25][] (requested by @cpisto)
-* [Fix] kqueue: deleting watched directory [#24][] (reported by @jakerr)
-
-## [0.7.4] - 2012-10-09
-
-* [Fix] inotify: fixes from https://codereview.appspot.com/5418045/ (ugorji)
-* [Fix] kqueue: preserve watch flags when watching for delete [#21][] (reported by @robfig)
-* [Fix] kqueue: watch the directory even if it isn't a new watch (thanks @robfig)
-* [Fix] kqueue: modify after recreation of file
-
-## [0.7.3] - 2012-09-27
-
-* [Fix] kqueue: watch with an existing folder inside the watched folder (thanks @vmirage)
-* [Fix] kqueue: no longer get duplicate CREATE events
-
-## [0.7.2] - 2012-09-01
-
-* kqueue: events for created directories
-
-## [0.7.1] - 2012-07-14
-
-* [Fix] for renaming files
-
-## [0.7.0] - 2012-07-02
-
-* [Feature] FSNotify flags
-* [Fix] inotify: Added file name back to event path
-
-## [0.6.0] - 2012-06-06
-
-* kqueue: watch files after directory created (thanks @tmc)
-
-## [0.5.1] - 2012-05-22
-
-* [Fix] inotify: remove all watches before Close()
-
-## [0.5.0] - 2012-05-03
-
-* [API] kqueue: return errors during watch instead of sending over channel
-* kqueue: match symlink behavior on Linux
-* inotify: add `DELETE_SELF` (requested by @taralx)
-* [Fix] kqueue: handle EINTR (reported by @robfig)
-* [Doc] Godoc example [#1][] (thanks @davecheney)
-
-## [0.4.0] - 2012-03-30
-
-* Go 1 released: build with go tool
-* [Feature] Windows support using winfsnotify
-* Windows does not have attribute change notifications
-* Roll attribute notifications into IsModify
-
-## [0.3.0] - 2012-02-19
-
-* kqueue: add files when watch directory
-
-## [0.2.0] - 2011-12-30
-
-* update to latest Go weekly code
-
-## [0.1.0] - 2011-10-19
-
-* kqueue: add watch on file creation to match inotify
-* kqueue: create file event
-* inotify: ignore `IN_IGNORED` events
-* event String()
-* linux: common FileEvent functions
-* initial commit
-
-[#79]: https://github.com/howeyc/fsnotify/pull/79
-[#77]: https://github.com/howeyc/fsnotify/pull/77
-[#72]: https://github.com/howeyc/fsnotify/issues/72
-[#71]: https://github.com/howeyc/fsnotify/issues/71
-[#70]: https://github.com/howeyc/fsnotify/issues/70
-[#63]: https://github.com/howeyc/fsnotify/issues/63
-[#62]: https://github.com/howeyc/fsnotify/issues/62
-[#60]: https://github.com/howeyc/fsnotify/issues/60
-[#59]: https://github.com/howeyc/fsnotify/issues/59
-[#49]: https://github.com/howeyc/fsnotify/issues/49
-[#45]: https://github.com/howeyc/fsnotify/issues/45
-[#40]: https://github.com/howeyc/fsnotify/issues/40
-[#36]: https://github.com/howeyc/fsnotify/issues/36
-[#33]: https://github.com/howeyc/fsnotify/issues/33
-[#29]: https://github.com/howeyc/fsnotify/issues/29
-[#25]: https://github.com/howeyc/fsnotify/issues/25
-[#24]: https://github.com/howeyc/fsnotify/issues/24
-[#21]: https://github.com/howeyc/fsnotify/issues/21
diff --git a/vendor/github.com/fsnotify/fsnotify/CONTRIBUTING.md b/vendor/github.com/fsnotify/fsnotify/CONTRIBUTING.md
deleted file mode 100644
index ea37975..0000000
--- a/vendor/github.com/fsnotify/fsnotify/CONTRIBUTING.md
+++ /dev/null
@@ -1,26 +0,0 @@
-Thank you for your interest in contributing to fsnotify! We try to review and
-merge PRs in a reasonable timeframe, but please be aware that:
-
-- To avoid "wasted" work, please discus changes on the issue tracker first. You
- can just send PRs, but they may end up being rejected for one reason or the
- other.
-
-- fsnotify is a cross-platform library, and changes must work reasonably well on
- all supported platforms.
-
-- Changes will need to be compatible; old code should still compile, and the
- runtime behaviour can't change in ways that are likely to lead to problems for
- users.
-
-Testing
--------
-Just `go test ./...` runs all the tests; the CI runs this on all supported
-platforms. Testing different platforms locally can be done with something like
-[goon] or [Vagrant], but this isn't super-easy to set up at the moment.
-
-Use the `-short` flag to make the "stress test" run faster.
-
-
-[goon]: https://github.com/arp242/goon
-[Vagrant]: https://www.vagrantup.com/
-[integration_test.go]: /integration_test.go
diff --git a/vendor/github.com/fsnotify/fsnotify/LICENSE b/vendor/github.com/fsnotify/fsnotify/LICENSE
deleted file mode 100644
index fb03ade..0000000
--- a/vendor/github.com/fsnotify/fsnotify/LICENSE
+++ /dev/null
@@ -1,25 +0,0 @@
-Copyright © 2012 The Go Authors. All rights reserved.
-Copyright © fsnotify 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.
diff --git a/vendor/github.com/fsnotify/fsnotify/README.md b/vendor/github.com/fsnotify/fsnotify/README.md
deleted file mode 100644
index e480733..0000000
--- a/vendor/github.com/fsnotify/fsnotify/README.md
+++ /dev/null
@@ -1,184 +0,0 @@
-fsnotify is a Go library to provide cross-platform filesystem notifications on
-Windows, Linux, macOS, BSD, and illumos.
-
-Go 1.17 or newer is required; the full documentation is at
-https://pkg.go.dev/github.com/fsnotify/fsnotify
-
----
-
-Platform support:
-
-| Backend | OS | Status |
-| :-------------------- | :--------- | :------------------------------------------------------------------------ |
-| inotify | Linux | Supported |
-| kqueue | BSD, macOS | Supported |
-| ReadDirectoryChangesW | Windows | Supported |
-| FEN | illumos | Supported |
-| fanotify | Linux 5.9+ | [Not yet](https://github.com/fsnotify/fsnotify/issues/114) |
-| AHAFS | AIX | [aix branch]; experimental due to lack of maintainer and test environment |
-| FSEvents | macOS | [Needs support in x/sys/unix][fsevents] |
-| USN Journals | Windows | [Needs support in x/sys/windows][usn] |
-| Polling | *All* | [Not yet](https://github.com/fsnotify/fsnotify/issues/9) |
-
-Linux and illumos should include Android and Solaris, but these are currently
-untested.
-
-[fsevents]: https://github.com/fsnotify/fsnotify/issues/11#issuecomment-1279133120
-[usn]: https://github.com/fsnotify/fsnotify/issues/53#issuecomment-1279829847
-[aix branch]: https://github.com/fsnotify/fsnotify/issues/353#issuecomment-1284590129
-
-Usage
------
-A basic example:
-
-```go
-package main
-
-import (
- "log"
-
- "github.com/fsnotify/fsnotify"
-)
-
-func main() {
- // Create new watcher.
- watcher, err := fsnotify.NewWatcher()
- if err != nil {
- log.Fatal(err)
- }
- defer watcher.Close()
-
- // Start listening for events.
- go func() {
- for {
- select {
- case event, ok := <-watcher.Events:
- if !ok {
- return
- }
- log.Println("event:", event)
- if event.Has(fsnotify.Write) {
- log.Println("modified file:", event.Name)
- }
- case err, ok := <-watcher.Errors:
- if !ok {
- return
- }
- log.Println("error:", err)
- }
- }
- }()
-
- // Add a path.
- err = watcher.Add("/tmp")
- if err != nil {
- log.Fatal(err)
- }
-
- // Block main goroutine forever.
- <-make(chan struct{})
-}
-```
-
-Some more examples can be found in [cmd/fsnotify](cmd/fsnotify), which can be
-run with:
-
- % go run ./cmd/fsnotify
-
-Further detailed documentation can be found in godoc:
-https://pkg.go.dev/github.com/fsnotify/fsnotify
-
-FAQ
----
-### Will a file still be watched when it's moved to another directory?
-No, not unless you are watching the location it was moved to.
-
-### Are subdirectories watched?
-No, you must add watches for any directory you want to watch (a recursive
-watcher is on the roadmap: [#18]).
-
-[#18]: https://github.com/fsnotify/fsnotify/issues/18
-
-### Do I have to watch the Error and Event channels in a goroutine?
-Yes. You can read both channels in the same goroutine using `select` (you don't
-need a separate goroutine for both channels; see the example).
-
-### Why don't notifications work with NFS, SMB, FUSE, /proc, or /sys?
-fsnotify requires support from underlying OS to work. The current NFS and SMB
-protocols does not provide network level support for file notifications, and
-neither do the /proc and /sys virtual filesystems.
-
-This could be fixed with a polling watcher ([#9]), but it's not yet implemented.
-
-[#9]: https://github.com/fsnotify/fsnotify/issues/9
-
-### Why do I get many Chmod events?
-Some programs may generate a lot of attribute changes; for example Spotlight on
-macOS, anti-virus programs, backup applications, and some others are known to do
-this. As a rule, it's typically best to ignore Chmod events. They're often not
-useful, and tend to cause problems.
-
-Spotlight indexing on macOS can result in multiple events (see [#15]). A
-temporary workaround is to add your folder(s) to the *Spotlight Privacy
-settings* until we have a native FSEvents implementation (see [#11]).
-
-[#11]: https://github.com/fsnotify/fsnotify/issues/11
-[#15]: https://github.com/fsnotify/fsnotify/issues/15
-
-### Watching a file doesn't work well
-Watching individual files (rather than directories) is generally not recommended
-as many programs (especially editors) update files atomically: it will write to
-a temporary file which is then moved to to destination, overwriting the original
-(or some variant thereof). The watcher on the original file is now lost, as that
-no longer exists.
-
-The upshot of this is that a power failure or crash won't leave a half-written
-file.
-
-Watch the parent directory and use `Event.Name` to filter out files you're not
-interested in. There is an example of this in `cmd/fsnotify/file.go`.
-
-Platform-specific notes
------------------------
-### Linux
-When a file is removed a REMOVE event won't be emitted until all file
-descriptors are closed; it will emit a CHMOD instead:
-
- fp := os.Open("file")
- os.Remove("file") // CHMOD
- fp.Close() // REMOVE
-
-This is the event that inotify sends, so not much can be changed about this.
-
-The `fs.inotify.max_user_watches` sysctl variable specifies the upper limit for
-the number of watches per user, and `fs.inotify.max_user_instances` specifies
-the maximum number of inotify instances per user. Every Watcher you create is an
-"instance", and every path you add is a "watch".
-
-These are also exposed in `/proc` as `/proc/sys/fs/inotify/max_user_watches` and
-`/proc/sys/fs/inotify/max_user_instances`
-
-To increase them you can use `sysctl` or write the value to proc file:
-
- # The default values on Linux 5.18
- sysctl fs.inotify.max_user_watches=124983
- sysctl fs.inotify.max_user_instances=128
-
-To make the changes persist on reboot edit `/etc/sysctl.conf` or
-`/usr/lib/sysctl.d/50-default.conf` (details differ per Linux distro; check your
-distro's documentation):
-
- fs.inotify.max_user_watches=124983
- fs.inotify.max_user_instances=128
-
-Reaching the limit will result in a "no space left on device" or "too many open
-files" error.
-
-### kqueue (macOS, all BSD systems)
-kqueue requires opening a file descriptor for every file that's being watched;
-so if you're watching a directory with five files then that's six file
-descriptors. You will run in to your system's "max open files" limit faster on
-these platforms.
-
-The sysctl variables `kern.maxfiles` and `kern.maxfilesperproc` can be used to
-control the maximum number of open files.
diff --git a/vendor/github.com/fsnotify/fsnotify/backend_fen.go b/vendor/github.com/fsnotify/fsnotify/backend_fen.go
deleted file mode 100644
index 28497f1..0000000
--- a/vendor/github.com/fsnotify/fsnotify/backend_fen.go
+++ /dev/null
@@ -1,640 +0,0 @@
-//go:build solaris
-// +build solaris
-
-// Note: the documentation on the Watcher type and methods is generated from
-// mkdoc.zsh
-
-package fsnotify
-
-import (
- "errors"
- "fmt"
- "os"
- "path/filepath"
- "sync"
-
- "golang.org/x/sys/unix"
-)
-
-// Watcher watches a set of paths, delivering events on a channel.
-//
-// A watcher should not be copied (e.g. pass it by pointer, rather than by
-// value).
-//
-// # Linux notes
-//
-// When a file is removed a Remove event won't be emitted until all file
-// descriptors are closed, and deletes will always emit a Chmod. For example:
-//
-// fp := os.Open("file")
-// os.Remove("file") // Triggers Chmod
-// fp.Close() // Triggers Remove
-//
-// This is the event that inotify sends, so not much can be changed about this.
-//
-// The fs.inotify.max_user_watches sysctl variable specifies the upper limit
-// for the number of watches per user, and fs.inotify.max_user_instances
-// specifies the maximum number of inotify instances per user. Every Watcher you
-// create is an "instance", and every path you add is a "watch".
-//
-// These are also exposed in /proc as /proc/sys/fs/inotify/max_user_watches and
-// /proc/sys/fs/inotify/max_user_instances
-//
-// To increase them you can use sysctl or write the value to the /proc file:
-//
-// # Default values on Linux 5.18
-// sysctl fs.inotify.max_user_watches=124983
-// sysctl fs.inotify.max_user_instances=128
-//
-// To make the changes persist on reboot edit /etc/sysctl.conf or
-// /usr/lib/sysctl.d/50-default.conf (details differ per Linux distro; check
-// your distro's documentation):
-//
-// fs.inotify.max_user_watches=124983
-// fs.inotify.max_user_instances=128
-//
-// Reaching the limit will result in a "no space left on device" or "too many open
-// files" error.
-//
-// # kqueue notes (macOS, BSD)
-//
-// kqueue requires opening a file descriptor for every file that's being watched;
-// so if you're watching a directory with five files then that's six file
-// descriptors. You will run in to your system's "max open files" limit faster on
-// these platforms.
-//
-// The sysctl variables kern.maxfiles and kern.maxfilesperproc can be used to
-// control the maximum number of open files, as well as /etc/login.conf on BSD
-// systems.
-//
-// # Windows notes
-//
-// Paths can be added as "C:\path\to\dir", but forward slashes
-// ("C:/path/to/dir") will also work.
-//
-// When a watched directory is removed it will always send an event for the
-// directory itself, but may not send events for all files in that directory.
-// Sometimes it will send events for all times, sometimes it will send no
-// events, and often only for some files.
-//
-// The default ReadDirectoryChangesW() buffer size is 64K, which is the largest
-// value that is guaranteed to work with SMB filesystems. If you have many
-// events in quick succession this may not be enough, and you will have to use
-// [WithBufferSize] to increase the value.
-type Watcher struct {
- // Events sends the filesystem change events.
- //
- // fsnotify can send the following events; a "path" here can refer to a
- // file, directory, symbolic link, or special file like a FIFO.
- //
- // fsnotify.Create A new path was created; this may be followed by one
- // or more Write events if data also gets written to a
- // file.
- //
- // fsnotify.Remove A path was removed.
- //
- // fsnotify.Rename A path was renamed. A rename is always sent with the
- // old path as Event.Name, and a Create event will be
- // sent with the new name. Renames are only sent for
- // paths that are currently watched; e.g. moving an
- // unmonitored file into a monitored directory will
- // show up as just a Create. Similarly, renaming a file
- // to outside a monitored directory will show up as
- // only a Rename.
- //
- // fsnotify.Write A file or named pipe was written to. A Truncate will
- // also trigger a Write. A single "write action"
- // initiated by the user may show up as one or multiple
- // writes, depending on when the system syncs things to
- // disk. For example when compiling a large Go program
- // you may get hundreds of Write events, and you may
- // want to wait until you've stopped receiving them
- // (see the dedup example in cmd/fsnotify).
- //
- // Some systems may send Write event for directories
- // when the directory content changes.
- //
- // fsnotify.Chmod Attributes were changed. On Linux this is also sent
- // when a file is removed (or more accurately, when a
- // link to an inode is removed). On kqueue it's sent
- // when a file is truncated. On Windows it's never
- // sent.
- Events chan Event
-
- // Errors sends any errors.
- //
- // ErrEventOverflow is used to indicate there are too many events:
- //
- // - inotify: There are too many queued events (fs.inotify.max_queued_events sysctl)
- // - windows: The buffer size is too small; WithBufferSize() can be used to increase it.
- // - kqueue, fen: Not used.
- Errors chan error
-
- mu sync.Mutex
- port *unix.EventPort
- done chan struct{} // Channel for sending a "quit message" to the reader goroutine
- dirs map[string]struct{} // Explicitly watched directories
- watches map[string]struct{} // Explicitly watched non-directories
-}
-
-// NewWatcher creates a new Watcher.
-func NewWatcher() (*Watcher, error) {
- return NewBufferedWatcher(0)
-}
-
-// NewBufferedWatcher creates a new Watcher with a buffered Watcher.Events
-// channel.
-//
-// The main use case for this is situations with a very large number of events
-// where the kernel buffer size can't be increased (e.g. due to lack of
-// permissions). An unbuffered Watcher will perform better for almost all use
-// cases, and whenever possible you will be better off increasing the kernel
-// buffers instead of adding a large userspace buffer.
-func NewBufferedWatcher(sz uint) (*Watcher, error) {
- w := &Watcher{
- Events: make(chan Event, sz),
- Errors: make(chan error),
- dirs: make(map[string]struct{}),
- watches: make(map[string]struct{}),
- done: make(chan struct{}),
- }
-
- var err error
- w.port, err = unix.NewEventPort()
- if err != nil {
- return nil, fmt.Errorf("fsnotify.NewWatcher: %w", err)
- }
-
- go w.readEvents()
- return w, nil
-}
-
-// sendEvent attempts to send an event to the user, returning true if the event
-// was put in the channel successfully and false if the watcher has been closed.
-func (w *Watcher) sendEvent(name string, op Op) (sent bool) {
- select {
- case w.Events <- Event{Name: name, Op: op}:
- return true
- case <-w.done:
- return false
- }
-}
-
-// sendError attempts to send an error to the user, returning true if the error
-// was put in the channel successfully and false if the watcher has been closed.
-func (w *Watcher) sendError(err error) (sent bool) {
- select {
- case w.Errors <- err:
- return true
- case <-w.done:
- return false
- }
-}
-
-func (w *Watcher) isClosed() bool {
- select {
- case <-w.done:
- return true
- default:
- return false
- }
-}
-
-// Close removes all watches and closes the Events channel.
-func (w *Watcher) Close() error {
- // Take the lock used by associateFile to prevent lingering events from
- // being processed after the close
- w.mu.Lock()
- defer w.mu.Unlock()
- if w.isClosed() {
- return nil
- }
- close(w.done)
- return w.port.Close()
-}
-
-// Add starts monitoring the path for changes.
-//
-// A path can only be watched once; watching it more than once is a no-op and will
-// not return an error. Paths that do not yet exist on the filesystem cannot be
-// watched.
-//
-// A watch will be automatically removed if the watched path is deleted or
-// renamed. The exception is the Windows backend, which doesn't remove the
-// watcher on renames.
-//
-// Notifications on network filesystems (NFS, SMB, FUSE, etc.) or special
-// filesystems (/proc, /sys, etc.) generally don't work.
-//
-// Returns [ErrClosed] if [Watcher.Close] was called.
-//
-// See [Watcher.AddWith] for a version that allows adding options.
-//
-// # Watching directories
-//
-// All files in a directory are monitored, including new files that are created
-// after the watcher is started. Subdirectories are not watched (i.e. it's
-// non-recursive).
-//
-// # Watching files
-//
-// Watching individual files (rather than directories) is generally not
-// recommended as many programs (especially editors) update files atomically: it
-// will write to a temporary file which is then moved to to destination,
-// overwriting the original (or some variant thereof). The watcher on the
-// original file is now lost, as that no longer exists.
-//
-// The upshot of this is that a power failure or crash won't leave a
-// half-written file.
-//
-// Watch the parent directory and use Event.Name to filter out files you're not
-// interested in. There is an example of this in cmd/fsnotify/file.go.
-func (w *Watcher) Add(name string) error { return w.AddWith(name) }
-
-// AddWith is like [Watcher.Add], but allows adding options. When using Add()
-// the defaults described below are used.
-//
-// Possible options are:
-//
-// - [WithBufferSize] sets the buffer size for the Windows backend; no-op on
-// other platforms. The default is 64K (65536 bytes).
-func (w *Watcher) AddWith(name string, opts ...addOpt) error {
- if w.isClosed() {
- return ErrClosed
- }
- if w.port.PathIsWatched(name) {
- return nil
- }
-
- _ = getOptions(opts...)
-
- // Currently we resolve symlinks that were explicitly requested to be
- // watched. Otherwise we would use LStat here.
- stat, err := os.Stat(name)
- if err != nil {
- return err
- }
-
- // Associate all files in the directory.
- if stat.IsDir() {
- err := w.handleDirectory(name, stat, true, w.associateFile)
- if err != nil {
- return err
- }
-
- w.mu.Lock()
- w.dirs[name] = struct{}{}
- w.mu.Unlock()
- return nil
- }
-
- err = w.associateFile(name, stat, true)
- if err != nil {
- return err
- }
-
- w.mu.Lock()
- w.watches[name] = struct{}{}
- w.mu.Unlock()
- return nil
-}
-
-// Remove stops monitoring the path for changes.
-//
-// Directories are always removed non-recursively. For example, if you added
-// /tmp/dir and /tmp/dir/subdir then you will need to remove both.
-//
-// Removing a path that has not yet been added returns [ErrNonExistentWatch].
-//
-// Returns nil if [Watcher.Close] was called.
-func (w *Watcher) Remove(name string) error {
- if w.isClosed() {
- return nil
- }
- if !w.port.PathIsWatched(name) {
- return fmt.Errorf("%w: %s", ErrNonExistentWatch, name)
- }
-
- // The user has expressed an intent. Immediately remove this name from
- // whichever watch list it might be in. If it's not in there the delete
- // doesn't cause harm.
- w.mu.Lock()
- delete(w.watches, name)
- delete(w.dirs, name)
- w.mu.Unlock()
-
- stat, err := os.Stat(name)
- if err != nil {
- return err
- }
-
- // Remove associations for every file in the directory.
- if stat.IsDir() {
- err := w.handleDirectory(name, stat, false, w.dissociateFile)
- if err != nil {
- return err
- }
- return nil
- }
-
- err = w.port.DissociatePath(name)
- if err != nil {
- return err
- }
-
- return nil
-}
-
-// readEvents contains the main loop that runs in a goroutine watching for events.
-func (w *Watcher) readEvents() {
- // If this function returns, the watcher has been closed and we can close
- // these channels
- defer func() {
- close(w.Errors)
- close(w.Events)
- }()
-
- pevents := make([]unix.PortEvent, 8)
- for {
- count, err := w.port.Get(pevents, 1, nil)
- if err != nil && err != unix.ETIME {
- // Interrupted system call (count should be 0) ignore and continue
- if errors.Is(err, unix.EINTR) && count == 0 {
- continue
- }
- // Get failed because we called w.Close()
- if errors.Is(err, unix.EBADF) && w.isClosed() {
- return
- }
- // There was an error not caused by calling w.Close()
- if !w.sendError(err) {
- return
- }
- }
-
- p := pevents[:count]
- for _, pevent := range p {
- if pevent.Source != unix.PORT_SOURCE_FILE {
- // Event from unexpected source received; should never happen.
- if !w.sendError(errors.New("Event from unexpected source received")) {
- return
- }
- continue
- }
-
- err = w.handleEvent(&pevent)
- if err != nil {
- if !w.sendError(err) {
- return
- }
- }
- }
- }
-}
-
-func (w *Watcher) handleDirectory(path string, stat os.FileInfo, follow bool, handler func(string, os.FileInfo, bool) error) error {
- files, err := os.ReadDir(path)
- if err != nil {
- return err
- }
-
- // Handle all children of the directory.
- for _, entry := range files {
- finfo, err := entry.Info()
- if err != nil {
- return err
- }
- err = handler(filepath.Join(path, finfo.Name()), finfo, false)
- if err != nil {
- return err
- }
- }
-
- // And finally handle the directory itself.
- return handler(path, stat, follow)
-}
-
-// handleEvent might need to emit more than one fsnotify event if the events
-// bitmap matches more than one event type (e.g. the file was both modified and
-// had the attributes changed between when the association was created and the
-// when event was returned)
-func (w *Watcher) handleEvent(event *unix.PortEvent) error {
- var (
- events = event.Events
- path = event.Path
- fmode = event.Cookie.(os.FileMode)
- reRegister = true
- )
-
- w.mu.Lock()
- _, watchedDir := w.dirs[path]
- _, watchedPath := w.watches[path]
- w.mu.Unlock()
- isWatched := watchedDir || watchedPath
-
- if events&unix.FILE_DELETE != 0 {
- if !w.sendEvent(path, Remove) {
- return nil
- }
- reRegister = false
- }
- if events&unix.FILE_RENAME_FROM != 0 {
- if !w.sendEvent(path, Rename) {
- return nil
- }
- // Don't keep watching the new file name
- reRegister = false
- }
- if events&unix.FILE_RENAME_TO != 0 {
- // We don't report a Rename event for this case, because Rename events
- // are interpreted as referring to the _old_ name of the file, and in
- // this case the event would refer to the new name of the file. This
- // type of rename event is not supported by fsnotify.
-
- // inotify reports a Remove event in this case, so we simulate this
- // here.
- if !w.sendEvent(path, Remove) {
- return nil
- }
- // Don't keep watching the file that was removed
- reRegister = false
- }
-
- // The file is gone, nothing left to do.
- if !reRegister {
- if watchedDir {
- w.mu.Lock()
- delete(w.dirs, path)
- w.mu.Unlock()
- }
- if watchedPath {
- w.mu.Lock()
- delete(w.watches, path)
- w.mu.Unlock()
- }
- return nil
- }
-
- // If we didn't get a deletion the file still exists and we're going to have
- // to watch it again. Let's Stat it now so that we can compare permissions
- // and have what we need to continue watching the file
-
- stat, err := os.Lstat(path)
- if err != nil {
- // This is unexpected, but we should still emit an event. This happens
- // most often on "rm -r" of a subdirectory inside a watched directory We
- // get a modify event of something happening inside, but by the time we
- // get here, the sudirectory is already gone. Clearly we were watching
- // this path but now it is gone. Let's tell the user that it was
- // removed.
- if !w.sendEvent(path, Remove) {
- return nil
- }
- // Suppress extra write events on removed directories; they are not
- // informative and can be confusing.
- return nil
- }
-
- // resolve symlinks that were explicitly watched as we would have at Add()
- // time. this helps suppress spurious Chmod events on watched symlinks
- if isWatched {
- stat, err = os.Stat(path)
- if err != nil {
- // The symlink still exists, but the target is gone. Report the
- // Remove similar to above.
- if !w.sendEvent(path, Remove) {
- return nil
- }
- // Don't return the error
- }
- }
-
- if events&unix.FILE_MODIFIED != 0 {
- if fmode.IsDir() {
- if watchedDir {
- if err := w.updateDirectory(path); err != nil {
- return err
- }
- } else {
- if !w.sendEvent(path, Write) {
- return nil
- }
- }
- } else {
- if !w.sendEvent(path, Write) {
- return nil
- }
- }
- }
- if events&unix.FILE_ATTRIB != 0 && stat != nil {
- // Only send Chmod if perms changed
- if stat.Mode().Perm() != fmode.Perm() {
- if !w.sendEvent(path, Chmod) {
- return nil
- }
- }
- }
-
- if stat != nil {
- // If we get here, it means we've hit an event above that requires us to
- // continue watching the file or directory
- return w.associateFile(path, stat, isWatched)
- }
- return nil
-}
-
-func (w *Watcher) updateDirectory(path string) error {
- // The directory was modified, so we must find unwatched entities and watch
- // them. If something was removed from the directory, nothing will happen,
- // as everything else should still be watched.
- files, err := os.ReadDir(path)
- if err != nil {
- return err
- }
-
- for _, entry := range files {
- path := filepath.Join(path, entry.Name())
- if w.port.PathIsWatched(path) {
- continue
- }
-
- finfo, err := entry.Info()
- if err != nil {
- return err
- }
- err = w.associateFile(path, finfo, false)
- if err != nil {
- if !w.sendError(err) {
- return nil
- }
- }
- if !w.sendEvent(path, Create) {
- return nil
- }
- }
- return nil
-}
-
-func (w *Watcher) associateFile(path string, stat os.FileInfo, follow bool) error {
- if w.isClosed() {
- return ErrClosed
- }
- // This is primarily protecting the call to AssociatePath but it is
- // important and intentional that the call to PathIsWatched is also
- // protected by this mutex. Without this mutex, AssociatePath has been seen
- // to error out that the path is already associated.
- w.mu.Lock()
- defer w.mu.Unlock()
-
- if w.port.PathIsWatched(path) {
- // Remove the old association in favor of this one If we get ENOENT,
- // then while the x/sys/unix wrapper still thought that this path was
- // associated, the underlying event port did not. This call will have
- // cleared up that discrepancy. The most likely cause is that the event
- // has fired but we haven't processed it yet.
- err := w.port.DissociatePath(path)
- if err != nil && err != unix.ENOENT {
- return err
- }
- }
- // FILE_NOFOLLOW means we watch symlinks themselves rather than their
- // targets.
- events := unix.FILE_MODIFIED | unix.FILE_ATTRIB | unix.FILE_NOFOLLOW
- if follow {
- // We *DO* follow symlinks for explicitly watched entries.
- events = unix.FILE_MODIFIED | unix.FILE_ATTRIB
- }
- return w.port.AssociatePath(path, stat,
- events,
- stat.Mode())
-}
-
-func (w *Watcher) dissociateFile(path string, stat os.FileInfo, unused bool) error {
- if !w.port.PathIsWatched(path) {
- return nil
- }
- return w.port.DissociatePath(path)
-}
-
-// WatchList returns all paths explicitly added with [Watcher.Add] (and are not
-// yet removed).
-//
-// Returns nil if [Watcher.Close] was called.
-func (w *Watcher) WatchList() []string {
- if w.isClosed() {
- return nil
- }
-
- w.mu.Lock()
- defer w.mu.Unlock()
-
- entries := make([]string, 0, len(w.watches)+len(w.dirs))
- for pathname := range w.dirs {
- entries = append(entries, pathname)
- }
- for pathname := range w.watches {
- entries = append(entries, pathname)
- }
-
- return entries
-}
diff --git a/vendor/github.com/fsnotify/fsnotify/backend_inotify.go b/vendor/github.com/fsnotify/fsnotify/backend_inotify.go
deleted file mode 100644
index 921c1c1..0000000
--- a/vendor/github.com/fsnotify/fsnotify/backend_inotify.go
+++ /dev/null
@@ -1,594 +0,0 @@
-//go:build linux && !appengine
-// +build linux,!appengine
-
-// Note: the documentation on the Watcher type and methods is generated from
-// mkdoc.zsh
-
-package fsnotify
-
-import (
- "errors"
- "fmt"
- "io"
- "os"
- "path/filepath"
- "strings"
- "sync"
- "unsafe"
-
- "golang.org/x/sys/unix"
-)
-
-// Watcher watches a set of paths, delivering events on a channel.
-//
-// A watcher should not be copied (e.g. pass it by pointer, rather than by
-// value).
-//
-// # Linux notes
-//
-// When a file is removed a Remove event won't be emitted until all file
-// descriptors are closed, and deletes will always emit a Chmod. For example:
-//
-// fp := os.Open("file")
-// os.Remove("file") // Triggers Chmod
-// fp.Close() // Triggers Remove
-//
-// This is the event that inotify sends, so not much can be changed about this.
-//
-// The fs.inotify.max_user_watches sysctl variable specifies the upper limit
-// for the number of watches per user, and fs.inotify.max_user_instances
-// specifies the maximum number of inotify instances per user. Every Watcher you
-// create is an "instance", and every path you add is a "watch".
-//
-// These are also exposed in /proc as /proc/sys/fs/inotify/max_user_watches and
-// /proc/sys/fs/inotify/max_user_instances
-//
-// To increase them you can use sysctl or write the value to the /proc file:
-//
-// # Default values on Linux 5.18
-// sysctl fs.inotify.max_user_watches=124983
-// sysctl fs.inotify.max_user_instances=128
-//
-// To make the changes persist on reboot edit /etc/sysctl.conf or
-// /usr/lib/sysctl.d/50-default.conf (details differ per Linux distro; check
-// your distro's documentation):
-//
-// fs.inotify.max_user_watches=124983
-// fs.inotify.max_user_instances=128
-//
-// Reaching the limit will result in a "no space left on device" or "too many open
-// files" error.
-//
-// # kqueue notes (macOS, BSD)
-//
-// kqueue requires opening a file descriptor for every file that's being watched;
-// so if you're watching a directory with five files then that's six file
-// descriptors. You will run in to your system's "max open files" limit faster on
-// these platforms.
-//
-// The sysctl variables kern.maxfiles and kern.maxfilesperproc can be used to
-// control the maximum number of open files, as well as /etc/login.conf on BSD
-// systems.
-//
-// # Windows notes
-//
-// Paths can be added as "C:\path\to\dir", but forward slashes
-// ("C:/path/to/dir") will also work.
-//
-// When a watched directory is removed it will always send an event for the
-// directory itself, but may not send events for all files in that directory.
-// Sometimes it will send events for all times, sometimes it will send no
-// events, and often only for some files.
-//
-// The default ReadDirectoryChangesW() buffer size is 64K, which is the largest
-// value that is guaranteed to work with SMB filesystems. If you have many
-// events in quick succession this may not be enough, and you will have to use
-// [WithBufferSize] to increase the value.
-type Watcher struct {
- // Events sends the filesystem change events.
- //
- // fsnotify can send the following events; a "path" here can refer to a
- // file, directory, symbolic link, or special file like a FIFO.
- //
- // fsnotify.Create A new path was created; this may be followed by one
- // or more Write events if data also gets written to a
- // file.
- //
- // fsnotify.Remove A path was removed.
- //
- // fsnotify.Rename A path was renamed. A rename is always sent with the
- // old path as Event.Name, and a Create event will be
- // sent with the new name. Renames are only sent for
- // paths that are currently watched; e.g. moving an
- // unmonitored file into a monitored directory will
- // show up as just a Create. Similarly, renaming a file
- // to outside a monitored directory will show up as
- // only a Rename.
- //
- // fsnotify.Write A file or named pipe was written to. A Truncate will
- // also trigger a Write. A single "write action"
- // initiated by the user may show up as one or multiple
- // writes, depending on when the system syncs things to
- // disk. For example when compiling a large Go program
- // you may get hundreds of Write events, and you may
- // want to wait until you've stopped receiving them
- // (see the dedup example in cmd/fsnotify).
- //
- // Some systems may send Write event for directories
- // when the directory content changes.
- //
- // fsnotify.Chmod Attributes were changed. On Linux this is also sent
- // when a file is removed (or more accurately, when a
- // link to an inode is removed). On kqueue it's sent
- // when a file is truncated. On Windows it's never
- // sent.
- Events chan Event
-
- // Errors sends any errors.
- //
- // ErrEventOverflow is used to indicate there are too many events:
- //
- // - inotify: There are too many queued events (fs.inotify.max_queued_events sysctl)
- // - windows: The buffer size is too small; WithBufferSize() can be used to increase it.
- // - kqueue, fen: Not used.
- Errors chan error
-
- // Store fd here as os.File.Read() will no longer return on close after
- // calling Fd(). See: https://github.com/golang/go/issues/26439
- fd int
- inotifyFile *os.File
- watches *watches
- done chan struct{} // Channel for sending a "quit message" to the reader goroutine
- closeMu sync.Mutex
- doneResp chan struct{} // Channel to respond to Close
-}
-
-type (
- watches struct {
- mu sync.RWMutex
- wd map[uint32]*watch // wd → watch
- path map[string]uint32 // pathname → wd
- }
- watch struct {
- wd uint32 // Watch descriptor (as returned by the inotify_add_watch() syscall)
- flags uint32 // inotify flags of this watch (see inotify(7) for the list of valid flags)
- path string // Watch path.
- }
-)
-
-func newWatches() *watches {
- return &watches{
- wd: make(map[uint32]*watch),
- path: make(map[string]uint32),
- }
-}
-
-func (w *watches) len() int {
- w.mu.RLock()
- defer w.mu.RUnlock()
- return len(w.wd)
-}
-
-func (w *watches) add(ww *watch) {
- w.mu.Lock()
- defer w.mu.Unlock()
- w.wd[ww.wd] = ww
- w.path[ww.path] = ww.wd
-}
-
-func (w *watches) remove(wd uint32) {
- w.mu.Lock()
- defer w.mu.Unlock()
- delete(w.path, w.wd[wd].path)
- delete(w.wd, wd)
-}
-
-func (w *watches) removePath(path string) (uint32, bool) {
- w.mu.Lock()
- defer w.mu.Unlock()
-
- wd, ok := w.path[path]
- if !ok {
- return 0, false
- }
-
- delete(w.path, path)
- delete(w.wd, wd)
-
- return wd, true
-}
-
-func (w *watches) byPath(path string) *watch {
- w.mu.RLock()
- defer w.mu.RUnlock()
- return w.wd[w.path[path]]
-}
-
-func (w *watches) byWd(wd uint32) *watch {
- w.mu.RLock()
- defer w.mu.RUnlock()
- return w.wd[wd]
-}
-
-func (w *watches) updatePath(path string, f func(*watch) (*watch, error)) error {
- w.mu.Lock()
- defer w.mu.Unlock()
-
- var existing *watch
- wd, ok := w.path[path]
- if ok {
- existing = w.wd[wd]
- }
-
- upd, err := f(existing)
- if err != nil {
- return err
- }
- if upd != nil {
- w.wd[upd.wd] = upd
- w.path[upd.path] = upd.wd
-
- if upd.wd != wd {
- delete(w.wd, wd)
- }
- }
-
- return nil
-}
-
-// NewWatcher creates a new Watcher.
-func NewWatcher() (*Watcher, error) {
- return NewBufferedWatcher(0)
-}
-
-// NewBufferedWatcher creates a new Watcher with a buffered Watcher.Events
-// channel.
-//
-// The main use case for this is situations with a very large number of events
-// where the kernel buffer size can't be increased (e.g. due to lack of
-// permissions). An unbuffered Watcher will perform better for almost all use
-// cases, and whenever possible you will be better off increasing the kernel
-// buffers instead of adding a large userspace buffer.
-func NewBufferedWatcher(sz uint) (*Watcher, error) {
- // Need to set nonblocking mode for SetDeadline to work, otherwise blocking
- // I/O operations won't terminate on close.
- fd, errno := unix.InotifyInit1(unix.IN_CLOEXEC | unix.IN_NONBLOCK)
- if fd == -1 {
- return nil, errno
- }
-
- w := &Watcher{
- fd: fd,
- inotifyFile: os.NewFile(uintptr(fd), ""),
- watches: newWatches(),
- Events: make(chan Event, sz),
- Errors: make(chan error),
- done: make(chan struct{}),
- doneResp: make(chan struct{}),
- }
-
- go w.readEvents()
- return w, nil
-}
-
-// Returns true if the event was sent, or false if watcher is closed.
-func (w *Watcher) sendEvent(e Event) bool {
- select {
- case w.Events <- e:
- return true
- case <-w.done:
- return false
- }
-}
-
-// Returns true if the error was sent, or false if watcher is closed.
-func (w *Watcher) sendError(err error) bool {
- select {
- case w.Errors <- err:
- return true
- case <-w.done:
- return false
- }
-}
-
-func (w *Watcher) isClosed() bool {
- select {
- case <-w.done:
- return true
- default:
- return false
- }
-}
-
-// Close removes all watches and closes the Events channel.
-func (w *Watcher) Close() error {
- w.closeMu.Lock()
- if w.isClosed() {
- w.closeMu.Unlock()
- return nil
- }
- close(w.done)
- w.closeMu.Unlock()
-
- // Causes any blocking reads to return with an error, provided the file
- // still supports deadline operations.
- err := w.inotifyFile.Close()
- if err != nil {
- return err
- }
-
- // Wait for goroutine to close
- <-w.doneResp
-
- return nil
-}
-
-// Add starts monitoring the path for changes.
-//
-// A path can only be watched once; watching it more than once is a no-op and will
-// not return an error. Paths that do not yet exist on the filesystem cannot be
-// watched.
-//
-// A watch will be automatically removed if the watched path is deleted or
-// renamed. The exception is the Windows backend, which doesn't remove the
-// watcher on renames.
-//
-// Notifications on network filesystems (NFS, SMB, FUSE, etc.) or special
-// filesystems (/proc, /sys, etc.) generally don't work.
-//
-// Returns [ErrClosed] if [Watcher.Close] was called.
-//
-// See [Watcher.AddWith] for a version that allows adding options.
-//
-// # Watching directories
-//
-// All files in a directory are monitored, including new files that are created
-// after the watcher is started. Subdirectories are not watched (i.e. it's
-// non-recursive).
-//
-// # Watching files
-//
-// Watching individual files (rather than directories) is generally not
-// recommended as many programs (especially editors) update files atomically: it
-// will write to a temporary file which is then moved to to destination,
-// overwriting the original (or some variant thereof). The watcher on the
-// original file is now lost, as that no longer exists.
-//
-// The upshot of this is that a power failure or crash won't leave a
-// half-written file.
-//
-// Watch the parent directory and use Event.Name to filter out files you're not
-// interested in. There is an example of this in cmd/fsnotify/file.go.
-func (w *Watcher) Add(name string) error { return w.AddWith(name) }
-
-// AddWith is like [Watcher.Add], but allows adding options. When using Add()
-// the defaults described below are used.
-//
-// Possible options are:
-//
-// - [WithBufferSize] sets the buffer size for the Windows backend; no-op on
-// other platforms. The default is 64K (65536 bytes).
-func (w *Watcher) AddWith(name string, opts ...addOpt) error {
- if w.isClosed() {
- return ErrClosed
- }
-
- name = filepath.Clean(name)
- _ = getOptions(opts...)
-
- var flags uint32 = unix.IN_MOVED_TO | unix.IN_MOVED_FROM |
- unix.IN_CREATE | unix.IN_ATTRIB | unix.IN_MODIFY |
- unix.IN_MOVE_SELF | unix.IN_DELETE | unix.IN_DELETE_SELF
-
- return w.watches.updatePath(name, func(existing *watch) (*watch, error) {
- if existing != nil {
- flags |= existing.flags | unix.IN_MASK_ADD
- }
-
- wd, err := unix.InotifyAddWatch(w.fd, name, flags)
- if wd == -1 {
- return nil, err
- }
-
- if existing == nil {
- return &watch{
- wd: uint32(wd),
- path: name,
- flags: flags,
- }, nil
- }
-
- existing.wd = uint32(wd)
- existing.flags = flags
- return existing, nil
- })
-}
-
-// Remove stops monitoring the path for changes.
-//
-// Directories are always removed non-recursively. For example, if you added
-// /tmp/dir and /tmp/dir/subdir then you will need to remove both.
-//
-// Removing a path that has not yet been added returns [ErrNonExistentWatch].
-//
-// Returns nil if [Watcher.Close] was called.
-func (w *Watcher) Remove(name string) error {
- if w.isClosed() {
- return nil
- }
- return w.remove(filepath.Clean(name))
-}
-
-func (w *Watcher) remove(name string) error {
- wd, ok := w.watches.removePath(name)
- if !ok {
- return fmt.Errorf("%w: %s", ErrNonExistentWatch, name)
- }
-
- success, errno := unix.InotifyRmWatch(w.fd, wd)
- if success == -1 {
- // TODO: Perhaps it's not helpful to return an error here in every case;
- // The only two possible errors are:
- //
- // - EBADF, which happens when w.fd is not a valid file descriptor
- // of any kind.
- // - EINVAL, which is when fd is not an inotify descriptor or wd
- // is not a valid watch descriptor. Watch descriptors are
- // invalidated when they are removed explicitly or implicitly;
- // explicitly by inotify_rm_watch, implicitly when the file they
- // are watching is deleted.
- return errno
- }
- return nil
-}
-
-// WatchList returns all paths explicitly added with [Watcher.Add] (and are not
-// yet removed).
-//
-// Returns nil if [Watcher.Close] was called.
-func (w *Watcher) WatchList() []string {
- if w.isClosed() {
- return nil
- }
-
- entries := make([]string, 0, w.watches.len())
- w.watches.mu.RLock()
- for pathname := range w.watches.path {
- entries = append(entries, pathname)
- }
- w.watches.mu.RUnlock()
-
- return entries
-}
-
-// readEvents reads from the inotify file descriptor, converts the
-// received events into Event objects and sends them via the Events channel
-func (w *Watcher) readEvents() {
- defer func() {
- close(w.doneResp)
- close(w.Errors)
- close(w.Events)
- }()
-
- var (
- buf [unix.SizeofInotifyEvent * 4096]byte // Buffer for a maximum of 4096 raw events
- errno error // Syscall errno
- )
- for {
- // See if we have been closed.
- if w.isClosed() {
- return
- }
-
- n, err := w.inotifyFile.Read(buf[:])
- switch {
- case errors.Unwrap(err) == os.ErrClosed:
- return
- case err != nil:
- if !w.sendError(err) {
- return
- }
- continue
- }
-
- if n < unix.SizeofInotifyEvent {
- var err error
- if n == 0 {
- err = io.EOF // If EOF is received. This should really never happen.
- } else if n < 0 {
- err = errno // If an error occurred while reading.
- } else {
- err = errors.New("notify: short read in readEvents()") // Read was too short.
- }
- if !w.sendError(err) {
- return
- }
- continue
- }
-
- var offset uint32
- // We don't know how many events we just read into the buffer
- // While the offset points to at least one whole event...
- for offset <= uint32(n-unix.SizeofInotifyEvent) {
- var (
- // Point "raw" to the event in the buffer
- raw = (*unix.InotifyEvent)(unsafe.Pointer(&buf[offset]))
- mask = uint32(raw.Mask)
- nameLen = uint32(raw.Len)
- )
-
- if mask&unix.IN_Q_OVERFLOW != 0 {
- if !w.sendError(ErrEventOverflow) {
- return
- }
- }
-
- // If the event happened to the watched directory or the watched file, the kernel
- // doesn't append the filename to the event, but we would like to always fill the
- // the "Name" field with a valid filename. We retrieve the path of the watch from
- // the "paths" map.
- watch := w.watches.byWd(uint32(raw.Wd))
-
- // inotify will automatically remove the watch on deletes; just need
- // to clean our state here.
- if watch != nil && mask&unix.IN_DELETE_SELF == unix.IN_DELETE_SELF {
- w.watches.remove(watch.wd)
- }
- // We can't really update the state when a watched path is moved;
- // only IN_MOVE_SELF is sent and not IN_MOVED_{FROM,TO}. So remove
- // the watch.
- if watch != nil && mask&unix.IN_MOVE_SELF == unix.IN_MOVE_SELF {
- err := w.remove(watch.path)
- if err != nil && !errors.Is(err, ErrNonExistentWatch) {
- if !w.sendError(err) {
- return
- }
- }
- }
-
- var name string
- if watch != nil {
- name = watch.path
- }
- if nameLen > 0 {
- // Point "bytes" at the first byte of the filename
- bytes := (*[unix.PathMax]byte)(unsafe.Pointer(&buf[offset+unix.SizeofInotifyEvent]))[:nameLen:nameLen]
- // The filename is padded with NULL bytes. TrimRight() gets rid of those.
- name += "/" + strings.TrimRight(string(bytes[0:nameLen]), "\000")
- }
-
- event := w.newEvent(name, mask)
-
- // Send the events that are not ignored on the events channel
- if mask&unix.IN_IGNORED == 0 {
- if !w.sendEvent(event) {
- return
- }
- }
-
- // Move to the next event in the buffer
- offset += unix.SizeofInotifyEvent + nameLen
- }
- }
-}
-
-// newEvent returns an platform-independent Event based on an inotify mask.
-func (w *Watcher) newEvent(name string, mask uint32) Event {
- e := Event{Name: name}
- if mask&unix.IN_CREATE == unix.IN_CREATE || mask&unix.IN_MOVED_TO == unix.IN_MOVED_TO {
- e.Op |= Create
- }
- if mask&unix.IN_DELETE_SELF == unix.IN_DELETE_SELF || mask&unix.IN_DELETE == unix.IN_DELETE {
- e.Op |= Remove
- }
- if mask&unix.IN_MODIFY == unix.IN_MODIFY {
- e.Op |= Write
- }
- if mask&unix.IN_MOVE_SELF == unix.IN_MOVE_SELF || mask&unix.IN_MOVED_FROM == unix.IN_MOVED_FROM {
- e.Op |= Rename
- }
- if mask&unix.IN_ATTRIB == unix.IN_ATTRIB {
- e.Op |= Chmod
- }
- return e
-}
diff --git a/vendor/github.com/fsnotify/fsnotify/backend_kqueue.go b/vendor/github.com/fsnotify/fsnotify/backend_kqueue.go
deleted file mode 100644
index 063a091..0000000
--- a/vendor/github.com/fsnotify/fsnotify/backend_kqueue.go
+++ /dev/null
@@ -1,782 +0,0 @@
-//go:build freebsd || openbsd || netbsd || dragonfly || darwin
-// +build freebsd openbsd netbsd dragonfly darwin
-
-// Note: the documentation on the Watcher type and methods is generated from
-// mkdoc.zsh
-
-package fsnotify
-
-import (
- "errors"
- "fmt"
- "os"
- "path/filepath"
- "sync"
-
- "golang.org/x/sys/unix"
-)
-
-// Watcher watches a set of paths, delivering events on a channel.
-//
-// A watcher should not be copied (e.g. pass it by pointer, rather than by
-// value).
-//
-// # Linux notes
-//
-// When a file is removed a Remove event won't be emitted until all file
-// descriptors are closed, and deletes will always emit a Chmod. For example:
-//
-// fp := os.Open("file")
-// os.Remove("file") // Triggers Chmod
-// fp.Close() // Triggers Remove
-//
-// This is the event that inotify sends, so not much can be changed about this.
-//
-// The fs.inotify.max_user_watches sysctl variable specifies the upper limit
-// for the number of watches per user, and fs.inotify.max_user_instances
-// specifies the maximum number of inotify instances per user. Every Watcher you
-// create is an "instance", and every path you add is a "watch".
-//
-// These are also exposed in /proc as /proc/sys/fs/inotify/max_user_watches and
-// /proc/sys/fs/inotify/max_user_instances
-//
-// To increase them you can use sysctl or write the value to the /proc file:
-//
-// # Default values on Linux 5.18
-// sysctl fs.inotify.max_user_watches=124983
-// sysctl fs.inotify.max_user_instances=128
-//
-// To make the changes persist on reboot edit /etc/sysctl.conf or
-// /usr/lib/sysctl.d/50-default.conf (details differ per Linux distro; check
-// your distro's documentation):
-//
-// fs.inotify.max_user_watches=124983
-// fs.inotify.max_user_instances=128
-//
-// Reaching the limit will result in a "no space left on device" or "too many open
-// files" error.
-//
-// # kqueue notes (macOS, BSD)
-//
-// kqueue requires opening a file descriptor for every file that's being watched;
-// so if you're watching a directory with five files then that's six file
-// descriptors. You will run in to your system's "max open files" limit faster on
-// these platforms.
-//
-// The sysctl variables kern.maxfiles and kern.maxfilesperproc can be used to
-// control the maximum number of open files, as well as /etc/login.conf on BSD
-// systems.
-//
-// # Windows notes
-//
-// Paths can be added as "C:\path\to\dir", but forward slashes
-// ("C:/path/to/dir") will also work.
-//
-// When a watched directory is removed it will always send an event for the
-// directory itself, but may not send events for all files in that directory.
-// Sometimes it will send events for all times, sometimes it will send no
-// events, and often only for some files.
-//
-// The default ReadDirectoryChangesW() buffer size is 64K, which is the largest
-// value that is guaranteed to work with SMB filesystems. If you have many
-// events in quick succession this may not be enough, and you will have to use
-// [WithBufferSize] to increase the value.
-type Watcher struct {
- // Events sends the filesystem change events.
- //
- // fsnotify can send the following events; a "path" here can refer to a
- // file, directory, symbolic link, or special file like a FIFO.
- //
- // fsnotify.Create A new path was created; this may be followed by one
- // or more Write events if data also gets written to a
- // file.
- //
- // fsnotify.Remove A path was removed.
- //
- // fsnotify.Rename A path was renamed. A rename is always sent with the
- // old path as Event.Name, and a Create event will be
- // sent with the new name. Renames are only sent for
- // paths that are currently watched; e.g. moving an
- // unmonitored file into a monitored directory will
- // show up as just a Create. Similarly, renaming a file
- // to outside a monitored directory will show up as
- // only a Rename.
- //
- // fsnotify.Write A file or named pipe was written to. A Truncate will
- // also trigger a Write. A single "write action"
- // initiated by the user may show up as one or multiple
- // writes, depending on when the system syncs things to
- // disk. For example when compiling a large Go program
- // you may get hundreds of Write events, and you may
- // want to wait until you've stopped receiving them
- // (see the dedup example in cmd/fsnotify).
- //
- // Some systems may send Write event for directories
- // when the directory content changes.
- //
- // fsnotify.Chmod Attributes were changed. On Linux this is also sent
- // when a file is removed (or more accurately, when a
- // link to an inode is removed). On kqueue it's sent
- // when a file is truncated. On Windows it's never
- // sent.
- Events chan Event
-
- // Errors sends any errors.
- //
- // ErrEventOverflow is used to indicate there are too many events:
- //
- // - inotify: There are too many queued events (fs.inotify.max_queued_events sysctl)
- // - windows: The buffer size is too small; WithBufferSize() can be used to increase it.
- // - kqueue, fen: Not used.
- Errors chan error
-
- done chan struct{}
- kq int // File descriptor (as returned by the kqueue() syscall).
- closepipe [2]int // Pipe used for closing.
- mu sync.Mutex // Protects access to watcher data
- watches map[string]int // Watched file descriptors (key: path).
- watchesByDir map[string]map[int]struct{} // Watched file descriptors indexed by the parent directory (key: dirname(path)).
- userWatches map[string]struct{} // Watches added with Watcher.Add()
- dirFlags map[string]uint32 // Watched directories to fflags used in kqueue.
- paths map[int]pathInfo // File descriptors to path names for processing kqueue events.
- fileExists map[string]struct{} // Keep track of if we know this file exists (to stop duplicate create events).
- isClosed bool // Set to true when Close() is first called
-}
-
-type pathInfo struct {
- name string
- isDir bool
-}
-
-// NewWatcher creates a new Watcher.
-func NewWatcher() (*Watcher, error) {
- return NewBufferedWatcher(0)
-}
-
-// NewBufferedWatcher creates a new Watcher with a buffered Watcher.Events
-// channel.
-//
-// The main use case for this is situations with a very large number of events
-// where the kernel buffer size can't be increased (e.g. due to lack of
-// permissions). An unbuffered Watcher will perform better for almost all use
-// cases, and whenever possible you will be better off increasing the kernel
-// buffers instead of adding a large userspace buffer.
-func NewBufferedWatcher(sz uint) (*Watcher, error) {
- kq, closepipe, err := newKqueue()
- if err != nil {
- return nil, err
- }
-
- w := &Watcher{
- kq: kq,
- closepipe: closepipe,
- watches: make(map[string]int),
- watchesByDir: make(map[string]map[int]struct{}),
- dirFlags: make(map[string]uint32),
- paths: make(map[int]pathInfo),
- fileExists: make(map[string]struct{}),
- userWatches: make(map[string]struct{}),
- Events: make(chan Event, sz),
- Errors: make(chan error),
- done: make(chan struct{}),
- }
-
- go w.readEvents()
- return w, nil
-}
-
-// newKqueue creates a new kernel event queue and returns a descriptor.
-//
-// This registers a new event on closepipe, which will trigger an event when
-// it's closed. This way we can use kevent() without timeout/polling; without
-// the closepipe, it would block forever and we wouldn't be able to stop it at
-// all.
-func newKqueue() (kq int, closepipe [2]int, err error) {
- kq, err = unix.Kqueue()
- if kq == -1 {
- return kq, closepipe, err
- }
-
- // Register the close pipe.
- err = unix.Pipe(closepipe[:])
- if err != nil {
- unix.Close(kq)
- return kq, closepipe, err
- }
-
- // Register changes to listen on the closepipe.
- changes := make([]unix.Kevent_t, 1)
- // SetKevent converts int to the platform-specific types.
- unix.SetKevent(&changes[0], closepipe[0], unix.EVFILT_READ,
- unix.EV_ADD|unix.EV_ENABLE|unix.EV_ONESHOT)
-
- ok, err := unix.Kevent(kq, changes, nil, nil)
- if ok == -1 {
- unix.Close(kq)
- unix.Close(closepipe[0])
- unix.Close(closepipe[1])
- return kq, closepipe, err
- }
- return kq, closepipe, nil
-}
-
-// Returns true if the event was sent, or false if watcher is closed.
-func (w *Watcher) sendEvent(e Event) bool {
- select {
- case w.Events <- e:
- return true
- case <-w.done:
- return false
- }
-}
-
-// Returns true if the error was sent, or false if watcher is closed.
-func (w *Watcher) sendError(err error) bool {
- select {
- case w.Errors <- err:
- return true
- case <-w.done:
- return false
- }
-}
-
-// Close removes all watches and closes the Events channel.
-func (w *Watcher) Close() error {
- w.mu.Lock()
- if w.isClosed {
- w.mu.Unlock()
- return nil
- }
- w.isClosed = true
-
- // copy paths to remove while locked
- pathsToRemove := make([]string, 0, len(w.watches))
- for name := range w.watches {
- pathsToRemove = append(pathsToRemove, name)
- }
- w.mu.Unlock() // Unlock before calling Remove, which also locks
- for _, name := range pathsToRemove {
- w.Remove(name)
- }
-
- // Send "quit" message to the reader goroutine.
- unix.Close(w.closepipe[1])
- close(w.done)
-
- return nil
-}
-
-// Add starts monitoring the path for changes.
-//
-// A path can only be watched once; watching it more than once is a no-op and will
-// not return an error. Paths that do not yet exist on the filesystem cannot be
-// watched.
-//
-// A watch will be automatically removed if the watched path is deleted or
-// renamed. The exception is the Windows backend, which doesn't remove the
-// watcher on renames.
-//
-// Notifications on network filesystems (NFS, SMB, FUSE, etc.) or special
-// filesystems (/proc, /sys, etc.) generally don't work.
-//
-// Returns [ErrClosed] if [Watcher.Close] was called.
-//
-// See [Watcher.AddWith] for a version that allows adding options.
-//
-// # Watching directories
-//
-// All files in a directory are monitored, including new files that are created
-// after the watcher is started. Subdirectories are not watched (i.e. it's
-// non-recursive).
-//
-// # Watching files
-//
-// Watching individual files (rather than directories) is generally not
-// recommended as many programs (especially editors) update files atomically: it
-// will write to a temporary file which is then moved to to destination,
-// overwriting the original (or some variant thereof). The watcher on the
-// original file is now lost, as that no longer exists.
-//
-// The upshot of this is that a power failure or crash won't leave a
-// half-written file.
-//
-// Watch the parent directory and use Event.Name to filter out files you're not
-// interested in. There is an example of this in cmd/fsnotify/file.go.
-func (w *Watcher) Add(name string) error { return w.AddWith(name) }
-
-// AddWith is like [Watcher.Add], but allows adding options. When using Add()
-// the defaults described below are used.
-//
-// Possible options are:
-//
-// - [WithBufferSize] sets the buffer size for the Windows backend; no-op on
-// other platforms. The default is 64K (65536 bytes).
-func (w *Watcher) AddWith(name string, opts ...addOpt) error {
- _ = getOptions(opts...)
-
- w.mu.Lock()
- w.userWatches[name] = struct{}{}
- w.mu.Unlock()
- _, err := w.addWatch(name, noteAllEvents)
- return err
-}
-
-// Remove stops monitoring the path for changes.
-//
-// Directories are always removed non-recursively. For example, if you added
-// /tmp/dir and /tmp/dir/subdir then you will need to remove both.
-//
-// Removing a path that has not yet been added returns [ErrNonExistentWatch].
-//
-// Returns nil if [Watcher.Close] was called.
-func (w *Watcher) Remove(name string) error {
- return w.remove(name, true)
-}
-
-func (w *Watcher) remove(name string, unwatchFiles bool) error {
- name = filepath.Clean(name)
- w.mu.Lock()
- if w.isClosed {
- w.mu.Unlock()
- return nil
- }
- watchfd, ok := w.watches[name]
- w.mu.Unlock()
- if !ok {
- return fmt.Errorf("%w: %s", ErrNonExistentWatch, name)
- }
-
- err := w.register([]int{watchfd}, unix.EV_DELETE, 0)
- if err != nil {
- return err
- }
-
- unix.Close(watchfd)
-
- w.mu.Lock()
- isDir := w.paths[watchfd].isDir
- delete(w.watches, name)
- delete(w.userWatches, name)
-
- parentName := filepath.Dir(name)
- delete(w.watchesByDir[parentName], watchfd)
-
- if len(w.watchesByDir[parentName]) == 0 {
- delete(w.watchesByDir, parentName)
- }
-
- delete(w.paths, watchfd)
- delete(w.dirFlags, name)
- delete(w.fileExists, name)
- w.mu.Unlock()
-
- // Find all watched paths that are in this directory that are not external.
- if unwatchFiles && isDir {
- var pathsToRemove []string
- w.mu.Lock()
- for fd := range w.watchesByDir[name] {
- path := w.paths[fd]
- if _, ok := w.userWatches[path.name]; !ok {
- pathsToRemove = append(pathsToRemove, path.name)
- }
- }
- w.mu.Unlock()
- for _, name := range pathsToRemove {
- // Since these are internal, not much sense in propagating error to
- // the user, as that will just confuse them with an error about a
- // path they did not explicitly watch themselves.
- w.Remove(name)
- }
- }
- return nil
-}
-
-// WatchList returns all paths explicitly added with [Watcher.Add] (and are not
-// yet removed).
-//
-// Returns nil if [Watcher.Close] was called.
-func (w *Watcher) WatchList() []string {
- w.mu.Lock()
- defer w.mu.Unlock()
- if w.isClosed {
- return nil
- }
-
- entries := make([]string, 0, len(w.userWatches))
- for pathname := range w.userWatches {
- entries = append(entries, pathname)
- }
-
- return entries
-}
-
-// Watch all events (except NOTE_EXTEND, NOTE_LINK, NOTE_REVOKE)
-const noteAllEvents = unix.NOTE_DELETE | unix.NOTE_WRITE | unix.NOTE_ATTRIB | unix.NOTE_RENAME
-
-// addWatch adds name to the watched file set; the flags are interpreted as
-// described in kevent(2).
-//
-// Returns the real path to the file which was added, with symlinks resolved.
-func (w *Watcher) addWatch(name string, flags uint32) (string, error) {
- var isDir bool
- name = filepath.Clean(name)
-
- w.mu.Lock()
- if w.isClosed {
- w.mu.Unlock()
- return "", ErrClosed
- }
- watchfd, alreadyWatching := w.watches[name]
- // We already have a watch, but we can still override flags.
- if alreadyWatching {
- isDir = w.paths[watchfd].isDir
- }
- w.mu.Unlock()
-
- if !alreadyWatching {
- fi, err := os.Lstat(name)
- if err != nil {
- return "", err
- }
-
- // Don't watch sockets or named pipes
- if (fi.Mode()&os.ModeSocket == os.ModeSocket) || (fi.Mode()&os.ModeNamedPipe == os.ModeNamedPipe) {
- return "", nil
- }
-
- // Follow Symlinks.
- if fi.Mode()&os.ModeSymlink == os.ModeSymlink {
- link, err := os.Readlink(name)
- if err != nil {
- // Return nil because Linux can add unresolvable symlinks to the
- // watch list without problems, so maintain consistency with
- // that. There will be no file events for broken symlinks.
- // TODO: more specific check; returns os.PathError; ENOENT?
- return "", nil
- }
-
- w.mu.Lock()
- _, alreadyWatching = w.watches[link]
- w.mu.Unlock()
-
- if alreadyWatching {
- // Add to watches so we don't get spurious Create events later
- // on when we diff the directories.
- w.watches[name] = 0
- w.fileExists[name] = struct{}{}
- return link, nil
- }
-
- name = link
- fi, err = os.Lstat(name)
- if err != nil {
- return "", nil
- }
- }
-
- // Retry on EINTR; open() can return EINTR in practice on macOS.
- // See #354, and Go issues 11180 and 39237.
- for {
- watchfd, err = unix.Open(name, openMode, 0)
- if err == nil {
- break
- }
- if errors.Is(err, unix.EINTR) {
- continue
- }
-
- return "", err
- }
-
- isDir = fi.IsDir()
- }
-
- err := w.register([]int{watchfd}, unix.EV_ADD|unix.EV_CLEAR|unix.EV_ENABLE, flags)
- if err != nil {
- unix.Close(watchfd)
- return "", err
- }
-
- if !alreadyWatching {
- w.mu.Lock()
- parentName := filepath.Dir(name)
- w.watches[name] = watchfd
-
- watchesByDir, ok := w.watchesByDir[parentName]
- if !ok {
- watchesByDir = make(map[int]struct{}, 1)
- w.watchesByDir[parentName] = watchesByDir
- }
- watchesByDir[watchfd] = struct{}{}
- w.paths[watchfd] = pathInfo{name: name, isDir: isDir}
- w.mu.Unlock()
- }
-
- if isDir {
- // Watch the directory if it has not been watched before, or if it was
- // watched before, but perhaps only a NOTE_DELETE (watchDirectoryFiles)
- w.mu.Lock()
-
- watchDir := (flags&unix.NOTE_WRITE) == unix.NOTE_WRITE &&
- (!alreadyWatching || (w.dirFlags[name]&unix.NOTE_WRITE) != unix.NOTE_WRITE)
- // Store flags so this watch can be updated later
- w.dirFlags[name] = flags
- w.mu.Unlock()
-
- if watchDir {
- if err := w.watchDirectoryFiles(name); err != nil {
- return "", err
- }
- }
- }
- return name, nil
-}
-
-// readEvents reads from kqueue and converts the received kevents into
-// Event values that it sends down the Events channel.
-func (w *Watcher) readEvents() {
- defer func() {
- close(w.Events)
- close(w.Errors)
- _ = unix.Close(w.kq)
- unix.Close(w.closepipe[0])
- }()
-
- eventBuffer := make([]unix.Kevent_t, 10)
- for closed := false; !closed; {
- kevents, err := w.read(eventBuffer)
- // EINTR is okay, the syscall was interrupted before timeout expired.
- if err != nil && err != unix.EINTR {
- if !w.sendError(fmt.Errorf("fsnotify.readEvents: %w", err)) {
- closed = true
- }
- continue
- }
-
- // Flush the events we received to the Events channel
- for _, kevent := range kevents {
- var (
- watchfd = int(kevent.Ident)
- mask = uint32(kevent.Fflags)
- )
-
- // Shut down the loop when the pipe is closed, but only after all
- // other events have been processed.
- if watchfd == w.closepipe[0] {
- closed = true
- continue
- }
-
- w.mu.Lock()
- path := w.paths[watchfd]
- w.mu.Unlock()
-
- event := w.newEvent(path.name, mask)
-
- if event.Has(Rename) || event.Has(Remove) {
- w.remove(event.Name, false)
- w.mu.Lock()
- delete(w.fileExists, event.Name)
- w.mu.Unlock()
- }
-
- if path.isDir && event.Has(Write) && !event.Has(Remove) {
- w.sendDirectoryChangeEvents(event.Name)
- } else {
- if !w.sendEvent(event) {
- closed = true
- continue
- }
- }
-
- if event.Has(Remove) {
- // Look for a file that may have overwritten this; for example,
- // mv f1 f2 will delete f2, then create f2.
- if path.isDir {
- fileDir := filepath.Clean(event.Name)
- w.mu.Lock()
- _, found := w.watches[fileDir]
- w.mu.Unlock()
- if found {
- err := w.sendDirectoryChangeEvents(fileDir)
- if err != nil {
- if !w.sendError(err) {
- closed = true
- }
- }
- }
- } else {
- filePath := filepath.Clean(event.Name)
- if fi, err := os.Lstat(filePath); err == nil {
- err := w.sendFileCreatedEventIfNew(filePath, fi)
- if err != nil {
- if !w.sendError(err) {
- closed = true
- }
- }
- }
- }
- }
- }
- }
-}
-
-// newEvent returns an platform-independent Event based on kqueue Fflags.
-func (w *Watcher) newEvent(name string, mask uint32) Event {
- e := Event{Name: name}
- if mask&unix.NOTE_DELETE == unix.NOTE_DELETE {
- e.Op |= Remove
- }
- if mask&unix.NOTE_WRITE == unix.NOTE_WRITE {
- e.Op |= Write
- }
- if mask&unix.NOTE_RENAME == unix.NOTE_RENAME {
- e.Op |= Rename
- }
- if mask&unix.NOTE_ATTRIB == unix.NOTE_ATTRIB {
- e.Op |= Chmod
- }
- // No point sending a write and delete event at the same time: if it's gone,
- // then it's gone.
- if e.Op.Has(Write) && e.Op.Has(Remove) {
- e.Op &^= Write
- }
- return e
-}
-
-// watchDirectoryFiles to mimic inotify when adding a watch on a directory
-func (w *Watcher) watchDirectoryFiles(dirPath string) error {
- // Get all files
- files, err := os.ReadDir(dirPath)
- if err != nil {
- return err
- }
-
- for _, f := range files {
- path := filepath.Join(dirPath, f.Name())
-
- fi, err := f.Info()
- if err != nil {
- return fmt.Errorf("%q: %w", path, err)
- }
-
- cleanPath, err := w.internalWatch(path, fi)
- if err != nil {
- // No permission to read the file; that's not a problem: just skip.
- // But do add it to w.fileExists to prevent it from being picked up
- // as a "new" file later (it still shows up in the directory
- // listing).
- switch {
- case errors.Is(err, unix.EACCES) || errors.Is(err, unix.EPERM):
- cleanPath = filepath.Clean(path)
- default:
- return fmt.Errorf("%q: %w", path, err)
- }
- }
-
- w.mu.Lock()
- w.fileExists[cleanPath] = struct{}{}
- w.mu.Unlock()
- }
-
- return nil
-}
-
-// Search the directory for new files and send an event for them.
-//
-// This functionality is to have the BSD watcher match the inotify, which sends
-// a create event for files created in a watched directory.
-func (w *Watcher) sendDirectoryChangeEvents(dir string) error {
- files, err := os.ReadDir(dir)
- if err != nil {
- // Directory no longer exists: we can ignore this safely. kqueue will
- // still give us the correct events.
- if errors.Is(err, os.ErrNotExist) {
- return nil
- }
- return fmt.Errorf("fsnotify.sendDirectoryChangeEvents: %w", err)
- }
-
- for _, f := range files {
- fi, err := f.Info()
- if err != nil {
- return fmt.Errorf("fsnotify.sendDirectoryChangeEvents: %w", err)
- }
-
- err = w.sendFileCreatedEventIfNew(filepath.Join(dir, fi.Name()), fi)
- if err != nil {
- // Don't need to send an error if this file isn't readable.
- if errors.Is(err, unix.EACCES) || errors.Is(err, unix.EPERM) {
- return nil
- }
- return fmt.Errorf("fsnotify.sendDirectoryChangeEvents: %w", err)
- }
- }
- return nil
-}
-
-// sendFileCreatedEvent sends a create event if the file isn't already being tracked.
-func (w *Watcher) sendFileCreatedEventIfNew(filePath string, fi os.FileInfo) (err error) {
- w.mu.Lock()
- _, doesExist := w.fileExists[filePath]
- w.mu.Unlock()
- if !doesExist {
- if !w.sendEvent(Event{Name: filePath, Op: Create}) {
- return
- }
- }
-
- // like watchDirectoryFiles (but without doing another ReadDir)
- filePath, err = w.internalWatch(filePath, fi)
- if err != nil {
- return err
- }
-
- w.mu.Lock()
- w.fileExists[filePath] = struct{}{}
- w.mu.Unlock()
-
- return nil
-}
-
-func (w *Watcher) internalWatch(name string, fi os.FileInfo) (string, error) {
- if fi.IsDir() {
- // mimic Linux providing delete events for subdirectories, but preserve
- // the flags used if currently watching subdirectory
- w.mu.Lock()
- flags := w.dirFlags[name]
- w.mu.Unlock()
-
- flags |= unix.NOTE_DELETE | unix.NOTE_RENAME
- return w.addWatch(name, flags)
- }
-
- // watch file to mimic Linux inotify
- return w.addWatch(name, noteAllEvents)
-}
-
-// Register events with the queue.
-func (w *Watcher) register(fds []int, flags int, fflags uint32) error {
- changes := make([]unix.Kevent_t, len(fds))
- for i, fd := range fds {
- // SetKevent converts int to the platform-specific types.
- unix.SetKevent(&changes[i], fd, unix.EVFILT_VNODE, flags)
- changes[i].Fflags = fflags
- }
-
- // Register the events.
- success, err := unix.Kevent(w.kq, changes, nil, nil)
- if success == -1 {
- return err
- }
- return nil
-}
-
-// read retrieves pending events, or waits until an event occurs.
-func (w *Watcher) read(events []unix.Kevent_t) ([]unix.Kevent_t, error) {
- n, err := unix.Kevent(w.kq, nil, events, nil)
- if err != nil {
- return nil, err
- }
- return events[0:n], nil
-}
diff --git a/vendor/github.com/fsnotify/fsnotify/backend_other.go b/vendor/github.com/fsnotify/fsnotify/backend_other.go
deleted file mode 100644
index d34a23c..0000000
--- a/vendor/github.com/fsnotify/fsnotify/backend_other.go
+++ /dev/null
@@ -1,205 +0,0 @@
-//go:build appengine || (!darwin && !dragonfly && !freebsd && !openbsd && !linux && !netbsd && !solaris && !windows)
-// +build appengine !darwin,!dragonfly,!freebsd,!openbsd,!linux,!netbsd,!solaris,!windows
-
-// Note: the documentation on the Watcher type and methods is generated from
-// mkdoc.zsh
-
-package fsnotify
-
-import "errors"
-
-// Watcher watches a set of paths, delivering events on a channel.
-//
-// A watcher should not be copied (e.g. pass it by pointer, rather than by
-// value).
-//
-// # Linux notes
-//
-// When a file is removed a Remove event won't be emitted until all file
-// descriptors are closed, and deletes will always emit a Chmod. For example:
-//
-// fp := os.Open("file")
-// os.Remove("file") // Triggers Chmod
-// fp.Close() // Triggers Remove
-//
-// This is the event that inotify sends, so not much can be changed about this.
-//
-// The fs.inotify.max_user_watches sysctl variable specifies the upper limit
-// for the number of watches per user, and fs.inotify.max_user_instances
-// specifies the maximum number of inotify instances per user. Every Watcher you
-// create is an "instance", and every path you add is a "watch".
-//
-// These are also exposed in /proc as /proc/sys/fs/inotify/max_user_watches and
-// /proc/sys/fs/inotify/max_user_instances
-//
-// To increase them you can use sysctl or write the value to the /proc file:
-//
-// # Default values on Linux 5.18
-// sysctl fs.inotify.max_user_watches=124983
-// sysctl fs.inotify.max_user_instances=128
-//
-// To make the changes persist on reboot edit /etc/sysctl.conf or
-// /usr/lib/sysctl.d/50-default.conf (details differ per Linux distro; check
-// your distro's documentation):
-//
-// fs.inotify.max_user_watches=124983
-// fs.inotify.max_user_instances=128
-//
-// Reaching the limit will result in a "no space left on device" or "too many open
-// files" error.
-//
-// # kqueue notes (macOS, BSD)
-//
-// kqueue requires opening a file descriptor for every file that's being watched;
-// so if you're watching a directory with five files then that's six file
-// descriptors. You will run in to your system's "max open files" limit faster on
-// these platforms.
-//
-// The sysctl variables kern.maxfiles and kern.maxfilesperproc can be used to
-// control the maximum number of open files, as well as /etc/login.conf on BSD
-// systems.
-//
-// # Windows notes
-//
-// Paths can be added as "C:\path\to\dir", but forward slashes
-// ("C:/path/to/dir") will also work.
-//
-// When a watched directory is removed it will always send an event for the
-// directory itself, but may not send events for all files in that directory.
-// Sometimes it will send events for all times, sometimes it will send no
-// events, and often only for some files.
-//
-// The default ReadDirectoryChangesW() buffer size is 64K, which is the largest
-// value that is guaranteed to work with SMB filesystems. If you have many
-// events in quick succession this may not be enough, and you will have to use
-// [WithBufferSize] to increase the value.
-type Watcher struct {
- // Events sends the filesystem change events.
- //
- // fsnotify can send the following events; a "path" here can refer to a
- // file, directory, symbolic link, or special file like a FIFO.
- //
- // fsnotify.Create A new path was created; this may be followed by one
- // or more Write events if data also gets written to a
- // file.
- //
- // fsnotify.Remove A path was removed.
- //
- // fsnotify.Rename A path was renamed. A rename is always sent with the
- // old path as Event.Name, and a Create event will be
- // sent with the new name. Renames are only sent for
- // paths that are currently watched; e.g. moving an
- // unmonitored file into a monitored directory will
- // show up as just a Create. Similarly, renaming a file
- // to outside a monitored directory will show up as
- // only a Rename.
- //
- // fsnotify.Write A file or named pipe was written to. A Truncate will
- // also trigger a Write. A single "write action"
- // initiated by the user may show up as one or multiple
- // writes, depending on when the system syncs things to
- // disk. For example when compiling a large Go program
- // you may get hundreds of Write events, and you may
- // want to wait until you've stopped receiving them
- // (see the dedup example in cmd/fsnotify).
- //
- // Some systems may send Write event for directories
- // when the directory content changes.
- //
- // fsnotify.Chmod Attributes were changed. On Linux this is also sent
- // when a file is removed (or more accurately, when a
- // link to an inode is removed). On kqueue it's sent
- // when a file is truncated. On Windows it's never
- // sent.
- Events chan Event
-
- // Errors sends any errors.
- //
- // ErrEventOverflow is used to indicate there are too many events:
- //
- // - inotify: There are too many queued events (fs.inotify.max_queued_events sysctl)
- // - windows: The buffer size is too small; WithBufferSize() can be used to increase it.
- // - kqueue, fen: Not used.
- Errors chan error
-}
-
-// NewWatcher creates a new Watcher.
-func NewWatcher() (*Watcher, error) {
- return nil, errors.New("fsnotify not supported on the current platform")
-}
-
-// NewBufferedWatcher creates a new Watcher with a buffered Watcher.Events
-// channel.
-//
-// The main use case for this is situations with a very large number of events
-// where the kernel buffer size can't be increased (e.g. due to lack of
-// permissions). An unbuffered Watcher will perform better for almost all use
-// cases, and whenever possible you will be better off increasing the kernel
-// buffers instead of adding a large userspace buffer.
-func NewBufferedWatcher(sz uint) (*Watcher, error) { return NewWatcher() }
-
-// Close removes all watches and closes the Events channel.
-func (w *Watcher) Close() error { return nil }
-
-// WatchList returns all paths explicitly added with [Watcher.Add] (and are not
-// yet removed).
-//
-// Returns nil if [Watcher.Close] was called.
-func (w *Watcher) WatchList() []string { return nil }
-
-// Add starts monitoring the path for changes.
-//
-// A path can only be watched once; watching it more than once is a no-op and will
-// not return an error. Paths that do not yet exist on the filesystem cannot be
-// watched.
-//
-// A watch will be automatically removed if the watched path is deleted or
-// renamed. The exception is the Windows backend, which doesn't remove the
-// watcher on renames.
-//
-// Notifications on network filesystems (NFS, SMB, FUSE, etc.) or special
-// filesystems (/proc, /sys, etc.) generally don't work.
-//
-// Returns [ErrClosed] if [Watcher.Close] was called.
-//
-// See [Watcher.AddWith] for a version that allows adding options.
-//
-// # Watching directories
-//
-// All files in a directory are monitored, including new files that are created
-// after the watcher is started. Subdirectories are not watched (i.e. it's
-// non-recursive).
-//
-// # Watching files
-//
-// Watching individual files (rather than directories) is generally not
-// recommended as many programs (especially editors) update files atomically: it
-// will write to a temporary file which is then moved to to destination,
-// overwriting the original (or some variant thereof). The watcher on the
-// original file is now lost, as that no longer exists.
-//
-// The upshot of this is that a power failure or crash won't leave a
-// half-written file.
-//
-// Watch the parent directory and use Event.Name to filter out files you're not
-// interested in. There is an example of this in cmd/fsnotify/file.go.
-func (w *Watcher) Add(name string) error { return nil }
-
-// AddWith is like [Watcher.Add], but allows adding options. When using Add()
-// the defaults described below are used.
-//
-// Possible options are:
-//
-// - [WithBufferSize] sets the buffer size for the Windows backend; no-op on
-// other platforms. The default is 64K (65536 bytes).
-func (w *Watcher) AddWith(name string, opts ...addOpt) error { return nil }
-
-// Remove stops monitoring the path for changes.
-//
-// Directories are always removed non-recursively. For example, if you added
-// /tmp/dir and /tmp/dir/subdir then you will need to remove both.
-//
-// Removing a path that has not yet been added returns [ErrNonExistentWatch].
-//
-// Returns nil if [Watcher.Close] was called.
-func (w *Watcher) Remove(name string) error { return nil }
diff --git a/vendor/github.com/fsnotify/fsnotify/backend_windows.go b/vendor/github.com/fsnotify/fsnotify/backend_windows.go
deleted file mode 100644
index 9bc91e5..0000000
--- a/vendor/github.com/fsnotify/fsnotify/backend_windows.go
+++ /dev/null
@@ -1,827 +0,0 @@
-//go:build windows
-// +build windows
-
-// Windows backend based on ReadDirectoryChangesW()
-//
-// https://learn.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-readdirectorychangesw
-//
-// Note: the documentation on the Watcher type and methods is generated from
-// mkdoc.zsh
-
-package fsnotify
-
-import (
- "errors"
- "fmt"
- "os"
- "path/filepath"
- "reflect"
- "runtime"
- "strings"
- "sync"
- "unsafe"
-
- "golang.org/x/sys/windows"
-)
-
-// Watcher watches a set of paths, delivering events on a channel.
-//
-// A watcher should not be copied (e.g. pass it by pointer, rather than by
-// value).
-//
-// # Linux notes
-//
-// When a file is removed a Remove event won't be emitted until all file
-// descriptors are closed, and deletes will always emit a Chmod. For example:
-//
-// fp := os.Open("file")
-// os.Remove("file") // Triggers Chmod
-// fp.Close() // Triggers Remove
-//
-// This is the event that inotify sends, so not much can be changed about this.
-//
-// The fs.inotify.max_user_watches sysctl variable specifies the upper limit
-// for the number of watches per user, and fs.inotify.max_user_instances
-// specifies the maximum number of inotify instances per user. Every Watcher you
-// create is an "instance", and every path you add is a "watch".
-//
-// These are also exposed in /proc as /proc/sys/fs/inotify/max_user_watches and
-// /proc/sys/fs/inotify/max_user_instances
-//
-// To increase them you can use sysctl or write the value to the /proc file:
-//
-// # Default values on Linux 5.18
-// sysctl fs.inotify.max_user_watches=124983
-// sysctl fs.inotify.max_user_instances=128
-//
-// To make the changes persist on reboot edit /etc/sysctl.conf or
-// /usr/lib/sysctl.d/50-default.conf (details differ per Linux distro; check
-// your distro's documentation):
-//
-// fs.inotify.max_user_watches=124983
-// fs.inotify.max_user_instances=128
-//
-// Reaching the limit will result in a "no space left on device" or "too many open
-// files" error.
-//
-// # kqueue notes (macOS, BSD)
-//
-// kqueue requires opening a file descriptor for every file that's being watched;
-// so if you're watching a directory with five files then that's six file
-// descriptors. You will run in to your system's "max open files" limit faster on
-// these platforms.
-//
-// The sysctl variables kern.maxfiles and kern.maxfilesperproc can be used to
-// control the maximum number of open files, as well as /etc/login.conf on BSD
-// systems.
-//
-// # Windows notes
-//
-// Paths can be added as "C:\path\to\dir", but forward slashes
-// ("C:/path/to/dir") will also work.
-//
-// When a watched directory is removed it will always send an event for the
-// directory itself, but may not send events for all files in that directory.
-// Sometimes it will send events for all times, sometimes it will send no
-// events, and often only for some files.
-//
-// The default ReadDirectoryChangesW() buffer size is 64K, which is the largest
-// value that is guaranteed to work with SMB filesystems. If you have many
-// events in quick succession this may not be enough, and you will have to use
-// [WithBufferSize] to increase the value.
-type Watcher struct {
- // Events sends the filesystem change events.
- //
- // fsnotify can send the following events; a "path" here can refer to a
- // file, directory, symbolic link, or special file like a FIFO.
- //
- // fsnotify.Create A new path was created; this may be followed by one
- // or more Write events if data also gets written to a
- // file.
- //
- // fsnotify.Remove A path was removed.
- //
- // fsnotify.Rename A path was renamed. A rename is always sent with the
- // old path as Event.Name, and a Create event will be
- // sent with the new name. Renames are only sent for
- // paths that are currently watched; e.g. moving an
- // unmonitored file into a monitored directory will
- // show up as just a Create. Similarly, renaming a file
- // to outside a monitored directory will show up as
- // only a Rename.
- //
- // fsnotify.Write A file or named pipe was written to. A Truncate will
- // also trigger a Write. A single "write action"
- // initiated by the user may show up as one or multiple
- // writes, depending on when the system syncs things to
- // disk. For example when compiling a large Go program
- // you may get hundreds of Write events, and you may
- // want to wait until you've stopped receiving them
- // (see the dedup example in cmd/fsnotify).
- //
- // Some systems may send Write event for directories
- // when the directory content changes.
- //
- // fsnotify.Chmod Attributes were changed. On Linux this is also sent
- // when a file is removed (or more accurately, when a
- // link to an inode is removed). On kqueue it's sent
- // when a file is truncated. On Windows it's never
- // sent.
- Events chan Event
-
- // Errors sends any errors.
- //
- // ErrEventOverflow is used to indicate there are too many events:
- //
- // - inotify: There are too many queued events (fs.inotify.max_queued_events sysctl)
- // - windows: The buffer size is too small; WithBufferSize() can be used to increase it.
- // - kqueue, fen: Not used.
- Errors chan error
-
- port windows.Handle // Handle to completion port
- input chan *input // Inputs to the reader are sent on this channel
- quit chan chan<- error
-
- mu sync.Mutex // Protects access to watches, closed
- watches watchMap // Map of watches (key: i-number)
- closed bool // Set to true when Close() is first called
-}
-
-// NewWatcher creates a new Watcher.
-func NewWatcher() (*Watcher, error) {
- return NewBufferedWatcher(50)
-}
-
-// NewBufferedWatcher creates a new Watcher with a buffered Watcher.Events
-// channel.
-//
-// The main use case for this is situations with a very large number of events
-// where the kernel buffer size can't be increased (e.g. due to lack of
-// permissions). An unbuffered Watcher will perform better for almost all use
-// cases, and whenever possible you will be better off increasing the kernel
-// buffers instead of adding a large userspace buffer.
-func NewBufferedWatcher(sz uint) (*Watcher, error) {
- port, err := windows.CreateIoCompletionPort(windows.InvalidHandle, 0, 0, 0)
- if err != nil {
- return nil, os.NewSyscallError("CreateIoCompletionPort", err)
- }
- w := &Watcher{
- port: port,
- watches: make(watchMap),
- input: make(chan *input, 1),
- Events: make(chan Event, sz),
- Errors: make(chan error),
- quit: make(chan chan<- error, 1),
- }
- go w.readEvents()
- return w, nil
-}
-
-func (w *Watcher) isClosed() bool {
- w.mu.Lock()
- defer w.mu.Unlock()
- return w.closed
-}
-
-func (w *Watcher) sendEvent(name string, mask uint64) bool {
- if mask == 0 {
- return false
- }
-
- event := w.newEvent(name, uint32(mask))
- select {
- case ch := <-w.quit:
- w.quit <- ch
- case w.Events <- event:
- }
- return true
-}
-
-// Returns true if the error was sent, or false if watcher is closed.
-func (w *Watcher) sendError(err error) bool {
- select {
- case w.Errors <- err:
- return true
- case <-w.quit:
- }
- return false
-}
-
-// Close removes all watches and closes the Events channel.
-func (w *Watcher) Close() error {
- if w.isClosed() {
- return nil
- }
-
- w.mu.Lock()
- w.closed = true
- w.mu.Unlock()
-
- // Send "quit" message to the reader goroutine
- ch := make(chan error)
- w.quit <- ch
- if err := w.wakeupReader(); err != nil {
- return err
- }
- return <-ch
-}
-
-// Add starts monitoring the path for changes.
-//
-// A path can only be watched once; watching it more than once is a no-op and will
-// not return an error. Paths that do not yet exist on the filesystem cannot be
-// watched.
-//
-// A watch will be automatically removed if the watched path is deleted or
-// renamed. The exception is the Windows backend, which doesn't remove the
-// watcher on renames.
-//
-// Notifications on network filesystems (NFS, SMB, FUSE, etc.) or special
-// filesystems (/proc, /sys, etc.) generally don't work.
-//
-// Returns [ErrClosed] if [Watcher.Close] was called.
-//
-// See [Watcher.AddWith] for a version that allows adding options.
-//
-// # Watching directories
-//
-// All files in a directory are monitored, including new files that are created
-// after the watcher is started. Subdirectories are not watched (i.e. it's
-// non-recursive).
-//
-// # Watching files
-//
-// Watching individual files (rather than directories) is generally not
-// recommended as many programs (especially editors) update files atomically: it
-// will write to a temporary file which is then moved to to destination,
-// overwriting the original (or some variant thereof). The watcher on the
-// original file is now lost, as that no longer exists.
-//
-// The upshot of this is that a power failure or crash won't leave a
-// half-written file.
-//
-// Watch the parent directory and use Event.Name to filter out files you're not
-// interested in. There is an example of this in cmd/fsnotify/file.go.
-func (w *Watcher) Add(name string) error { return w.AddWith(name) }
-
-// AddWith is like [Watcher.Add], but allows adding options. When using Add()
-// the defaults described below are used.
-//
-// Possible options are:
-//
-// - [WithBufferSize] sets the buffer size for the Windows backend; no-op on
-// other platforms. The default is 64K (65536 bytes).
-func (w *Watcher) AddWith(name string, opts ...addOpt) error {
- if w.isClosed() {
- return ErrClosed
- }
-
- with := getOptions(opts...)
- if with.bufsize < 4096 {
- return fmt.Errorf("fsnotify.WithBufferSize: buffer size cannot be smaller than 4096 bytes")
- }
-
- in := &input{
- op: opAddWatch,
- path: filepath.Clean(name),
- flags: sysFSALLEVENTS,
- reply: make(chan error),
- bufsize: with.bufsize,
- }
- w.input <- in
- if err := w.wakeupReader(); err != nil {
- return err
- }
- return <-in.reply
-}
-
-// Remove stops monitoring the path for changes.
-//
-// Directories are always removed non-recursively. For example, if you added
-// /tmp/dir and /tmp/dir/subdir then you will need to remove both.
-//
-// Removing a path that has not yet been added returns [ErrNonExistentWatch].
-//
-// Returns nil if [Watcher.Close] was called.
-func (w *Watcher) Remove(name string) error {
- if w.isClosed() {
- return nil
- }
-
- in := &input{
- op: opRemoveWatch,
- path: filepath.Clean(name),
- reply: make(chan error),
- }
- w.input <- in
- if err := w.wakeupReader(); err != nil {
- return err
- }
- return <-in.reply
-}
-
-// WatchList returns all paths explicitly added with [Watcher.Add] (and are not
-// yet removed).
-//
-// Returns nil if [Watcher.Close] was called.
-func (w *Watcher) WatchList() []string {
- if w.isClosed() {
- return nil
- }
-
- w.mu.Lock()
- defer w.mu.Unlock()
-
- entries := make([]string, 0, len(w.watches))
- for _, entry := range w.watches {
- for _, watchEntry := range entry {
- entries = append(entries, watchEntry.path)
- }
- }
-
- return entries
-}
-
-// These options are from the old golang.org/x/exp/winfsnotify, where you could
-// add various options to the watch. This has long since been removed.
-//
-// The "sys" in the name is misleading as they're not part of any "system".
-//
-// This should all be removed at some point, and just use windows.FILE_NOTIFY_*
-const (
- sysFSALLEVENTS = 0xfff
- sysFSCREATE = 0x100
- sysFSDELETE = 0x200
- sysFSDELETESELF = 0x400
- sysFSMODIFY = 0x2
- sysFSMOVE = 0xc0
- sysFSMOVEDFROM = 0x40
- sysFSMOVEDTO = 0x80
- sysFSMOVESELF = 0x800
- sysFSIGNORED = 0x8000
-)
-
-func (w *Watcher) newEvent(name string, mask uint32) Event {
- e := Event{Name: name}
- if mask&sysFSCREATE == sysFSCREATE || mask&sysFSMOVEDTO == sysFSMOVEDTO {
- e.Op |= Create
- }
- if mask&sysFSDELETE == sysFSDELETE || mask&sysFSDELETESELF == sysFSDELETESELF {
- e.Op |= Remove
- }
- if mask&sysFSMODIFY == sysFSMODIFY {
- e.Op |= Write
- }
- if mask&sysFSMOVE == sysFSMOVE || mask&sysFSMOVESELF == sysFSMOVESELF || mask&sysFSMOVEDFROM == sysFSMOVEDFROM {
- e.Op |= Rename
- }
- return e
-}
-
-const (
- opAddWatch = iota
- opRemoveWatch
-)
-
-const (
- provisional uint64 = 1 << (32 + iota)
-)
-
-type input struct {
- op int
- path string
- flags uint32
- bufsize int
- reply chan error
-}
-
-type inode struct {
- handle windows.Handle
- volume uint32
- index uint64
-}
-
-type watch struct {
- ov windows.Overlapped
- ino *inode // i-number
- recurse bool // Recursive watch?
- path string // Directory path
- mask uint64 // Directory itself is being watched with these notify flags
- names map[string]uint64 // Map of names being watched and their notify flags
- rename string // Remembers the old name while renaming a file
- buf []byte // buffer, allocated later
-}
-
-type (
- indexMap map[uint64]*watch
- watchMap map[uint32]indexMap
-)
-
-func (w *Watcher) wakeupReader() error {
- err := windows.PostQueuedCompletionStatus(w.port, 0, 0, nil)
- if err != nil {
- return os.NewSyscallError("PostQueuedCompletionStatus", err)
- }
- return nil
-}
-
-func (w *Watcher) getDir(pathname string) (dir string, err error) {
- attr, err := windows.GetFileAttributes(windows.StringToUTF16Ptr(pathname))
- if err != nil {
- return "", os.NewSyscallError("GetFileAttributes", err)
- }
- if attr&windows.FILE_ATTRIBUTE_DIRECTORY != 0 {
- dir = pathname
- } else {
- dir, _ = filepath.Split(pathname)
- dir = filepath.Clean(dir)
- }
- return
-}
-
-func (w *Watcher) getIno(path string) (ino *inode, err error) {
- h, err := windows.CreateFile(windows.StringToUTF16Ptr(path),
- windows.FILE_LIST_DIRECTORY,
- windows.FILE_SHARE_READ|windows.FILE_SHARE_WRITE|windows.FILE_SHARE_DELETE,
- nil, windows.OPEN_EXISTING,
- windows.FILE_FLAG_BACKUP_SEMANTICS|windows.FILE_FLAG_OVERLAPPED, 0)
- if err != nil {
- return nil, os.NewSyscallError("CreateFile", err)
- }
-
- var fi windows.ByHandleFileInformation
- err = windows.GetFileInformationByHandle(h, &fi)
- if err != nil {
- windows.CloseHandle(h)
- return nil, os.NewSyscallError("GetFileInformationByHandle", err)
- }
- ino = &inode{
- handle: h,
- volume: fi.VolumeSerialNumber,
- index: uint64(fi.FileIndexHigh)<<32 | uint64(fi.FileIndexLow),
- }
- return ino, nil
-}
-
-// Must run within the I/O thread.
-func (m watchMap) get(ino *inode) *watch {
- if i := m[ino.volume]; i != nil {
- return i[ino.index]
- }
- return nil
-}
-
-// Must run within the I/O thread.
-func (m watchMap) set(ino *inode, watch *watch) {
- i := m[ino.volume]
- if i == nil {
- i = make(indexMap)
- m[ino.volume] = i
- }
- i[ino.index] = watch
-}
-
-// Must run within the I/O thread.
-func (w *Watcher) addWatch(pathname string, flags uint64, bufsize int) error {
- //pathname, recurse := recursivePath(pathname)
- recurse := false
-
- dir, err := w.getDir(pathname)
- if err != nil {
- return err
- }
-
- ino, err := w.getIno(dir)
- if err != nil {
- return err
- }
- w.mu.Lock()
- watchEntry := w.watches.get(ino)
- w.mu.Unlock()
- if watchEntry == nil {
- _, err := windows.CreateIoCompletionPort(ino.handle, w.port, 0, 0)
- if err != nil {
- windows.CloseHandle(ino.handle)
- return os.NewSyscallError("CreateIoCompletionPort", err)
- }
- watchEntry = &watch{
- ino: ino,
- path: dir,
- names: make(map[string]uint64),
- recurse: recurse,
- buf: make([]byte, bufsize),
- }
- w.mu.Lock()
- w.watches.set(ino, watchEntry)
- w.mu.Unlock()
- flags |= provisional
- } else {
- windows.CloseHandle(ino.handle)
- }
- if pathname == dir {
- watchEntry.mask |= flags
- } else {
- watchEntry.names[filepath.Base(pathname)] |= flags
- }
-
- err = w.startRead(watchEntry)
- if err != nil {
- return err
- }
-
- if pathname == dir {
- watchEntry.mask &= ^provisional
- } else {
- watchEntry.names[filepath.Base(pathname)] &= ^provisional
- }
- return nil
-}
-
-// Must run within the I/O thread.
-func (w *Watcher) remWatch(pathname string) error {
- pathname, recurse := recursivePath(pathname)
-
- dir, err := w.getDir(pathname)
- if err != nil {
- return err
- }
- ino, err := w.getIno(dir)
- if err != nil {
- return err
- }
-
- w.mu.Lock()
- watch := w.watches.get(ino)
- w.mu.Unlock()
-
- if recurse && !watch.recurse {
- return fmt.Errorf("can't use \\... with non-recursive watch %q", pathname)
- }
-
- err = windows.CloseHandle(ino.handle)
- if err != nil {
- w.sendError(os.NewSyscallError("CloseHandle", err))
- }
- if watch == nil {
- return fmt.Errorf("%w: %s", ErrNonExistentWatch, pathname)
- }
- if pathname == dir {
- w.sendEvent(watch.path, watch.mask&sysFSIGNORED)
- watch.mask = 0
- } else {
- name := filepath.Base(pathname)
- w.sendEvent(filepath.Join(watch.path, name), watch.names[name]&sysFSIGNORED)
- delete(watch.names, name)
- }
-
- return w.startRead(watch)
-}
-
-// Must run within the I/O thread.
-func (w *Watcher) deleteWatch(watch *watch) {
- for name, mask := range watch.names {
- if mask&provisional == 0 {
- w.sendEvent(filepath.Join(watch.path, name), mask&sysFSIGNORED)
- }
- delete(watch.names, name)
- }
- if watch.mask != 0 {
- if watch.mask&provisional == 0 {
- w.sendEvent(watch.path, watch.mask&sysFSIGNORED)
- }
- watch.mask = 0
- }
-}
-
-// Must run within the I/O thread.
-func (w *Watcher) startRead(watch *watch) error {
- err := windows.CancelIo(watch.ino.handle)
- if err != nil {
- w.sendError(os.NewSyscallError("CancelIo", err))
- w.deleteWatch(watch)
- }
- mask := w.toWindowsFlags(watch.mask)
- for _, m := range watch.names {
- mask |= w.toWindowsFlags(m)
- }
- if mask == 0 {
- err := windows.CloseHandle(watch.ino.handle)
- if err != nil {
- w.sendError(os.NewSyscallError("CloseHandle", err))
- }
- w.mu.Lock()
- delete(w.watches[watch.ino.volume], watch.ino.index)
- w.mu.Unlock()
- return nil
- }
-
- // We need to pass the array, rather than the slice.
- hdr := (*reflect.SliceHeader)(unsafe.Pointer(&watch.buf))
- rdErr := windows.ReadDirectoryChanges(watch.ino.handle,
- (*byte)(unsafe.Pointer(hdr.Data)), uint32(hdr.Len),
- watch.recurse, mask, nil, &watch.ov, 0)
- if rdErr != nil {
- err := os.NewSyscallError("ReadDirectoryChanges", rdErr)
- if rdErr == windows.ERROR_ACCESS_DENIED && watch.mask&provisional == 0 {
- // Watched directory was probably removed
- w.sendEvent(watch.path, watch.mask&sysFSDELETESELF)
- err = nil
- }
- w.deleteWatch(watch)
- w.startRead(watch)
- return err
- }
- return nil
-}
-
-// readEvents reads from the I/O completion port, converts the
-// received events into Event objects and sends them via the Events channel.
-// Entry point to the I/O thread.
-func (w *Watcher) readEvents() {
- var (
- n uint32
- key uintptr
- ov *windows.Overlapped
- )
- runtime.LockOSThread()
-
- for {
- // This error is handled after the watch == nil check below.
- qErr := windows.GetQueuedCompletionStatus(w.port, &n, &key, &ov, windows.INFINITE)
-
- watch := (*watch)(unsafe.Pointer(ov))
- if watch == nil {
- select {
- case ch := <-w.quit:
- w.mu.Lock()
- var indexes []indexMap
- for _, index := range w.watches {
- indexes = append(indexes, index)
- }
- w.mu.Unlock()
- for _, index := range indexes {
- for _, watch := range index {
- w.deleteWatch(watch)
- w.startRead(watch)
- }
- }
-
- err := windows.CloseHandle(w.port)
- if err != nil {
- err = os.NewSyscallError("CloseHandle", err)
- }
- close(w.Events)
- close(w.Errors)
- ch <- err
- return
- case in := <-w.input:
- switch in.op {
- case opAddWatch:
- in.reply <- w.addWatch(in.path, uint64(in.flags), in.bufsize)
- case opRemoveWatch:
- in.reply <- w.remWatch(in.path)
- }
- default:
- }
- continue
- }
-
- switch qErr {
- case nil:
- // No error
- case windows.ERROR_MORE_DATA:
- if watch == nil {
- w.sendError(errors.New("ERROR_MORE_DATA has unexpectedly null lpOverlapped buffer"))
- } else {
- // The i/o succeeded but the buffer is full.
- // In theory we should be building up a full packet.
- // In practice we can get away with just carrying on.
- n = uint32(unsafe.Sizeof(watch.buf))
- }
- case windows.ERROR_ACCESS_DENIED:
- // Watched directory was probably removed
- w.sendEvent(watch.path, watch.mask&sysFSDELETESELF)
- w.deleteWatch(watch)
- w.startRead(watch)
- continue
- case windows.ERROR_OPERATION_ABORTED:
- // CancelIo was called on this handle
- continue
- default:
- w.sendError(os.NewSyscallError("GetQueuedCompletionPort", qErr))
- continue
- }
-
- var offset uint32
- for {
- if n == 0 {
- w.sendError(ErrEventOverflow)
- break
- }
-
- // Point "raw" to the event in the buffer
- raw := (*windows.FileNotifyInformation)(unsafe.Pointer(&watch.buf[offset]))
-
- // Create a buf that is the size of the path name
- size := int(raw.FileNameLength / 2)
- var buf []uint16
- // TODO: Use unsafe.Slice in Go 1.17; https://stackoverflow.com/questions/51187973
- sh := (*reflect.SliceHeader)(unsafe.Pointer(&buf))
- sh.Data = uintptr(unsafe.Pointer(&raw.FileName))
- sh.Len = size
- sh.Cap = size
- name := windows.UTF16ToString(buf)
- fullname := filepath.Join(watch.path, name)
-
- var mask uint64
- switch raw.Action {
- case windows.FILE_ACTION_REMOVED:
- mask = sysFSDELETESELF
- case windows.FILE_ACTION_MODIFIED:
- mask = sysFSMODIFY
- case windows.FILE_ACTION_RENAMED_OLD_NAME:
- watch.rename = name
- case windows.FILE_ACTION_RENAMED_NEW_NAME:
- // Update saved path of all sub-watches.
- old := filepath.Join(watch.path, watch.rename)
- w.mu.Lock()
- for _, watchMap := range w.watches {
- for _, ww := range watchMap {
- if strings.HasPrefix(ww.path, old) {
- ww.path = filepath.Join(fullname, strings.TrimPrefix(ww.path, old))
- }
- }
- }
- w.mu.Unlock()
-
- if watch.names[watch.rename] != 0 {
- watch.names[name] |= watch.names[watch.rename]
- delete(watch.names, watch.rename)
- mask = sysFSMOVESELF
- }
- }
-
- sendNameEvent := func() {
- w.sendEvent(fullname, watch.names[name]&mask)
- }
- if raw.Action != windows.FILE_ACTION_RENAMED_NEW_NAME {
- sendNameEvent()
- }
- if raw.Action == windows.FILE_ACTION_REMOVED {
- w.sendEvent(fullname, watch.names[name]&sysFSIGNORED)
- delete(watch.names, name)
- }
-
- w.sendEvent(fullname, watch.mask&w.toFSnotifyFlags(raw.Action))
- if raw.Action == windows.FILE_ACTION_RENAMED_NEW_NAME {
- fullname = filepath.Join(watch.path, watch.rename)
- sendNameEvent()
- }
-
- // Move to the next event in the buffer
- if raw.NextEntryOffset == 0 {
- break
- }
- offset += raw.NextEntryOffset
-
- // Error!
- if offset >= n {
- //lint:ignore ST1005 Windows should be capitalized
- w.sendError(errors.New(
- "Windows system assumed buffer larger than it is, events have likely been missed"))
- break
- }
- }
-
- if err := w.startRead(watch); err != nil {
- w.sendError(err)
- }
- }
-}
-
-func (w *Watcher) toWindowsFlags(mask uint64) uint32 {
- var m uint32
- if mask&sysFSMODIFY != 0 {
- m |= windows.FILE_NOTIFY_CHANGE_LAST_WRITE
- }
- if mask&(sysFSMOVE|sysFSCREATE|sysFSDELETE) != 0 {
- m |= windows.FILE_NOTIFY_CHANGE_FILE_NAME | windows.FILE_NOTIFY_CHANGE_DIR_NAME
- }
- return m
-}
-
-func (w *Watcher) toFSnotifyFlags(action uint32) uint64 {
- switch action {
- case windows.FILE_ACTION_ADDED:
- return sysFSCREATE
- case windows.FILE_ACTION_REMOVED:
- return sysFSDELETE
- case windows.FILE_ACTION_MODIFIED:
- return sysFSMODIFY
- case windows.FILE_ACTION_RENAMED_OLD_NAME:
- return sysFSMOVEDFROM
- case windows.FILE_ACTION_RENAMED_NEW_NAME:
- return sysFSMOVEDTO
- }
- return 0
-}
diff --git a/vendor/github.com/fsnotify/fsnotify/fsnotify.go b/vendor/github.com/fsnotify/fsnotify/fsnotify.go
deleted file mode 100644
index 24c99cc..0000000
--- a/vendor/github.com/fsnotify/fsnotify/fsnotify.go
+++ /dev/null
@@ -1,146 +0,0 @@
-// Package fsnotify provides a cross-platform interface for file system
-// notifications.
-//
-// Currently supported systems:
-//
-// Linux 2.6.32+ via inotify
-// BSD, macOS via kqueue
-// Windows via ReadDirectoryChangesW
-// illumos via FEN
-package fsnotify
-
-import (
- "errors"
- "fmt"
- "path/filepath"
- "strings"
-)
-
-// Event represents a file system notification.
-type Event struct {
- // Path to the file or directory.
- //
- // Paths are relative to the input; for example with Add("dir") the Name
- // will be set to "dir/file" if you create that file, but if you use
- // Add("/path/to/dir") it will be "/path/to/dir/file".
- Name string
-
- // File operation that triggered the event.
- //
- // This is a bitmask and some systems may send multiple operations at once.
- // Use the Event.Has() method instead of comparing with ==.
- Op Op
-}
-
-// Op describes a set of file operations.
-type Op uint32
-
-// The operations fsnotify can trigger; see the documentation on [Watcher] for a
-// full description, and check them with [Event.Has].
-const (
- // A new pathname was created.
- Create Op = 1 << iota
-
- // The pathname was written to; this does *not* mean the write has finished,
- // and a write can be followed by more writes.
- Write
-
- // The path was removed; any watches on it will be removed. Some "remove"
- // operations may trigger a Rename if the file is actually moved (for
- // example "remove to trash" is often a rename).
- Remove
-
- // The path was renamed to something else; any watched on it will be
- // removed.
- Rename
-
- // File attributes were changed.
- //
- // It's generally not recommended to take action on this event, as it may
- // get triggered very frequently by some software. For example, Spotlight
- // indexing on macOS, anti-virus software, backup software, etc.
- Chmod
-)
-
-// Common errors that can be reported.
-var (
- ErrNonExistentWatch = errors.New("fsnotify: can't remove non-existent watch")
- ErrEventOverflow = errors.New("fsnotify: queue or buffer overflow")
- ErrClosed = errors.New("fsnotify: watcher already closed")
-)
-
-func (o Op) String() string {
- var b strings.Builder
- if o.Has(Create) {
- b.WriteString("|CREATE")
- }
- if o.Has(Remove) {
- b.WriteString("|REMOVE")
- }
- if o.Has(Write) {
- b.WriteString("|WRITE")
- }
- if o.Has(Rename) {
- b.WriteString("|RENAME")
- }
- if o.Has(Chmod) {
- b.WriteString("|CHMOD")
- }
- if b.Len() == 0 {
- return "[no events]"
- }
- return b.String()[1:]
-}
-
-// Has reports if this operation has the given operation.
-func (o Op) Has(h Op) bool { return o&h != 0 }
-
-// Has reports if this event has the given operation.
-func (e Event) Has(op Op) bool { return e.Op.Has(op) }
-
-// String returns a string representation of the event with their path.
-func (e Event) String() string {
- return fmt.Sprintf("%-13s %q", e.Op.String(), e.Name)
-}
-
-type (
- addOpt func(opt *withOpts)
- withOpts struct {
- bufsize int
- }
-)
-
-var defaultOpts = withOpts{
- bufsize: 65536, // 64K
-}
-
-func getOptions(opts ...addOpt) withOpts {
- with := defaultOpts
- for _, o := range opts {
- o(&with)
- }
- return with
-}
-
-// WithBufferSize sets the [ReadDirectoryChangesW] buffer size.
-//
-// This only has effect on Windows systems, and is a no-op for other backends.
-//
-// The default value is 64K (65536 bytes) which is the highest value that works
-// on all filesystems and should be enough for most applications, but if you
-// have a large burst of events it may not be enough. You can increase it if
-// you're hitting "queue or buffer overflow" errors ([ErrEventOverflow]).
-//
-// [ReadDirectoryChangesW]: https://learn.microsoft.com/en-gb/windows/win32/api/winbase/nf-winbase-readdirectorychangesw
-func WithBufferSize(bytes int) addOpt {
- return func(opt *withOpts) { opt.bufsize = bytes }
-}
-
-// Check if this path is recursive (ends with "/..." or "\..."), and return the
-// path with the /... stripped.
-func recursivePath(path string) (string, bool) {
- if filepath.Base(path) == "..." {
- return filepath.Dir(path), true
- }
- return path, false
-}
diff --git a/vendor/github.com/fsnotify/fsnotify/mkdoc.zsh b/vendor/github.com/fsnotify/fsnotify/mkdoc.zsh
deleted file mode 100644
index 99012ae..0000000
--- a/vendor/github.com/fsnotify/fsnotify/mkdoc.zsh
+++ /dev/null
@@ -1,259 +0,0 @@
-#!/usr/bin/env zsh
-[ "${ZSH_VERSION:-}" = "" ] && echo >&2 "Only works with zsh" && exit 1
-setopt err_exit no_unset pipefail extended_glob
-
-# Simple script to update the godoc comments on all watchers so you don't need
-# to update the same comment 5 times.
-
-watcher=$(</tmp/x
- print -r -- $cmt >>/tmp/x
- tail -n+$(( end + 1 )) $file >>/tmp/x
- mv /tmp/x $file
- done
-}
-
-set-cmt '^type Watcher struct ' $watcher
-set-cmt '^func NewWatcher(' $new
-set-cmt '^func NewBufferedWatcher(' $newbuffered
-set-cmt '^func (w \*Watcher) Add(' $add
-set-cmt '^func (w \*Watcher) AddWith(' $addwith
-set-cmt '^func (w \*Watcher) Remove(' $remove
-set-cmt '^func (w \*Watcher) Close(' $close
-set-cmt '^func (w \*Watcher) WatchList(' $watchlist
-set-cmt '^[[:space:]]*Events *chan Event$' $events
-set-cmt '^[[:space:]]*Errors *chan error$' $errors
diff --git a/vendor/github.com/fsnotify/fsnotify/system_bsd.go b/vendor/github.com/fsnotify/fsnotify/system_bsd.go
deleted file mode 100644
index 4322b0b..0000000
--- a/vendor/github.com/fsnotify/fsnotify/system_bsd.go
+++ /dev/null
@@ -1,8 +0,0 @@
-//go:build freebsd || openbsd || netbsd || dragonfly
-// +build freebsd openbsd netbsd dragonfly
-
-package fsnotify
-
-import "golang.org/x/sys/unix"
-
-const openMode = unix.O_NONBLOCK | unix.O_RDONLY | unix.O_CLOEXEC
diff --git a/vendor/github.com/fsnotify/fsnotify/system_darwin.go b/vendor/github.com/fsnotify/fsnotify/system_darwin.go
deleted file mode 100644
index 5da5ffa..0000000
--- a/vendor/github.com/fsnotify/fsnotify/system_darwin.go
+++ /dev/null
@@ -1,9 +0,0 @@
-//go:build darwin
-// +build darwin
-
-package fsnotify
-
-import "golang.org/x/sys/unix"
-
-// note: this constant is not defined on BSD
-const openMode = unix.O_EVTONLY | unix.O_CLOEXEC
diff --git a/vendor/github.com/ghodss/yaml/.gitignore b/vendor/github.com/ghodss/yaml/.gitignore
deleted file mode 100644
index e256a31..0000000
--- a/vendor/github.com/ghodss/yaml/.gitignore
+++ /dev/null
@@ -1,20 +0,0 @@
-# OSX leaves these everywhere on SMB shares
-._*
-
-# Eclipse files
-.classpath
-.project
-.settings/**
-
-# Emacs save files
-*~
-
-# Vim-related files
-[._]*.s[a-w][a-z]
-[._]s[a-w][a-z]
-*.un~
-Session.vim
-.netrwhist
-
-# Go test binaries
-*.test
diff --git a/vendor/github.com/ghodss/yaml/.travis.yml b/vendor/github.com/ghodss/yaml/.travis.yml
deleted file mode 100644
index 0e9d6ed..0000000
--- a/vendor/github.com/ghodss/yaml/.travis.yml
+++ /dev/null
@@ -1,7 +0,0 @@
-language: go
-go:
- - 1.3
- - 1.4
-script:
- - go test
- - go build
diff --git a/vendor/github.com/ghodss/yaml/LICENSE b/vendor/github.com/ghodss/yaml/LICENSE
deleted file mode 100644
index 7805d36..0000000
--- a/vendor/github.com/ghodss/yaml/LICENSE
+++ /dev/null
@@ -1,50 +0,0 @@
-The MIT License (MIT)
-
-Copyright (c) 2014 Sam Ghods
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in all
-copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-SOFTWARE.
-
-
-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.
diff --git a/vendor/github.com/ghodss/yaml/README.md b/vendor/github.com/ghodss/yaml/README.md
deleted file mode 100644
index 0200f75..0000000
--- a/vendor/github.com/ghodss/yaml/README.md
+++ /dev/null
@@ -1,121 +0,0 @@
-# YAML marshaling and unmarshaling support for Go
-
-[](https://travis-ci.org/ghodss/yaml)
-
-## Introduction
-
-A wrapper around [go-yaml](https://github.com/go-yaml/yaml) designed to enable a better way of handling YAML when marshaling to and from structs.
-
-In short, this library first converts YAML to JSON using go-yaml and then uses `json.Marshal` and `json.Unmarshal` to convert to or from the struct. This means that it effectively reuses the JSON struct tags as well as the custom JSON methods `MarshalJSON` and `UnmarshalJSON` unlike go-yaml. For a detailed overview of the rationale behind this method, [see this blog post](http://ghodss.com/2014/the-right-way-to-handle-yaml-in-golang/).
-
-## Compatibility
-
-This package uses [go-yaml](https://github.com/go-yaml/yaml) and therefore supports [everything go-yaml supports](https://github.com/go-yaml/yaml#compatibility).
-
-## Caveats
-
-**Caveat #1:** When using `yaml.Marshal` and `yaml.Unmarshal`, binary data should NOT be preceded with the `!!binary` YAML tag. If you do, go-yaml will convert the binary data from base64 to native binary data, which is not compatible with JSON. You can still use binary in your YAML files though - just store them without the `!!binary` tag and decode the base64 in your code (e.g. in the custom JSON methods `MarshalJSON` and `UnmarshalJSON`). This also has the benefit that your YAML and your JSON binary data will be decoded exactly the same way. As an example:
-
-```
-BAD:
- exampleKey: !!binary gIGC
-
-GOOD:
- exampleKey: gIGC
-... and decode the base64 data in your code.
-```
-
-**Caveat #2:** When using `YAMLToJSON` directly, maps with keys that are maps will result in an error since this is not supported by JSON. This error will occur in `Unmarshal` as well since you can't unmarshal map keys anyways since struct fields can't be keys.
-
-## Installation and usage
-
-To install, run:
-
-```
-$ go get github.com/ghodss/yaml
-```
-
-And import using:
-
-```
-import "github.com/ghodss/yaml"
-```
-
-Usage is very similar to the JSON library:
-
-```go
-package main
-
-import (
- "fmt"
-
- "github.com/ghodss/yaml"
-)
-
-type Person struct {
- Name string `json:"name"` // Affects YAML field names too.
- Age int `json:"age"`
-}
-
-func main() {
- // Marshal a Person struct to YAML.
- p := Person{"John", 30}
- y, err := yaml.Marshal(p)
- if err != nil {
- fmt.Printf("err: %v\n", err)
- return
- }
- fmt.Println(string(y))
- /* Output:
- age: 30
- name: John
- */
-
- // Unmarshal the YAML back into a Person struct.
- var p2 Person
- err = yaml.Unmarshal(y, &p2)
- if err != nil {
- fmt.Printf("err: %v\n", err)
- return
- }
- fmt.Println(p2)
- /* Output:
- {John 30}
- */
-}
-```
-
-`yaml.YAMLToJSON` and `yaml.JSONToYAML` methods are also available:
-
-```go
-package main
-
-import (
- "fmt"
-
- "github.com/ghodss/yaml"
-)
-
-func main() {
- j := []byte(`{"name": "John", "age": 30}`)
- y, err := yaml.JSONToYAML(j)
- if err != nil {
- fmt.Printf("err: %v\n", err)
- return
- }
- fmt.Println(string(y))
- /* Output:
- name: John
- age: 30
- */
- j2, err := yaml.YAMLToJSON(y)
- if err != nil {
- fmt.Printf("err: %v\n", err)
- return
- }
- fmt.Println(string(j2))
- /* Output:
- {"age":30,"name":"John"}
- */
-}
-```
diff --git a/vendor/github.com/ghodss/yaml/fields.go b/vendor/github.com/ghodss/yaml/fields.go
deleted file mode 100644
index 5860074..0000000
--- a/vendor/github.com/ghodss/yaml/fields.go
+++ /dev/null
@@ -1,501 +0,0 @@
-// Copyright 2013 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-package yaml
-
-import (
- "bytes"
- "encoding"
- "encoding/json"
- "reflect"
- "sort"
- "strings"
- "sync"
- "unicode"
- "unicode/utf8"
-)
-
-// indirect walks down v allocating pointers as needed,
-// until it gets to a non-pointer.
-// if it encounters an Unmarshaler, indirect stops and returns that.
-// if decodingNull is true, indirect stops at the last pointer so it can be set to nil.
-func indirect(v reflect.Value, decodingNull bool) (json.Unmarshaler, encoding.TextUnmarshaler, reflect.Value) {
- // If v is a named type and is addressable,
- // start with its address, so that if the type has pointer methods,
- // we find them.
- if v.Kind() != reflect.Ptr && v.Type().Name() != "" && v.CanAddr() {
- v = v.Addr()
- }
- for {
- // Load value from interface, but only if the result will be
- // usefully addressable.
- if v.Kind() == reflect.Interface && !v.IsNil() {
- e := v.Elem()
- if e.Kind() == reflect.Ptr && !e.IsNil() && (!decodingNull || e.Elem().Kind() == reflect.Ptr) {
- v = e
- continue
- }
- }
-
- if v.Kind() != reflect.Ptr {
- break
- }
-
- if v.Elem().Kind() != reflect.Ptr && decodingNull && v.CanSet() {
- break
- }
- if v.IsNil() {
- if v.CanSet() {
- v.Set(reflect.New(v.Type().Elem()))
- } else {
- v = reflect.New(v.Type().Elem())
- }
- }
- if v.Type().NumMethod() > 0 {
- if u, ok := v.Interface().(json.Unmarshaler); ok {
- return u, nil, reflect.Value{}
- }
- if u, ok := v.Interface().(encoding.TextUnmarshaler); ok {
- return nil, u, reflect.Value{}
- }
- }
- v = v.Elem()
- }
- return nil, nil, v
-}
-
-// A field represents a single field found in a struct.
-type field struct {
- name string
- nameBytes []byte // []byte(name)
- equalFold func(s, t []byte) bool // bytes.EqualFold or equivalent
-
- tag bool
- index []int
- typ reflect.Type
- omitEmpty bool
- quoted bool
-}
-
-func fillField(f field) field {
- f.nameBytes = []byte(f.name)
- f.equalFold = foldFunc(f.nameBytes)
- return f
-}
-
-// byName sorts field by name, breaking ties with depth,
-// then breaking ties with "name came from json tag", then
-// breaking ties with index sequence.
-type byName []field
-
-func (x byName) Len() int { return len(x) }
-
-func (x byName) Swap(i, j int) { x[i], x[j] = x[j], x[i] }
-
-func (x byName) Less(i, j int) bool {
- if x[i].name != x[j].name {
- return x[i].name < x[j].name
- }
- if len(x[i].index) != len(x[j].index) {
- return len(x[i].index) < len(x[j].index)
- }
- if x[i].tag != x[j].tag {
- return x[i].tag
- }
- return byIndex(x).Less(i, j)
-}
-
-// byIndex sorts field by index sequence.
-type byIndex []field
-
-func (x byIndex) Len() int { return len(x) }
-
-func (x byIndex) Swap(i, j int) { x[i], x[j] = x[j], x[i] }
-
-func (x byIndex) Less(i, j int) bool {
- for k, xik := range x[i].index {
- if k >= len(x[j].index) {
- return false
- }
- if xik != x[j].index[k] {
- return xik < x[j].index[k]
- }
- }
- return len(x[i].index) < len(x[j].index)
-}
-
-// typeFields returns a list of fields that JSON should recognize for the given type.
-// The algorithm is breadth-first search over the set of structs to include - the top struct
-// and then any reachable anonymous structs.
-func typeFields(t reflect.Type) []field {
- // Anonymous fields to explore at the current level and the next.
- current := []field{}
- next := []field{{typ: t}}
-
- // Count of queued names for current level and the next.
- count := map[reflect.Type]int{}
- nextCount := map[reflect.Type]int{}
-
- // Types already visited at an earlier level.
- visited := map[reflect.Type]bool{}
-
- // Fields found.
- var fields []field
-
- for len(next) > 0 {
- current, next = next, current[:0]
- count, nextCount = nextCount, map[reflect.Type]int{}
-
- for _, f := range current {
- if visited[f.typ] {
- continue
- }
- visited[f.typ] = true
-
- // Scan f.typ for fields to include.
- for i := 0; i < f.typ.NumField(); i++ {
- sf := f.typ.Field(i)
- if sf.PkgPath != "" { // unexported
- continue
- }
- tag := sf.Tag.Get("json")
- if tag == "-" {
- continue
- }
- name, opts := parseTag(tag)
- if !isValidTag(name) {
- name = ""
- }
- index := make([]int, len(f.index)+1)
- copy(index, f.index)
- index[len(f.index)] = i
-
- ft := sf.Type
- if ft.Name() == "" && ft.Kind() == reflect.Ptr {
- // Follow pointer.
- ft = ft.Elem()
- }
-
- // Record found field and index sequence.
- if name != "" || !sf.Anonymous || ft.Kind() != reflect.Struct {
- tagged := name != ""
- if name == "" {
- name = sf.Name
- }
- fields = append(fields, fillField(field{
- name: name,
- tag: tagged,
- index: index,
- typ: ft,
- omitEmpty: opts.Contains("omitempty"),
- quoted: opts.Contains("string"),
- }))
- if count[f.typ] > 1 {
- // If there were multiple instances, add a second,
- // so that the annihilation code will see a duplicate.
- // It only cares about the distinction between 1 or 2,
- // so don't bother generating any more copies.
- fields = append(fields, fields[len(fields)-1])
- }
- continue
- }
-
- // Record new anonymous struct to explore in next round.
- nextCount[ft]++
- if nextCount[ft] == 1 {
- next = append(next, fillField(field{name: ft.Name(), index: index, typ: ft}))
- }
- }
- }
- }
-
- sort.Sort(byName(fields))
-
- // Delete all fields that are hidden by the Go rules for embedded fields,
- // except that fields with JSON tags are promoted.
-
- // The fields are sorted in primary order of name, secondary order
- // of field index length. Loop over names; for each name, delete
- // hidden fields by choosing the one dominant field that survives.
- out := fields[:0]
- for advance, i := 0, 0; i < len(fields); i += advance {
- // One iteration per name.
- // Find the sequence of fields with the name of this first field.
- fi := fields[i]
- name := fi.name
- for advance = 1; i+advance < len(fields); advance++ {
- fj := fields[i+advance]
- if fj.name != name {
- break
- }
- }
- if advance == 1 { // Only one field with this name
- out = append(out, fi)
- continue
- }
- dominant, ok := dominantField(fields[i : i+advance])
- if ok {
- out = append(out, dominant)
- }
- }
-
- fields = out
- sort.Sort(byIndex(fields))
-
- return fields
-}
-
-// dominantField looks through the fields, all of which are known to
-// have the same name, to find the single field that dominates the
-// others using Go's embedding rules, modified by the presence of
-// JSON tags. If there are multiple top-level fields, the boolean
-// will be false: This condition is an error in Go and we skip all
-// the fields.
-func dominantField(fields []field) (field, bool) {
- // The fields are sorted in increasing index-length order. The winner
- // must therefore be one with the shortest index length. Drop all
- // longer entries, which is easy: just truncate the slice.
- length := len(fields[0].index)
- tagged := -1 // Index of first tagged field.
- for i, f := range fields {
- if len(f.index) > length {
- fields = fields[:i]
- break
- }
- if f.tag {
- if tagged >= 0 {
- // Multiple tagged fields at the same level: conflict.
- // Return no field.
- return field{}, false
- }
- tagged = i
- }
- }
- if tagged >= 0 {
- return fields[tagged], true
- }
- // All remaining fields have the same length. If there's more than one,
- // we have a conflict (two fields named "X" at the same level) and we
- // return no field.
- if len(fields) > 1 {
- return field{}, false
- }
- return fields[0], true
-}
-
-var fieldCache struct {
- sync.RWMutex
- m map[reflect.Type][]field
-}
-
-// cachedTypeFields is like typeFields but uses a cache to avoid repeated work.
-func cachedTypeFields(t reflect.Type) []field {
- fieldCache.RLock()
- f := fieldCache.m[t]
- fieldCache.RUnlock()
- if f != nil {
- return f
- }
-
- // Compute fields without lock.
- // Might duplicate effort but won't hold other computations back.
- f = typeFields(t)
- if f == nil {
- f = []field{}
- }
-
- fieldCache.Lock()
- if fieldCache.m == nil {
- fieldCache.m = map[reflect.Type][]field{}
- }
- fieldCache.m[t] = f
- fieldCache.Unlock()
- return f
-}
-
-func isValidTag(s string) bool {
- if s == "" {
- return false
- }
- for _, c := range s {
- switch {
- case strings.ContainsRune("!#$%&()*+-./:<=>?@[]^_{|}~ ", c):
- // Backslash and quote chars are reserved, but
- // otherwise any punctuation chars are allowed
- // in a tag name.
- default:
- if !unicode.IsLetter(c) && !unicode.IsDigit(c) {
- return false
- }
- }
- }
- return true
-}
-
-const (
- caseMask = ^byte(0x20) // Mask to ignore case in ASCII.
- kelvin = '\u212a'
- smallLongEss = '\u017f'
-)
-
-// foldFunc returns one of four different case folding equivalence
-// functions, from most general (and slow) to fastest:
-//
-// 1) bytes.EqualFold, if the key s contains any non-ASCII UTF-8
-// 2) equalFoldRight, if s contains special folding ASCII ('k', 'K', 's', 'S')
-// 3) asciiEqualFold, no special, but includes non-letters (including _)
-// 4) simpleLetterEqualFold, no specials, no non-letters.
-//
-// The letters S and K are special because they map to 3 runes, not just 2:
-// * S maps to s and to U+017F 'ſ' Latin small letter long s
-// * k maps to K and to U+212A 'K' Kelvin sign
-// See http://play.golang.org/p/tTxjOc0OGo
-//
-// The returned function is specialized for matching against s and
-// should only be given s. It's not curried for performance reasons.
-func foldFunc(s []byte) func(s, t []byte) bool {
- nonLetter := false
- special := false // special letter
- for _, b := range s {
- if b >= utf8.RuneSelf {
- return bytes.EqualFold
- }
- upper := b & caseMask
- if upper < 'A' || upper > 'Z' {
- nonLetter = true
- } else if upper == 'K' || upper == 'S' {
- // See above for why these letters are special.
- special = true
- }
- }
- if special {
- return equalFoldRight
- }
- if nonLetter {
- return asciiEqualFold
- }
- return simpleLetterEqualFold
-}
-
-// equalFoldRight is a specialization of bytes.EqualFold when s is
-// known to be all ASCII (including punctuation), but contains an 's',
-// 'S', 'k', or 'K', requiring a Unicode fold on the bytes in t.
-// See comments on foldFunc.
-func equalFoldRight(s, t []byte) bool {
- for _, sb := range s {
- if len(t) == 0 {
- return false
- }
- tb := t[0]
- if tb < utf8.RuneSelf {
- if sb != tb {
- sbUpper := sb & caseMask
- if 'A' <= sbUpper && sbUpper <= 'Z' {
- if sbUpper != tb&caseMask {
- return false
- }
- } else {
- return false
- }
- }
- t = t[1:]
- continue
- }
- // sb is ASCII and t is not. t must be either kelvin
- // sign or long s; sb must be s, S, k, or K.
- tr, size := utf8.DecodeRune(t)
- switch sb {
- case 's', 'S':
- if tr != smallLongEss {
- return false
- }
- case 'k', 'K':
- if tr != kelvin {
- return false
- }
- default:
- return false
- }
- t = t[size:]
-
- }
- if len(t) > 0 {
- return false
- }
- return true
-}
-
-// asciiEqualFold is a specialization of bytes.EqualFold for use when
-// s is all ASCII (but may contain non-letters) and contains no
-// special-folding letters.
-// See comments on foldFunc.
-func asciiEqualFold(s, t []byte) bool {
- if len(s) != len(t) {
- return false
- }
- for i, sb := range s {
- tb := t[i]
- if sb == tb {
- continue
- }
- if ('a' <= sb && sb <= 'z') || ('A' <= sb && sb <= 'Z') {
- if sb&caseMask != tb&caseMask {
- return false
- }
- } else {
- return false
- }
- }
- return true
-}
-
-// simpleLetterEqualFold is a specialization of bytes.EqualFold for
-// use when s is all ASCII letters (no underscores, etc) and also
-// doesn't contain 'k', 'K', 's', or 'S'.
-// See comments on foldFunc.
-func simpleLetterEqualFold(s, t []byte) bool {
- if len(s) != len(t) {
- return false
- }
- for i, b := range s {
- if b&caseMask != t[i]&caseMask {
- return false
- }
- }
- return true
-}
-
-// tagOptions is the string following a comma in a struct field's "json"
-// tag, or the empty string. It does not include the leading comma.
-type tagOptions string
-
-// parseTag splits a struct field's json tag into its name and
-// comma-separated options.
-func parseTag(tag string) (string, tagOptions) {
- if idx := strings.Index(tag, ","); idx != -1 {
- return tag[:idx], tagOptions(tag[idx+1:])
- }
- return tag, tagOptions("")
-}
-
-// Contains reports whether a comma-separated list of options
-// contains a particular substr flag. substr must be surrounded by a
-// string boundary or commas.
-func (o tagOptions) Contains(optionName string) bool {
- if len(o) == 0 {
- return false
- }
- s := string(o)
- for s != "" {
- var next string
- i := strings.Index(s, ",")
- if i >= 0 {
- s, next = s[:i], s[i+1:]
- }
- if s == optionName {
- return true
- }
- s = next
- }
- return false
-}
diff --git a/vendor/github.com/ghodss/yaml/yaml.go b/vendor/github.com/ghodss/yaml/yaml.go
deleted file mode 100644
index 4fb4054..0000000
--- a/vendor/github.com/ghodss/yaml/yaml.go
+++ /dev/null
@@ -1,277 +0,0 @@
-package yaml
-
-import (
- "bytes"
- "encoding/json"
- "fmt"
- "reflect"
- "strconv"
-
- "gopkg.in/yaml.v2"
-)
-
-// Marshals the object into JSON then converts JSON to YAML and returns the
-// YAML.
-func Marshal(o interface{}) ([]byte, error) {
- j, err := json.Marshal(o)
- if err != nil {
- return nil, fmt.Errorf("error marshaling into JSON: %v", err)
- }
-
- y, err := JSONToYAML(j)
- if err != nil {
- return nil, fmt.Errorf("error converting JSON to YAML: %v", err)
- }
-
- return y, nil
-}
-
-// Converts YAML to JSON then uses JSON to unmarshal into an object.
-func Unmarshal(y []byte, o interface{}) error {
- vo := reflect.ValueOf(o)
- j, err := yamlToJSON(y, &vo)
- if err != nil {
- return fmt.Errorf("error converting YAML to JSON: %v", err)
- }
-
- err = json.Unmarshal(j, o)
- if err != nil {
- return fmt.Errorf("error unmarshaling JSON: %v", err)
- }
-
- return nil
-}
-
-// Convert JSON to YAML.
-func JSONToYAML(j []byte) ([]byte, error) {
- // Convert the JSON to an object.
- var jsonObj interface{}
- // We are using yaml.Unmarshal here (instead of json.Unmarshal) because the
- // Go JSON library doesn't try to pick the right number type (int, float,
- // etc.) when unmarshalling to interface{}, it just picks float64
- // universally. go-yaml does go through the effort of picking the right
- // number type, so we can preserve number type throughout this process.
- err := yaml.Unmarshal(j, &jsonObj)
- if err != nil {
- return nil, err
- }
-
- // Marshal this object into YAML.
- return yaml.Marshal(jsonObj)
-}
-
-// Convert YAML to JSON. Since JSON is a subset of YAML, passing JSON through
-// this method should be a no-op.
-//
-// Things YAML can do that are not supported by JSON:
-// * In YAML you can have binary and null keys in your maps. These are invalid
-// in JSON. (int and float keys are converted to strings.)
-// * Binary data in YAML with the !!binary tag is not supported. If you want to
-// use binary data with this library, encode the data as base64 as usual but do
-// not use the !!binary tag in your YAML. This will ensure the original base64
-// encoded data makes it all the way through to the JSON.
-func YAMLToJSON(y []byte) ([]byte, error) {
- return yamlToJSON(y, nil)
-}
-
-func yamlToJSON(y []byte, jsonTarget *reflect.Value) ([]byte, error) {
- // Convert the YAML to an object.
- var yamlObj interface{}
- err := yaml.Unmarshal(y, &yamlObj)
- if err != nil {
- return nil, err
- }
-
- // YAML objects are not completely compatible with JSON objects (e.g. you
- // can have non-string keys in YAML). So, convert the YAML-compatible object
- // to a JSON-compatible object, failing with an error if irrecoverable
- // incompatibilties happen along the way.
- jsonObj, err := convertToJSONableObject(yamlObj, jsonTarget)
- if err != nil {
- return nil, err
- }
-
- // Convert this object to JSON and return the data.
- return json.Marshal(jsonObj)
-}
-
-func convertToJSONableObject(yamlObj interface{}, jsonTarget *reflect.Value) (interface{}, error) {
- var err error
-
- // Resolve jsonTarget to a concrete value (i.e. not a pointer or an
- // interface). We pass decodingNull as false because we're not actually
- // decoding into the value, we're just checking if the ultimate target is a
- // string.
- if jsonTarget != nil {
- ju, tu, pv := indirect(*jsonTarget, false)
- // We have a JSON or Text Umarshaler at this level, so we can't be trying
- // to decode into a string.
- if ju != nil || tu != nil {
- jsonTarget = nil
- } else {
- jsonTarget = &pv
- }
- }
-
- // If yamlObj is a number or a boolean, check if jsonTarget is a string -
- // if so, coerce. Else return normal.
- // If yamlObj is a map or array, find the field that each key is
- // unmarshaling to, and when you recurse pass the reflect.Value for that
- // field back into this function.
- switch typedYAMLObj := yamlObj.(type) {
- case map[interface{}]interface{}:
- // JSON does not support arbitrary keys in a map, so we must convert
- // these keys to strings.
- //
- // From my reading of go-yaml v2 (specifically the resolve function),
- // keys can only have the types string, int, int64, float64, binary
- // (unsupported), or null (unsupported).
- strMap := make(map[string]interface{})
- for k, v := range typedYAMLObj {
- // Resolve the key to a string first.
- var keyString string
- switch typedKey := k.(type) {
- case string:
- keyString = typedKey
- case int:
- keyString = strconv.Itoa(typedKey)
- case int64:
- // go-yaml will only return an int64 as a key if the system
- // architecture is 32-bit and the key's value is between 32-bit
- // and 64-bit. Otherwise the key type will simply be int.
- keyString = strconv.FormatInt(typedKey, 10)
- case float64:
- // Stolen from go-yaml to use the same conversion to string as
- // the go-yaml library uses to convert float to string when
- // Marshaling.
- s := strconv.FormatFloat(typedKey, 'g', -1, 32)
- switch s {
- case "+Inf":
- s = ".inf"
- case "-Inf":
- s = "-.inf"
- case "NaN":
- s = ".nan"
- }
- keyString = s
- case bool:
- if typedKey {
- keyString = "true"
- } else {
- keyString = "false"
- }
- default:
- return nil, fmt.Errorf("Unsupported map key of type: %s, key: %+#v, value: %+#v",
- reflect.TypeOf(k), k, v)
- }
-
- // jsonTarget should be a struct or a map. If it's a struct, find
- // the field it's going to map to and pass its reflect.Value. If
- // it's a map, find the element type of the map and pass the
- // reflect.Value created from that type. If it's neither, just pass
- // nil - JSON conversion will error for us if it's a real issue.
- if jsonTarget != nil {
- t := *jsonTarget
- if t.Kind() == reflect.Struct {
- keyBytes := []byte(keyString)
- // Find the field that the JSON library would use.
- var f *field
- fields := cachedTypeFields(t.Type())
- for i := range fields {
- ff := &fields[i]
- if bytes.Equal(ff.nameBytes, keyBytes) {
- f = ff
- break
- }
- // Do case-insensitive comparison.
- if f == nil && ff.equalFold(ff.nameBytes, keyBytes) {
- f = ff
- }
- }
- if f != nil {
- // Find the reflect.Value of the most preferential
- // struct field.
- jtf := t.Field(f.index[0])
- strMap[keyString], err = convertToJSONableObject(v, &jtf)
- if err != nil {
- return nil, err
- }
- continue
- }
- } else if t.Kind() == reflect.Map {
- // Create a zero value of the map's element type to use as
- // the JSON target.
- jtv := reflect.Zero(t.Type().Elem())
- strMap[keyString], err = convertToJSONableObject(v, &jtv)
- if err != nil {
- return nil, err
- }
- continue
- }
- }
- strMap[keyString], err = convertToJSONableObject(v, nil)
- if err != nil {
- return nil, err
- }
- }
- return strMap, nil
- case []interface{}:
- // We need to recurse into arrays in case there are any
- // map[interface{}]interface{}'s inside and to convert any
- // numbers to strings.
-
- // If jsonTarget is a slice (which it really should be), find the
- // thing it's going to map to. If it's not a slice, just pass nil
- // - JSON conversion will error for us if it's a real issue.
- var jsonSliceElemValue *reflect.Value
- if jsonTarget != nil {
- t := *jsonTarget
- if t.Kind() == reflect.Slice {
- // By default slices point to nil, but we need a reflect.Value
- // pointing to a value of the slice type, so we create one here.
- ev := reflect.Indirect(reflect.New(t.Type().Elem()))
- jsonSliceElemValue = &ev
- }
- }
-
- // Make and use a new array.
- arr := make([]interface{}, len(typedYAMLObj))
- for i, v := range typedYAMLObj {
- arr[i], err = convertToJSONableObject(v, jsonSliceElemValue)
- if err != nil {
- return nil, err
- }
- }
- return arr, nil
- default:
- // If the target type is a string and the YAML type is a number,
- // convert the YAML type to a string.
- if jsonTarget != nil && (*jsonTarget).Kind() == reflect.String {
- // Based on my reading of go-yaml, it may return int, int64,
- // float64, or uint64.
- var s string
- switch typedVal := typedYAMLObj.(type) {
- case int:
- s = strconv.FormatInt(int64(typedVal), 10)
- case int64:
- s = strconv.FormatInt(typedVal, 10)
- case float64:
- s = strconv.FormatFloat(typedVal, 'g', -1, 32)
- case uint64:
- s = strconv.FormatUint(typedVal, 10)
- case bool:
- if typedVal {
- s = "true"
- } else {
- s = "false"
- }
- }
- if len(s) > 0 {
- yamlObj = interface{}(s)
- }
- }
- return yamlObj, nil
- }
-
- return nil, nil
-}
diff --git a/vendor/github.com/go-chi/chi/v5/.gitignore b/vendor/github.com/go-chi/chi/v5/.gitignore
deleted file mode 100644
index ba22c99..0000000
--- a/vendor/github.com/go-chi/chi/v5/.gitignore
+++ /dev/null
@@ -1,3 +0,0 @@
-.idea
-*.sw?
-.vscode
diff --git a/vendor/github.com/go-chi/chi/v5/CHANGELOG.md b/vendor/github.com/go-chi/chi/v5/CHANGELOG.md
deleted file mode 100644
index 25b45b9..0000000
--- a/vendor/github.com/go-chi/chi/v5/CHANGELOG.md
+++ /dev/null
@@ -1,341 +0,0 @@
-# Changelog
-
-## v5.0.12 (2024-02-16)
-
-- History of changes: see https://github.com/go-chi/chi/compare/v5.0.11...v5.0.12
-
-
-## v5.0.11 (2023-12-19)
-
-- History of changes: see https://github.com/go-chi/chi/compare/v5.0.10...v5.0.11
-
-
-## v5.0.10 (2023-07-13)
-
-- Fixed small edge case in tests of v5.0.9 for older Go versions
-- History of changes: see https://github.com/go-chi/chi/compare/v5.0.9...v5.0.10
-
-
-## v5.0.9 (2023-07-13)
-
-- History of changes: see https://github.com/go-chi/chi/compare/v5.0.8...v5.0.9
-
-
-## v5.0.8 (2022-12-07)
-
-- History of changes: see https://github.com/go-chi/chi/compare/v5.0.7...v5.0.8
-
-
-## v5.0.7 (2021-11-18)
-
-- History of changes: see https://github.com/go-chi/chi/compare/v5.0.6...v5.0.7
-
-
-## v5.0.6 (2021-11-15)
-
-- History of changes: see https://github.com/go-chi/chi/compare/v5.0.5...v5.0.6
-
-
-## v5.0.5 (2021-10-27)
-
-- History of changes: see https://github.com/go-chi/chi/compare/v5.0.4...v5.0.5
-
-
-## v5.0.4 (2021-08-29)
-
-- History of changes: see https://github.com/go-chi/chi/compare/v5.0.3...v5.0.4
-
-
-## v5.0.3 (2021-04-29)
-
-- History of changes: see https://github.com/go-chi/chi/compare/v5.0.2...v5.0.3
-
-
-## v5.0.2 (2021-03-25)
-
-- History of changes: see https://github.com/go-chi/chi/compare/v5.0.1...v5.0.2
-
-
-## v5.0.1 (2021-03-10)
-
-- Small improvements
-- History of changes: see https://github.com/go-chi/chi/compare/v5.0.0...v5.0.1
-
-
-## v5.0.0 (2021-02-27)
-
-- chi v5, `github.com/go-chi/chi/v5` introduces the adoption of Go's SIV to adhere to the current state-of-the-tools in Go.
-- chi v1.5.x did not work out as planned, as the Go tooling is too powerful and chi's adoption is too wide.
- The most responsible thing to do for everyone's benefit is to just release v5 with SIV, so I present to you all,
- chi v5 at `github.com/go-chi/chi/v5`. I hope someday the developer experience and ergonomics I've been seeking
- will still come to fruition in some form, see https://github.com/golang/go/issues/44550
-- History of changes: see https://github.com/go-chi/chi/compare/v1.5.4...v5.0.0
-
-
-## v1.5.4 (2021-02-27)
-
-- Undo prior retraction in v1.5.3 as we prepare for v5.0.0 release
-- History of changes: see https://github.com/go-chi/chi/compare/v1.5.3...v1.5.4
-
-
-## v1.5.3 (2021-02-21)
-
-- Update go.mod to go 1.16 with new retract directive marking all versions without prior go.mod support
-- History of changes: see https://github.com/go-chi/chi/compare/v1.5.2...v1.5.3
-
-
-## v1.5.2 (2021-02-10)
-
-- Reverting allocation optimization as a precaution as go test -race fails.
-- Minor improvements, see history below
-- History of changes: see https://github.com/go-chi/chi/compare/v1.5.1...v1.5.2
-
-
-## v1.5.1 (2020-12-06)
-
-- Performance improvement: removing 1 allocation by foregoing context.WithValue, thank you @bouk for
- your contribution (https://github.com/go-chi/chi/pull/555). Note: new benchmarks posted in README.
-- `middleware.CleanPath`: new middleware that clean's request path of double slashes
-- deprecate & remove `chi.ServerBaseContext` in favour of stdlib `http.Server#BaseContext`
-- plus other tiny improvements, see full commit history below
-- History of changes: see https://github.com/go-chi/chi/compare/v4.1.2...v1.5.1
-
-
-## v1.5.0 (2020-11-12) - now with go.mod support
-
-`chi` dates back to 2016 with it's original implementation as one of the first routers to adopt the newly introduced
-context.Context api to the stdlib -- set out to design a router that is faster, more modular and simpler than anything
-else out there -- while not introducing any custom handler types or dependencies. Today, `chi` still has zero dependencies,
-and in many ways is future proofed from changes, given it's minimal nature. Between versions, chi's iterations have been very
-incremental, with the architecture and api being the same today as it was originally designed in 2016. For this reason it
-makes chi a pretty easy project to maintain, as well thanks to the many amazing community contributions over the years
-to who all help make chi better (total of 86 contributors to date -- thanks all!).
-
-Chi has been a labour of love, art and engineering, with the goals to offer beautiful ergonomics, flexibility, performance
-and simplicity when building HTTP services with Go. I've strived to keep the router very minimal in surface area / code size,
-and always improving the code wherever possible -- and as of today the `chi` package is just 1082 lines of code (not counting
-middlewares, which are all optional). As well, I don't have the exact metrics, but from my analysis and email exchanges from
-companies and developers, chi is used by thousands of projects around the world -- thank you all as there is no better form of
-joy for me than to have art I had started be helpful and enjoyed by others. And of course I use chi in all of my own projects too :)
-
-For me, the aesthetics of chi's code and usage are very important. With the introduction of Go's module support
-(which I'm a big fan of), chi's past versioning scheme choice to v2, v3 and v4 would mean I'd require the import path
-of "github.com/go-chi/chi/v4", leading to the lengthy discussion at https://github.com/go-chi/chi/issues/462.
-Haha, to some, you may be scratching your head why I've spent > 1 year stalling to adopt "/vXX" convention in the import
-path -- which isn't horrible in general -- but for chi, I'm unable to accept it as I strive for perfection in it's API design,
-aesthetics and simplicity. It just doesn't feel good to me given chi's simple nature -- I do not foresee a "v5" or "v6",
-and upgrading between versions in the future will also be just incremental.
-
-I do understand versioning is a part of the API design as well, which is why the solution for a while has been to "do nothing",
-as Go supports both old and new import paths with/out go.mod. However, now that Go module support has had time to iron out kinks and
-is adopted everywhere, it's time for chi to get with the times. Luckily, I've discovered a path forward that will make me happy,
-while also not breaking anyone's app who adopted a prior versioning from tags in v2/v3/v4. I've made an experimental release of
-v1.5.0 with go.mod silently, and tested it with new and old projects, to ensure the developer experience is preserved, and it's
-largely unnoticed. Fortunately, Go's toolchain will check the tags of a repo and consider the "latest" tag the one with go.mod.
-However, you can still request a specific older tag such as v4.1.2, and everything will "just work". But new users can just
-`go get github.com/go-chi/chi` or `go get github.com/go-chi/chi@latest` and they will get the latest version which contains
-go.mod support, which is v1.5.0+. `chi` will not change very much over the years, just like it hasn't changed much from 4 years ago.
-Therefore, we will stay on v1.x from here on, starting from v1.5.0. Any breaking changes will bump a "minor" release and
-backwards-compatible improvements/fixes will bump a "tiny" release.
-
-For existing projects who want to upgrade to the latest go.mod version, run: `go get -u github.com/go-chi/chi@v1.5.0`,
-which will get you on the go.mod version line (as Go's mod cache may still remember v4.x). Brand new systems can run
-`go get -u github.com/go-chi/chi` or `go get -u github.com/go-chi/chi@latest` to install chi, which will install v1.5.0+
-built with go.mod support.
-
-My apologies to the developers who will disagree with the decisions above, but, hope you'll try it and see it's a very
-minor request which is backwards compatible and won't break your existing installations.
-
-Cheers all, happy coding!
-
-
----
-
-
-## v4.1.2 (2020-06-02)
-
-- fix that handles MethodNotAllowed with path variables, thank you @caseyhadden for your contribution
-- fix to replace nested wildcards correctly in RoutePattern, thank you @@unmultimedio for your contribution
-- History of changes: see https://github.com/go-chi/chi/compare/v4.1.1...v4.1.2
-
-
-## v4.1.1 (2020-04-16)
-
-- fix for issue https://github.com/go-chi/chi/issues/411 which allows for overlapping regexp
- route to the correct handler through a recursive tree search, thanks to @Jahaja for the PR/fix!
-- new middleware.RouteHeaders as a simple router for request headers with wildcard support
-- History of changes: see https://github.com/go-chi/chi/compare/v4.1.0...v4.1.1
-
-
-## v4.1.0 (2020-04-1)
-
-- middleware.LogEntry: Write method on interface now passes the response header
- and an extra interface type useful for custom logger implementations.
-- middleware.WrapResponseWriter: minor fix
-- middleware.Recoverer: a bit prettier
-- History of changes: see https://github.com/go-chi/chi/compare/v4.0.4...v4.1.0
-
-## v4.0.4 (2020-03-24)
-
-- middleware.Recoverer: new pretty stack trace printing (https://github.com/go-chi/chi/pull/496)
-- a few minor improvements and fixes
-- History of changes: see https://github.com/go-chi/chi/compare/v4.0.3...v4.0.4
-
-
-## v4.0.3 (2020-01-09)
-
-- core: fix regexp routing to include default value when param is not matched
-- middleware: rewrite of middleware.Compress
-- middleware: suppress http.ErrAbortHandler in middleware.Recoverer
-- History of changes: see https://github.com/go-chi/chi/compare/v4.0.2...v4.0.3
-
-
-## v4.0.2 (2019-02-26)
-
-- Minor fixes
-- History of changes: see https://github.com/go-chi/chi/compare/v4.0.1...v4.0.2
-
-
-## v4.0.1 (2019-01-21)
-
-- Fixes issue with compress middleware: #382 #385
-- History of changes: see https://github.com/go-chi/chi/compare/v4.0.0...v4.0.1
-
-
-## v4.0.0 (2019-01-10)
-
-- chi v4 requires Go 1.10.3+ (or Go 1.9.7+) - we have deprecated support for Go 1.7 and 1.8
-- router: respond with 404 on router with no routes (#362)
-- router: additional check to ensure wildcard is at the end of a url pattern (#333)
-- middleware: deprecate use of http.CloseNotifier (#347)
-- middleware: fix RedirectSlashes to include query params on redirect (#334)
-- History of changes: see https://github.com/go-chi/chi/compare/v3.3.4...v4.0.0
-
-
-## v3.3.4 (2019-01-07)
-
-- Minor middleware improvements. No changes to core library/router. Moving v3 into its
-- own branch as a version of chi for Go 1.7, 1.8, 1.9, 1.10, 1.11
-- History of changes: see https://github.com/go-chi/chi/compare/v3.3.3...v3.3.4
-
-
-## v3.3.3 (2018-08-27)
-
-- Minor release
-- See https://github.com/go-chi/chi/compare/v3.3.2...v3.3.3
-
-
-## v3.3.2 (2017-12-22)
-
-- Support to route trailing slashes on mounted sub-routers (#281)
-- middleware: new `ContentCharset` to check matching charsets. Thank you
- @csucu for your community contribution!
-
-
-## v3.3.1 (2017-11-20)
-
-- middleware: new `AllowContentType` handler for explicit whitelist of accepted request Content-Types
-- middleware: new `SetHeader` handler for short-hand middleware to set a response header key/value
-- Minor bug fixes
-
-
-## v3.3.0 (2017-10-10)
-
-- New chi.RegisterMethod(method) to add support for custom HTTP methods, see _examples/custom-method for usage
-- Deprecated LINK and UNLINK methods from the default list, please use `chi.RegisterMethod("LINK")` and `chi.RegisterMethod("UNLINK")` in an `init()` function
-
-
-## v3.2.1 (2017-08-31)
-
-- Add new `Match(rctx *Context, method, path string) bool` method to `Routes` interface
- and `Mux`. Match searches the mux's routing tree for a handler that matches the method/path
-- Add new `RouteMethod` to `*Context`
-- Add new `Routes` pointer to `*Context`
-- Add new `middleware.GetHead` to route missing HEAD requests to GET handler
-- Updated benchmarks (see README)
-
-
-## v3.1.5 (2017-08-02)
-
-- Setup golint and go vet for the project
-- As per golint, we've redefined `func ServerBaseContext(h http.Handler, baseCtx context.Context) http.Handler`
- to `func ServerBaseContext(baseCtx context.Context, h http.Handler) http.Handler`
-
-
-## v3.1.0 (2017-07-10)
-
-- Fix a few minor issues after v3 release
-- Move `docgen` sub-pkg to https://github.com/go-chi/docgen
-- Move `render` sub-pkg to https://github.com/go-chi/render
-- Add new `URLFormat` handler to chi/middleware sub-pkg to make working with url mime
- suffixes easier, ie. parsing `/articles/1.json` and `/articles/1.xml`. See comments in
- https://github.com/go-chi/chi/blob/master/middleware/url_format.go for example usage.
-
-
-## v3.0.0 (2017-06-21)
-
-- Major update to chi library with many exciting updates, but also some *breaking changes*
-- URL parameter syntax changed from `/:id` to `/{id}` for even more flexible routing, such as
- `/articles/{month}-{day}-{year}-{slug}`, `/articles/{id}`, and `/articles/{id}.{ext}` on the
- same router
-- Support for regexp for routing patterns, in the form of `/{paramKey:regExp}` for example:
- `r.Get("/articles/{name:[a-z]+}", h)` and `chi.URLParam(r, "name")`
-- Add `Method` and `MethodFunc` to `chi.Router` to allow routing definitions such as
- `r.Method("GET", "/", h)` which provides a cleaner interface for custom handlers like
- in `_examples/custom-handler`
-- Deprecating `mux#FileServer` helper function. Instead, we encourage users to create their
- own using file handler with the stdlib, see `_examples/fileserver` for an example
-- Add support for LINK/UNLINK http methods via `r.Method()` and `r.MethodFunc()`
-- Moved the chi project to its own organization, to allow chi-related community packages to
- be easily discovered and supported, at: https://github.com/go-chi
-- *NOTE:* please update your import paths to `"github.com/go-chi/chi"`
-- *NOTE:* chi v2 is still available at https://github.com/go-chi/chi/tree/v2
-
-
-## v2.1.0 (2017-03-30)
-
-- Minor improvements and update to the chi core library
-- Introduced a brand new `chi/render` sub-package to complete the story of building
- APIs to offer a pattern for managing well-defined request / response payloads. Please
- check out the updated `_examples/rest` example for how it works.
-- Added `MethodNotAllowed(h http.HandlerFunc)` to chi.Router interface
-
-
-## v2.0.0 (2017-01-06)
-
-- After many months of v2 being in an RC state with many companies and users running it in
- production, the inclusion of some improvements to the middlewares, we are very pleased to
- announce v2.0.0 of chi.
-
-
-## v2.0.0-rc1 (2016-07-26)
-
-- Huge update! chi v2 is a large refactor targeting Go 1.7+. As of Go 1.7, the popular
- community `"net/context"` package has been included in the standard library as `"context"` and
- utilized by `"net/http"` and `http.Request` to managing deadlines, cancelation signals and other
- request-scoped values. We're very excited about the new context addition and are proud to
- introduce chi v2, a minimal and powerful routing package for building large HTTP services,
- with zero external dependencies. Chi focuses on idiomatic design and encourages the use of
- stdlib HTTP handlers and middlewares.
-- chi v2 deprecates its `chi.Handler` interface and requires `http.Handler` or `http.HandlerFunc`
-- chi v2 stores URL routing parameters and patterns in the standard request context: `r.Context()`
-- chi v2 lower-level routing context is accessible by `chi.RouteContext(r.Context()) *chi.Context`,
- which provides direct access to URL routing parameters, the routing path and the matching
- routing patterns.
-- Users upgrading from chi v1 to v2, need to:
- 1. Update the old chi.Handler signature, `func(ctx context.Context, w http.ResponseWriter, r *http.Request)` to
- the standard http.Handler: `func(w http.ResponseWriter, r *http.Request)`
- 2. Use `chi.URLParam(r *http.Request, paramKey string) string`
- or `URLParamFromCtx(ctx context.Context, paramKey string) string` to access a url parameter value
-
-
-## v1.0.0 (2016-07-01)
-
-- Released chi v1 stable https://github.com/go-chi/chi/tree/v1.0.0 for Go 1.6 and older.
-
-
-## v0.9.0 (2016-03-31)
-
-- Reuse context objects via sync.Pool for zero-allocation routing [#33](https://github.com/go-chi/chi/pull/33)
-- BREAKING NOTE: due to subtle API changes, previously `chi.URLParams(ctx)["id"]` used to access url parameters
- has changed to: `chi.URLParam(ctx, "id")`
diff --git a/vendor/github.com/go-chi/chi/v5/CONTRIBUTING.md b/vendor/github.com/go-chi/chi/v5/CONTRIBUTING.md
deleted file mode 100644
index c0ac2df..0000000
--- a/vendor/github.com/go-chi/chi/v5/CONTRIBUTING.md
+++ /dev/null
@@ -1,31 +0,0 @@
-# Contributing
-
-## Prerequisites
-
-1. [Install Go][go-install].
-2. Download the sources and switch the working directory:
-
- ```bash
- go get -u -d github.com/go-chi/chi
- cd $GOPATH/src/github.com/go-chi/chi
- ```
-
-## Submitting a Pull Request
-
-A typical workflow is:
-
-1. [Fork the repository.][fork] [This tip maybe also helpful.][go-fork-tip]
-2. [Create a topic branch.][branch]
-3. Add tests for your change.
-4. Run `go test`. If your tests pass, return to the step 3.
-5. Implement the change and ensure the steps from the previous step pass.
-6. Run `goimports -w .`, to ensure the new code conforms to Go formatting guideline.
-7. [Add, commit and push your changes.][git-help]
-8. [Submit a pull request.][pull-req]
-
-[go-install]: https://golang.org/doc/install
-[go-fork-tip]: http://blog.campoy.cat/2014/03/github-and-go-forking-pull-requests-and.html
-[fork]: https://help.github.com/articles/fork-a-repo
-[branch]: http://learn.github.com/p/branching.html
-[git-help]: https://guides.github.com
-[pull-req]: https://help.github.com/articles/using-pull-requests
diff --git a/vendor/github.com/go-chi/chi/v5/LICENSE b/vendor/github.com/go-chi/chi/v5/LICENSE
deleted file mode 100644
index d99f02f..0000000
--- a/vendor/github.com/go-chi/chi/v5/LICENSE
+++ /dev/null
@@ -1,20 +0,0 @@
-Copyright (c) 2015-present Peter Kieltyka (https://github.com/pkieltyka), Google Inc.
-
-MIT License
-
-Permission is hereby granted, free of charge, to any person obtaining a copy of
-this software and associated documentation files (the "Software"), to deal in
-the Software without restriction, including without limitation the rights to
-use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
-the Software, and to permit persons to whom the Software is furnished to do so,
-subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in all
-copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
-FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
-COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
-IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/vendor/github.com/go-chi/chi/v5/Makefile b/vendor/github.com/go-chi/chi/v5/Makefile
deleted file mode 100644
index e0f18c7..0000000
--- a/vendor/github.com/go-chi/chi/v5/Makefile
+++ /dev/null
@@ -1,22 +0,0 @@
-.PHONY: all
-all:
- @echo "**********************************************************"
- @echo "** chi build tool **"
- @echo "**********************************************************"
-
-
-.PHONY: test
-test:
- go clean -testcache && $(MAKE) test-router && $(MAKE) test-middleware
-
-.PHONY: test-router
-test-router:
- go test -race -v .
-
-.PHONY: test-middleware
-test-middleware:
- go test -race -v ./middleware
-
-.PHONY: docs
-docs:
- npx docsify-cli serve ./docs
diff --git a/vendor/github.com/go-chi/chi/v5/README.md b/vendor/github.com/go-chi/chi/v5/README.md
deleted file mode 100644
index 21cbb0f..0000000
--- a/vendor/github.com/go-chi/chi/v5/README.md
+++ /dev/null
@@ -1,502 +0,0 @@
-#
-
-
-[![GoDoc Widget]][GoDoc]
-
-`chi` is a lightweight, idiomatic and composable router for building Go HTTP services. It's
-especially good at helping you write large REST API services that are kept maintainable as your
-project grows and changes. `chi` is built on the new `context` package introduced in Go 1.7 to
-handle signaling, cancelation and request-scoped values across a handler chain.
-
-The focus of the project has been to seek out an elegant and comfortable design for writing
-REST API servers, written during the development of the Pressly API service that powers our
-public API service, which in turn powers all of our client-side applications.
-
-The key considerations of chi's design are: project structure, maintainability, standard http
-handlers (stdlib-only), developer productivity, and deconstructing a large system into many small
-parts. The core router `github.com/go-chi/chi` is quite small (less than 1000 LOC), but we've also
-included some useful/optional subpackages: [middleware](/middleware), [render](https://github.com/go-chi/render)
-and [docgen](https://github.com/go-chi/docgen). We hope you enjoy it too!
-
-## Install
-
-`go get -u github.com/go-chi/chi/v5`
-
-
-## Features
-
-* **Lightweight** - cloc'd in ~1000 LOC for the chi router
-* **Fast** - yes, see [benchmarks](#benchmarks)
-* **100% compatible with net/http** - use any http or middleware pkg in the ecosystem that is also compatible with `net/http`
-* **Designed for modular/composable APIs** - middlewares, inline middlewares, route groups and sub-router mounting
-* **Context control** - built on new `context` package, providing value chaining, cancellations and timeouts
-* **Robust** - in production at Pressly, Cloudflare, Heroku, 99Designs, and many others (see [discussion](https://github.com/go-chi/chi/issues/91))
-* **Doc generation** - `docgen` auto-generates routing documentation from your source to JSON or Markdown
-* **Go.mod support** - as of v5, go.mod support (see [CHANGELOG](https://github.com/go-chi/chi/blob/master/CHANGELOG.md))
-* **No external dependencies** - plain ol' Go stdlib + net/http
-
-
-## Examples
-
-See [_examples/](https://github.com/go-chi/chi/blob/master/_examples/) for a variety of examples.
-
-
-**As easy as:**
-
-```go
-package main
-
-import (
- "net/http"
-
- "github.com/go-chi/chi/v5"
- "github.com/go-chi/chi/v5/middleware"
-)
-
-func main() {
- r := chi.NewRouter()
- r.Use(middleware.Logger)
- r.Get("/", func(w http.ResponseWriter, r *http.Request) {
- w.Write([]byte("welcome"))
- })
- http.ListenAndServe(":3000", r)
-}
-```
-
-**REST Preview:**
-
-Here is a little preview of how routing looks like with chi. Also take a look at the generated routing docs
-in JSON ([routes.json](https://github.com/go-chi/chi/blob/master/_examples/rest/routes.json)) and in
-Markdown ([routes.md](https://github.com/go-chi/chi/blob/master/_examples/rest/routes.md)).
-
-I highly recommend reading the source of the [examples](https://github.com/go-chi/chi/blob/master/_examples/) listed
-above, they will show you all the features of chi and serve as a good form of documentation.
-
-```go
-import (
- //...
- "context"
- "github.com/go-chi/chi/v5"
- "github.com/go-chi/chi/v5/middleware"
-)
-
-func main() {
- r := chi.NewRouter()
-
- // A good base middleware stack
- r.Use(middleware.RequestID)
- r.Use(middleware.RealIP)
- r.Use(middleware.Logger)
- r.Use(middleware.Recoverer)
-
- // Set a timeout value on the request context (ctx), that will signal
- // through ctx.Done() that the request has timed out and further
- // processing should be stopped.
- r.Use(middleware.Timeout(60 * time.Second))
-
- r.Get("/", func(w http.ResponseWriter, r *http.Request) {
- w.Write([]byte("hi"))
- })
-
- // RESTy routes for "articles" resource
- r.Route("/articles", func(r chi.Router) {
- r.With(paginate).Get("/", listArticles) // GET /articles
- r.With(paginate).Get("/{month}-{day}-{year}", listArticlesByDate) // GET /articles/01-16-2017
-
- r.Post("/", createArticle) // POST /articles
- r.Get("/search", searchArticles) // GET /articles/search
-
- // Regexp url parameters:
- r.Get("/{articleSlug:[a-z-]+}", getArticleBySlug) // GET /articles/home-is-toronto
-
- // Subrouters:
- r.Route("/{articleID}", func(r chi.Router) {
- r.Use(ArticleCtx)
- r.Get("/", getArticle) // GET /articles/123
- r.Put("/", updateArticle) // PUT /articles/123
- r.Delete("/", deleteArticle) // DELETE /articles/123
- })
- })
-
- // Mount the admin sub-router
- r.Mount("/admin", adminRouter())
-
- http.ListenAndServe(":3333", r)
-}
-
-func ArticleCtx(next http.Handler) http.Handler {
- return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
- articleID := chi.URLParam(r, "articleID")
- article, err := dbGetArticle(articleID)
- if err != nil {
- http.Error(w, http.StatusText(404), 404)
- return
- }
- ctx := context.WithValue(r.Context(), "article", article)
- next.ServeHTTP(w, r.WithContext(ctx))
- })
-}
-
-func getArticle(w http.ResponseWriter, r *http.Request) {
- ctx := r.Context()
- article, ok := ctx.Value("article").(*Article)
- if !ok {
- http.Error(w, http.StatusText(422), 422)
- return
- }
- w.Write([]byte(fmt.Sprintf("title:%s", article.Title)))
-}
-
-// A completely separate router for administrator routes
-func adminRouter() http.Handler {
- r := chi.NewRouter()
- r.Use(AdminOnly)
- r.Get("/", adminIndex)
- r.Get("/accounts", adminListAccounts)
- return r
-}
-
-func AdminOnly(next http.Handler) http.Handler {
- return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
- ctx := r.Context()
- perm, ok := ctx.Value("acl.permission").(YourPermissionType)
- if !ok || !perm.IsAdmin() {
- http.Error(w, http.StatusText(403), 403)
- return
- }
- next.ServeHTTP(w, r)
- })
-}
-```
-
-
-## Router interface
-
-chi's router is based on a kind of [Patricia Radix trie](https://en.wikipedia.org/wiki/Radix_tree).
-The router is fully compatible with `net/http`.
-
-Built on top of the tree is the `Router` interface:
-
-```go
-// Router consisting of the core routing methods used by chi's Mux,
-// using only the standard net/http.
-type Router interface {
- http.Handler
- Routes
-
- // Use appends one or more middlewares onto the Router stack.
- Use(middlewares ...func(http.Handler) http.Handler)
-
- // With adds inline middlewares for an endpoint handler.
- With(middlewares ...func(http.Handler) http.Handler) Router
-
- // Group adds a new inline-Router along the current routing
- // path, with a fresh middleware stack for the inline-Router.
- Group(fn func(r Router)) Router
-
- // Route mounts a sub-Router along a `pattern`` string.
- Route(pattern string, fn func(r Router)) Router
-
- // Mount attaches another http.Handler along ./pattern/*
- Mount(pattern string, h http.Handler)
-
- // Handle and HandleFunc adds routes for `pattern` that matches
- // all HTTP methods.
- Handle(pattern string, h http.Handler)
- HandleFunc(pattern string, h http.HandlerFunc)
-
- // Method and MethodFunc adds routes for `pattern` that matches
- // the `method` HTTP method.
- Method(method, pattern string, h http.Handler)
- MethodFunc(method, pattern string, h http.HandlerFunc)
-
- // HTTP-method routing along `pattern`
- Connect(pattern string, h http.HandlerFunc)
- Delete(pattern string, h http.HandlerFunc)
- Get(pattern string, h http.HandlerFunc)
- Head(pattern string, h http.HandlerFunc)
- Options(pattern string, h http.HandlerFunc)
- Patch(pattern string, h http.HandlerFunc)
- Post(pattern string, h http.HandlerFunc)
- Put(pattern string, h http.HandlerFunc)
- Trace(pattern string, h http.HandlerFunc)
-
- // NotFound defines a handler to respond whenever a route could
- // not be found.
- NotFound(h http.HandlerFunc)
-
- // MethodNotAllowed defines a handler to respond whenever a method is
- // not allowed.
- MethodNotAllowed(h http.HandlerFunc)
-}
-
-// Routes interface adds two methods for router traversal, which is also
-// used by the github.com/go-chi/docgen package to generate documentation for Routers.
-type Routes interface {
- // Routes returns the routing tree in an easily traversable structure.
- Routes() []Route
-
- // Middlewares returns the list of middlewares in use by the router.
- Middlewares() Middlewares
-
- // Match searches the routing tree for a handler that matches
- // the method/path - similar to routing a http request, but without
- // executing the handler thereafter.
- Match(rctx *Context, method, path string) bool
-}
-```
-
-Each routing method accepts a URL `pattern` and chain of `handlers`. The URL pattern
-supports named params (ie. `/users/{userID}`) and wildcards (ie. `/admin/*`). URL parameters
-can be fetched at runtime by calling `chi.URLParam(r, "userID")` for named parameters
-and `chi.URLParam(r, "*")` for a wildcard parameter.
-
-
-### Middleware handlers
-
-chi's middlewares are just stdlib net/http middleware handlers. There is nothing special
-about them, which means the router and all the tooling is designed to be compatible and
-friendly with any middleware in the community. This offers much better extensibility and reuse
-of packages and is at the heart of chi's purpose.
-
-Here is an example of a standard net/http middleware where we assign a context key `"user"`
-the value of `"123"`. This middleware sets a hypothetical user identifier on the request
-context and calls the next handler in the chain.
-
-```go
-// HTTP middleware setting a value on the request context
-func MyMiddleware(next http.Handler) http.Handler {
- return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
- // create new context from `r` request context, and assign key `"user"`
- // to value of `"123"`
- ctx := context.WithValue(r.Context(), "user", "123")
-
- // call the next handler in the chain, passing the response writer and
- // the updated request object with the new context value.
- //
- // note: context.Context values are nested, so any previously set
- // values will be accessible as well, and the new `"user"` key
- // will be accessible from this point forward.
- next.ServeHTTP(w, r.WithContext(ctx))
- })
-}
-```
-
-
-### Request handlers
-
-chi uses standard net/http request handlers. This little snippet is an example of a http.Handler
-func that reads a user identifier from the request context - hypothetically, identifying
-the user sending an authenticated request, validated+set by a previous middleware handler.
-
-```go
-// HTTP handler accessing data from the request context.
-func MyRequestHandler(w http.ResponseWriter, r *http.Request) {
- // here we read from the request context and fetch out `"user"` key set in
- // the MyMiddleware example above.
- user := r.Context().Value("user").(string)
-
- // respond to the client
- w.Write([]byte(fmt.Sprintf("hi %s", user)))
-}
-```
-
-
-### URL parameters
-
-chi's router parses and stores URL parameters right onto the request context. Here is
-an example of how to access URL params in your net/http handlers. And of course, middlewares
-are able to access the same information.
-
-```go
-// HTTP handler accessing the url routing parameters.
-func MyRequestHandler(w http.ResponseWriter, r *http.Request) {
- // fetch the url parameter `"userID"` from the request of a matching
- // routing pattern. An example routing pattern could be: /users/{userID}
- userID := chi.URLParam(r, "userID")
-
- // fetch `"key"` from the request context
- ctx := r.Context()
- key := ctx.Value("key").(string)
-
- // respond to the client
- w.Write([]byte(fmt.Sprintf("hi %v, %v", userID, key)))
-}
-```
-
-
-## Middlewares
-
-chi comes equipped with an optional `middleware` package, providing a suite of standard
-`net/http` middlewares. Please note, any middleware in the ecosystem that is also compatible
-with `net/http` can be used with chi's mux.
-
-### Core middlewares
-
-----------------------------------------------------------------------------------------------------
-| chi/middleware Handler | description |
-| :--------------------- | :---------------------------------------------------------------------- |
-| [AllowContentEncoding] | Enforces a whitelist of request Content-Encoding headers |
-| [AllowContentType] | Explicit whitelist of accepted request Content-Types |
-| [BasicAuth] | Basic HTTP authentication |
-| [Compress] | Gzip compression for clients that accept compressed responses |
-| [ContentCharset] | Ensure charset for Content-Type request headers |
-| [CleanPath] | Clean double slashes from request path |
-| [GetHead] | Automatically route undefined HEAD requests to GET handlers |
-| [Heartbeat] | Monitoring endpoint to check the servers pulse |
-| [Logger] | Logs the start and end of each request with the elapsed processing time |
-| [NoCache] | Sets response headers to prevent clients from caching |
-| [Profiler] | Easily attach net/http/pprof to your routers |
-| [RealIP] | Sets a http.Request's RemoteAddr to either X-Real-IP or X-Forwarded-For |
-| [Recoverer] | Gracefully absorb panics and prints the stack trace |
-| [RequestID] | Injects a request ID into the context of each request |
-| [RedirectSlashes] | Redirect slashes on routing paths |
-| [RouteHeaders] | Route handling for request headers |
-| [SetHeader] | Short-hand middleware to set a response header key/value |
-| [StripSlashes] | Strip slashes on routing paths |
-| [Sunset] | Sunset set Deprecation/Sunset header to response |
-| [Throttle] | Puts a ceiling on the number of concurrent requests |
-| [Timeout] | Signals to the request context when the timeout deadline is reached |
-| [URLFormat] | Parse extension from url and put it on request context |
-| [WithValue] | Short-hand middleware to set a key/value on the request context |
-----------------------------------------------------------------------------------------------------
-
-[AllowContentEncoding]: https://pkg.go.dev/github.com/go-chi/chi/middleware#AllowContentEncoding
-[AllowContentType]: https://pkg.go.dev/github.com/go-chi/chi/middleware#AllowContentType
-[BasicAuth]: https://pkg.go.dev/github.com/go-chi/chi/middleware#BasicAuth
-[Compress]: https://pkg.go.dev/github.com/go-chi/chi/middleware#Compress
-[ContentCharset]: https://pkg.go.dev/github.com/go-chi/chi/middleware#ContentCharset
-[CleanPath]: https://pkg.go.dev/github.com/go-chi/chi/middleware#CleanPath
-[GetHead]: https://pkg.go.dev/github.com/go-chi/chi/middleware#GetHead
-[GetReqID]: https://pkg.go.dev/github.com/go-chi/chi/middleware#GetReqID
-[Heartbeat]: https://pkg.go.dev/github.com/go-chi/chi/middleware#Heartbeat
-[Logger]: https://pkg.go.dev/github.com/go-chi/chi/middleware#Logger
-[NoCache]: https://pkg.go.dev/github.com/go-chi/chi/middleware#NoCache
-[Profiler]: https://pkg.go.dev/github.com/go-chi/chi/middleware#Profiler
-[RealIP]: https://pkg.go.dev/github.com/go-chi/chi/middleware#RealIP
-[Recoverer]: https://pkg.go.dev/github.com/go-chi/chi/middleware#Recoverer
-[RedirectSlashes]: https://pkg.go.dev/github.com/go-chi/chi/middleware#RedirectSlashes
-[RequestLogger]: https://pkg.go.dev/github.com/go-chi/chi/middleware#RequestLogger
-[RequestID]: https://pkg.go.dev/github.com/go-chi/chi/middleware#RequestID
-[RouteHeaders]: https://pkg.go.dev/github.com/go-chi/chi/middleware#RouteHeaders
-[SetHeader]: https://pkg.go.dev/github.com/go-chi/chi/middleware#SetHeader
-[StripSlashes]: https://pkg.go.dev/github.com/go-chi/chi/middleware#StripSlashes
-[Sunset]: https://pkg.go.dev/github.com/go-chi/chi/v5/middleware#Sunset
-[Throttle]: https://pkg.go.dev/github.com/go-chi/chi/middleware#Throttle
-[ThrottleBacklog]: https://pkg.go.dev/github.com/go-chi/chi/middleware#ThrottleBacklog
-[ThrottleWithOpts]: https://pkg.go.dev/github.com/go-chi/chi/middleware#ThrottleWithOpts
-[Timeout]: https://pkg.go.dev/github.com/go-chi/chi/middleware#Timeout
-[URLFormat]: https://pkg.go.dev/github.com/go-chi/chi/middleware#URLFormat
-[WithLogEntry]: https://pkg.go.dev/github.com/go-chi/chi/middleware#WithLogEntry
-[WithValue]: https://pkg.go.dev/github.com/go-chi/chi/middleware#WithValue
-[Compressor]: https://pkg.go.dev/github.com/go-chi/chi/middleware#Compressor
-[DefaultLogFormatter]: https://pkg.go.dev/github.com/go-chi/chi/middleware#DefaultLogFormatter
-[EncoderFunc]: https://pkg.go.dev/github.com/go-chi/chi/middleware#EncoderFunc
-[HeaderRoute]: https://pkg.go.dev/github.com/go-chi/chi/middleware#HeaderRoute
-[HeaderRouter]: https://pkg.go.dev/github.com/go-chi/chi/middleware#HeaderRouter
-[LogEntry]: https://pkg.go.dev/github.com/go-chi/chi/middleware#LogEntry
-[LogFormatter]: https://pkg.go.dev/github.com/go-chi/chi/middleware#LogFormatter
-[LoggerInterface]: https://pkg.go.dev/github.com/go-chi/chi/middleware#LoggerInterface
-[ThrottleOpts]: https://pkg.go.dev/github.com/go-chi/chi/middleware#ThrottleOpts
-[WrapResponseWriter]: https://pkg.go.dev/github.com/go-chi/chi/middleware#WrapResponseWriter
-
-### Extra middlewares & packages
-
-Please see https://github.com/go-chi for additional packages.
-
---------------------------------------------------------------------------------------------------------------------
-| package | description |
-|:---------------------------------------------------|:-------------------------------------------------------------
-| [cors](https://github.com/go-chi/cors) | Cross-origin resource sharing (CORS) |
-| [docgen](https://github.com/go-chi/docgen) | Print chi.Router routes at runtime |
-| [jwtauth](https://github.com/go-chi/jwtauth) | JWT authentication |
-| [hostrouter](https://github.com/go-chi/hostrouter) | Domain/host based request routing |
-| [httplog](https://github.com/go-chi/httplog) | Small but powerful structured HTTP request logging |
-| [httprate](https://github.com/go-chi/httprate) | HTTP request rate limiter |
-| [httptracer](https://github.com/go-chi/httptracer) | HTTP request performance tracing library |
-| [httpvcr](https://github.com/go-chi/httpvcr) | Write deterministic tests for external sources |
-| [stampede](https://github.com/go-chi/stampede) | HTTP request coalescer |
---------------------------------------------------------------------------------------------------------------------
-
-
-## context?
-
-`context` is a tiny pkg that provides simple interface to signal context across call stacks
-and goroutines. It was originally written by [Sameer Ajmani](https://github.com/Sajmani)
-and is available in stdlib since go1.7.
-
-Learn more at https://blog.golang.org/context
-
-and..
-* Docs: https://golang.org/pkg/context
-* Source: https://github.com/golang/go/tree/master/src/context
-
-
-## Benchmarks
-
-The benchmark suite: https://github.com/pkieltyka/go-http-routing-benchmark
-
-Results as of Nov 29, 2020 with Go 1.15.5 on Linux AMD 3950x
-
-```shell
-BenchmarkChi_Param 3075895 384 ns/op 400 B/op 2 allocs/op
-BenchmarkChi_Param5 2116603 566 ns/op 400 B/op 2 allocs/op
-BenchmarkChi_Param20 964117 1227 ns/op 400 B/op 2 allocs/op
-BenchmarkChi_ParamWrite 2863413 420 ns/op 400 B/op 2 allocs/op
-BenchmarkChi_GithubStatic 3045488 395 ns/op 400 B/op 2 allocs/op
-BenchmarkChi_GithubParam 2204115 540 ns/op 400 B/op 2 allocs/op
-BenchmarkChi_GithubAll 10000 113811 ns/op 81203 B/op 406 allocs/op
-BenchmarkChi_GPlusStatic 3337485 359 ns/op 400 B/op 2 allocs/op
-BenchmarkChi_GPlusParam 2825853 423 ns/op 400 B/op 2 allocs/op
-BenchmarkChi_GPlus2Params 2471697 483 ns/op 400 B/op 2 allocs/op
-BenchmarkChi_GPlusAll 194220 5950 ns/op 5200 B/op 26 allocs/op
-BenchmarkChi_ParseStatic 3365324 356 ns/op 400 B/op 2 allocs/op
-BenchmarkChi_ParseParam 2976614 404 ns/op 400 B/op 2 allocs/op
-BenchmarkChi_Parse2Params 2638084 439 ns/op 400 B/op 2 allocs/op
-BenchmarkChi_ParseAll 109567 11295 ns/op 10400 B/op 52 allocs/op
-BenchmarkChi_StaticAll 16846 71308 ns/op 62802 B/op 314 allocs/op
-```
-
-Comparison with other routers: https://gist.github.com/pkieltyka/123032f12052520aaccab752bd3e78cc
-
-NOTE: the allocs in the benchmark above are from the calls to http.Request's
-`WithContext(context.Context)` method that clones the http.Request, sets the `Context()`
-on the duplicated (alloc'd) request and returns it the new request object. This is just
-how setting context on a request in Go works.
-
-
-## Credits
-
-* Carl Jackson for https://github.com/zenazn/goji
- * Parts of chi's thinking comes from goji, and chi's middleware package
- sources from goji.
-* Armon Dadgar for https://github.com/armon/go-radix
-* Contributions: [@VojtechVitek](https://github.com/VojtechVitek)
-
-We'll be more than happy to see [your contributions](./CONTRIBUTING.md)!
-
-
-## Beyond REST
-
-chi is just a http router that lets you decompose request handling into many smaller layers.
-Many companies use chi to write REST services for their public APIs. But, REST is just a convention
-for managing state via HTTP, and there's a lot of other pieces required to write a complete client-server
-system or network of microservices.
-
-Looking beyond REST, I also recommend some newer works in the field:
-* [webrpc](https://github.com/webrpc/webrpc) - Web-focused RPC client+server framework with code-gen
-* [gRPC](https://github.com/grpc/grpc-go) - Google's RPC framework via protobufs
-* [graphql](https://github.com/99designs/gqlgen) - Declarative query language
-* [NATS](https://nats.io) - lightweight pub-sub
-
-
-## License
-
-Copyright (c) 2015-present [Peter Kieltyka](https://github.com/pkieltyka)
-
-Licensed under [MIT License](./LICENSE)
-
-[GoDoc]: https://pkg.go.dev/github.com/go-chi/chi/v5
-[GoDoc Widget]: https://godoc.org/github.com/go-chi/chi?status.svg
-[Travis]: https://travis-ci.org/go-chi/chi
-[Travis Widget]: https://travis-ci.org/go-chi/chi.svg?branch=master
diff --git a/vendor/github.com/go-chi/chi/v5/SECURITY.md b/vendor/github.com/go-chi/chi/v5/SECURITY.md
deleted file mode 100644
index 7e937f8..0000000
--- a/vendor/github.com/go-chi/chi/v5/SECURITY.md
+++ /dev/null
@@ -1,5 +0,0 @@
-# Reporting Security Issues
-
-We appreciate your efforts to responsibly disclose your findings, and will make every effort to acknowledge your contributions.
-
-To report a security issue, please use the GitHub Security Advisory ["Report a Vulnerability"](https://github.com/go-chi/chi/security/advisories/new) tab.
diff --git a/vendor/github.com/go-chi/chi/v5/chain.go b/vendor/github.com/go-chi/chi/v5/chain.go
deleted file mode 100644
index a227841..0000000
--- a/vendor/github.com/go-chi/chi/v5/chain.go
+++ /dev/null
@@ -1,49 +0,0 @@
-package chi
-
-import "net/http"
-
-// Chain returns a Middlewares type from a slice of middleware handlers.
-func Chain(middlewares ...func(http.Handler) http.Handler) Middlewares {
- return Middlewares(middlewares)
-}
-
-// Handler builds and returns a http.Handler from the chain of middlewares,
-// with `h http.Handler` as the final handler.
-func (mws Middlewares) Handler(h http.Handler) http.Handler {
- return &ChainHandler{h, chain(mws, h), mws}
-}
-
-// HandlerFunc builds and returns a http.Handler from the chain of middlewares,
-// with `h http.Handler` as the final handler.
-func (mws Middlewares) HandlerFunc(h http.HandlerFunc) http.Handler {
- return &ChainHandler{h, chain(mws, h), mws}
-}
-
-// ChainHandler is a http.Handler with support for handler composition and
-// execution.
-type ChainHandler struct {
- Endpoint http.Handler
- chain http.Handler
- Middlewares Middlewares
-}
-
-func (c *ChainHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
- c.chain.ServeHTTP(w, r)
-}
-
-// chain builds a http.Handler composed of an inline middleware stack and endpoint
-// handler in the order they are passed.
-func chain(middlewares []func(http.Handler) http.Handler, endpoint http.Handler) http.Handler {
- // Return ahead of time if there aren't any middlewares for the chain
- if len(middlewares) == 0 {
- return endpoint
- }
-
- // Wrap the end handler with the middleware chain
- h := middlewares[len(middlewares)-1](endpoint)
- for i := len(middlewares) - 2; i >= 0; i-- {
- h = middlewares[i](h)
- }
-
- return h
-}
diff --git a/vendor/github.com/go-chi/chi/v5/chi.go b/vendor/github.com/go-chi/chi/v5/chi.go
deleted file mode 100644
index a1691bb..0000000
--- a/vendor/github.com/go-chi/chi/v5/chi.go
+++ /dev/null
@@ -1,134 +0,0 @@
-// Package chi is a small, idiomatic and composable router for building HTTP services.
-//
-// chi requires Go 1.14 or newer.
-//
-// Example:
-//
-// package main
-//
-// import (
-// "net/http"
-//
-// "github.com/go-chi/chi/v5"
-// "github.com/go-chi/chi/v5/middleware"
-// )
-//
-// func main() {
-// r := chi.NewRouter()
-// r.Use(middleware.Logger)
-// r.Use(middleware.Recoverer)
-//
-// r.Get("/", func(w http.ResponseWriter, r *http.Request) {
-// w.Write([]byte("root."))
-// })
-//
-// http.ListenAndServe(":3333", r)
-// }
-//
-// See github.com/go-chi/chi/_examples/ for more in-depth examples.
-//
-// URL patterns allow for easy matching of path components in HTTP
-// requests. The matching components can then be accessed using
-// chi.URLParam(). All patterns must begin with a slash.
-//
-// A simple named placeholder {name} matches any sequence of characters
-// up to the next / or the end of the URL. Trailing slashes on paths must
-// be handled explicitly.
-//
-// A placeholder with a name followed by a colon allows a regular
-// expression match, for example {number:\\d+}. The regular expression
-// syntax is Go's normal regexp RE2 syntax, except that regular expressions
-// including { or } are not supported, and / will never be
-// matched. An anonymous regexp pattern is allowed, using an empty string
-// before the colon in the placeholder, such as {:\\d+}
-//
-// The special placeholder of asterisk matches the rest of the requested
-// URL. Any trailing characters in the pattern are ignored. This is the only
-// placeholder which will match / characters.
-//
-// Examples:
-//
-// "/user/{name}" matches "/user/jsmith" but not "/user/jsmith/info" or "/user/jsmith/"
-// "/user/{name}/info" matches "/user/jsmith/info"
-// "/page/*" matches "/page/intro/latest"
-// "/page/{other}/index" also matches "/page/intro/latest"
-// "/date/{yyyy:\\d\\d\\d\\d}/{mm:\\d\\d}/{dd:\\d\\d}" matches "/date/2017/04/01"
-package chi
-
-import "net/http"
-
-// NewRouter returns a new Mux object that implements the Router interface.
-func NewRouter() *Mux {
- return NewMux()
-}
-
-// Router consisting of the core routing methods used by chi's Mux,
-// using only the standard net/http.
-type Router interface {
- http.Handler
- Routes
-
- // Use appends one or more middlewares onto the Router stack.
- Use(middlewares ...func(http.Handler) http.Handler)
-
- // With adds inline middlewares for an endpoint handler.
- With(middlewares ...func(http.Handler) http.Handler) Router
-
- // Group adds a new inline-Router along the current routing
- // path, with a fresh middleware stack for the inline-Router.
- Group(fn func(r Router)) Router
-
- // Route mounts a sub-Router along a `pattern`` string.
- Route(pattern string, fn func(r Router)) Router
-
- // Mount attaches another http.Handler along ./pattern/*
- Mount(pattern string, h http.Handler)
-
- // Handle and HandleFunc adds routes for `pattern` that matches
- // all HTTP methods.
- Handle(pattern string, h http.Handler)
- HandleFunc(pattern string, h http.HandlerFunc)
-
- // Method and MethodFunc adds routes for `pattern` that matches
- // the `method` HTTP method.
- Method(method, pattern string, h http.Handler)
- MethodFunc(method, pattern string, h http.HandlerFunc)
-
- // HTTP-method routing along `pattern`
- Connect(pattern string, h http.HandlerFunc)
- Delete(pattern string, h http.HandlerFunc)
- Get(pattern string, h http.HandlerFunc)
- Head(pattern string, h http.HandlerFunc)
- Options(pattern string, h http.HandlerFunc)
- Patch(pattern string, h http.HandlerFunc)
- Post(pattern string, h http.HandlerFunc)
- Put(pattern string, h http.HandlerFunc)
- Trace(pattern string, h http.HandlerFunc)
-
- // NotFound defines a handler to respond whenever a route could
- // not be found.
- NotFound(h http.HandlerFunc)
-
- // MethodNotAllowed defines a handler to respond whenever a method is
- // not allowed.
- MethodNotAllowed(h http.HandlerFunc)
-}
-
-// Routes interface adds two methods for router traversal, which is also
-// used by the `docgen` subpackage to generation documentation for Routers.
-type Routes interface {
- // Routes returns the routing tree in an easily traversable structure.
- Routes() []Route
-
- // Middlewares returns the list of middlewares in use by the router.
- Middlewares() Middlewares
-
- // Match searches the routing tree for a handler that matches
- // the method/path - similar to routing a http request, but without
- // executing the handler thereafter.
- Match(rctx *Context, method, path string) bool
-}
-
-// Middlewares type is a slice of standard middleware handlers with methods
-// to compose middleware chains and http.Handler's.
-type Middlewares []func(http.Handler) http.Handler
diff --git a/vendor/github.com/go-chi/chi/v5/context.go b/vendor/github.com/go-chi/chi/v5/context.go
deleted file mode 100644
index 82e5f28..0000000
--- a/vendor/github.com/go-chi/chi/v5/context.go
+++ /dev/null
@@ -1,163 +0,0 @@
-package chi
-
-import (
- "context"
- "net/http"
- "strings"
-)
-
-// URLParam returns the url parameter from a http.Request object.
-func URLParam(r *http.Request, key string) string {
- if rctx := RouteContext(r.Context()); rctx != nil {
- return rctx.URLParam(key)
- }
- return ""
-}
-
-// URLParamFromCtx returns the url parameter from a http.Request Context.
-func URLParamFromCtx(ctx context.Context, key string) string {
- if rctx := RouteContext(ctx); rctx != nil {
- return rctx.URLParam(key)
- }
- return ""
-}
-
-// RouteContext returns chi's routing Context object from a
-// http.Request Context.
-func RouteContext(ctx context.Context) *Context {
- val, _ := ctx.Value(RouteCtxKey).(*Context)
- return val
-}
-
-// NewRouteContext returns a new routing Context object.
-func NewRouteContext() *Context {
- return &Context{}
-}
-
-var (
- // RouteCtxKey is the context.Context key to store the request context.
- RouteCtxKey = &contextKey{"RouteContext"}
-)
-
-// Context is the default routing context set on the root node of a
-// request context to track route patterns, URL parameters and
-// an optional routing path.
-type Context struct {
- Routes Routes
-
- // parentCtx is the parent of this one, for using Context as a
- // context.Context directly. This is an optimization that saves
- // 1 allocation.
- parentCtx context.Context
-
- // Routing path/method override used during the route search.
- // See Mux#routeHTTP method.
- RoutePath string
- RouteMethod string
-
- // URLParams are the stack of routeParams captured during the
- // routing lifecycle across a stack of sub-routers.
- URLParams RouteParams
-
- // Route parameters matched for the current sub-router. It is
- // intentionally unexported so it can't be tampered.
- routeParams RouteParams
-
- // The endpoint routing pattern that matched the request URI path
- // or `RoutePath` of the current sub-router. This value will update
- // during the lifecycle of a request passing through a stack of
- // sub-routers.
- routePattern string
-
- // Routing pattern stack throughout the lifecycle of the request,
- // across all connected routers. It is a record of all matching
- // patterns across a stack of sub-routers.
- RoutePatterns []string
-
- // methodNotAllowed hint
- methodNotAllowed bool
- methodsAllowed []methodTyp // allowed methods in case of a 405
-}
-
-// Reset a routing context to its initial state.
-func (x *Context) Reset() {
- x.Routes = nil
- x.RoutePath = ""
- x.RouteMethod = ""
- x.RoutePatterns = x.RoutePatterns[:0]
- x.URLParams.Keys = x.URLParams.Keys[:0]
- x.URLParams.Values = x.URLParams.Values[:0]
-
- x.routePattern = ""
- x.routeParams.Keys = x.routeParams.Keys[:0]
- x.routeParams.Values = x.routeParams.Values[:0]
- x.methodNotAllowed = false
- x.methodsAllowed = x.methodsAllowed[:0]
- x.parentCtx = nil
-}
-
-// URLParam returns the corresponding URL parameter value from the request
-// routing context.
-func (x *Context) URLParam(key string) string {
- for k := len(x.URLParams.Keys) - 1; k >= 0; k-- {
- if x.URLParams.Keys[k] == key {
- return x.URLParams.Values[k]
- }
- }
- return ""
-}
-
-// RoutePattern builds the routing pattern string for the particular
-// request, at the particular point during routing. This means, the value
-// will change throughout the execution of a request in a router. That is
-// why its advised to only use this value after calling the next handler.
-//
-// For example,
-//
-// func Instrument(next http.Handler) http.Handler {
-// return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
-// next.ServeHTTP(w, r)
-// routePattern := chi.RouteContext(r.Context()).RoutePattern()
-// measure(w, r, routePattern)
-// })
-// }
-func (x *Context) RoutePattern() string {
- routePattern := strings.Join(x.RoutePatterns, "")
- routePattern = replaceWildcards(routePattern)
- if routePattern != "/" {
- routePattern = strings.TrimSuffix(routePattern, "//")
- routePattern = strings.TrimSuffix(routePattern, "/")
- }
- return routePattern
-}
-
-// replaceWildcards takes a route pattern and recursively replaces all
-// occurrences of "/*/" to "/".
-func replaceWildcards(p string) string {
- if strings.Contains(p, "/*/") {
- return replaceWildcards(strings.Replace(p, "/*/", "/", -1))
- }
- return p
-}
-
-// RouteParams is a structure to track URL routing parameters efficiently.
-type RouteParams struct {
- Keys, Values []string
-}
-
-// Add will append a URL parameter to the end of the route param
-func (s *RouteParams) Add(key, value string) {
- s.Keys = append(s.Keys, key)
- s.Values = append(s.Values, value)
-}
-
-// contextKey is a value for use with context.WithValue. It's used as
-// a pointer so it fits in an interface{} without allocation. This technique
-// for defining context keys was copied from Go 1.7's new use of context in net/http.
-type contextKey struct {
- name string
-}
-
-func (k *contextKey) String() string {
- return "chi context value " + k.name
-}
diff --git a/vendor/github.com/go-chi/chi/v5/middleware/basic_auth.go b/vendor/github.com/go-chi/chi/v5/middleware/basic_auth.go
deleted file mode 100644
index a546c9e..0000000
--- a/vendor/github.com/go-chi/chi/v5/middleware/basic_auth.go
+++ /dev/null
@@ -1,33 +0,0 @@
-package middleware
-
-import (
- "crypto/subtle"
- "fmt"
- "net/http"
-)
-
-// BasicAuth implements a simple middleware handler for adding basic http auth to a route.
-func BasicAuth(realm string, creds map[string]string) func(next http.Handler) http.Handler {
- return func(next http.Handler) http.Handler {
- return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
- user, pass, ok := r.BasicAuth()
- if !ok {
- basicAuthFailed(w, realm)
- return
- }
-
- credPass, credUserOk := creds[user]
- if !credUserOk || subtle.ConstantTimeCompare([]byte(pass), []byte(credPass)) != 1 {
- basicAuthFailed(w, realm)
- return
- }
-
- next.ServeHTTP(w, r)
- })
- }
-}
-
-func basicAuthFailed(w http.ResponseWriter, realm string) {
- w.Header().Add("WWW-Authenticate", fmt.Sprintf(`Basic realm="%s"`, realm))
- w.WriteHeader(http.StatusUnauthorized)
-}
diff --git a/vendor/github.com/go-chi/chi/v5/middleware/clean_path.go b/vendor/github.com/go-chi/chi/v5/middleware/clean_path.go
deleted file mode 100644
index adeba42..0000000
--- a/vendor/github.com/go-chi/chi/v5/middleware/clean_path.go
+++ /dev/null
@@ -1,28 +0,0 @@
-package middleware
-
-import (
- "net/http"
- "path"
-
- "github.com/go-chi/chi/v5"
-)
-
-// CleanPath middleware will clean out double slash mistakes from a user's request path.
-// For example, if a user requests /users//1 or //users////1 will both be treated as: /users/1
-func CleanPath(next http.Handler) http.Handler {
- return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
- rctx := chi.RouteContext(r.Context())
-
- routePath := rctx.RoutePath
- if routePath == "" {
- if r.URL.RawPath != "" {
- routePath = r.URL.RawPath
- } else {
- routePath = r.URL.Path
- }
- rctx.RoutePath = path.Clean(routePath)
- }
-
- next.ServeHTTP(w, r)
- })
-}
diff --git a/vendor/github.com/go-chi/chi/v5/middleware/compress.go b/vendor/github.com/go-chi/chi/v5/middleware/compress.go
deleted file mode 100644
index 28240c4..0000000
--- a/vendor/github.com/go-chi/chi/v5/middleware/compress.go
+++ /dev/null
@@ -1,398 +0,0 @@
-package middleware
-
-import (
- "bufio"
- "compress/flate"
- "compress/gzip"
- "errors"
- "fmt"
- "io"
- "io/ioutil"
- "net"
- "net/http"
- "strings"
- "sync"
-)
-
-var defaultCompressibleContentTypes = []string{
- "text/html",
- "text/css",
- "text/plain",
- "text/javascript",
- "application/javascript",
- "application/x-javascript",
- "application/json",
- "application/atom+xml",
- "application/rss+xml",
- "image/svg+xml",
-}
-
-// Compress is a middleware that compresses response
-// body of a given content types to a data format based
-// on Accept-Encoding request header. It uses a given
-// compression level.
-//
-// NOTE: make sure to set the Content-Type header on your response
-// otherwise this middleware will not compress the response body. For ex, in
-// your handler you should set w.Header().Set("Content-Type", http.DetectContentType(yourBody))
-// or set it manually.
-//
-// Passing a compression level of 5 is sensible value
-func Compress(level int, types ...string) func(next http.Handler) http.Handler {
- compressor := NewCompressor(level, types...)
- return compressor.Handler
-}
-
-// Compressor represents a set of encoding configurations.
-type Compressor struct {
- // The mapping of encoder names to encoder functions.
- encoders map[string]EncoderFunc
- // The mapping of pooled encoders to pools.
- pooledEncoders map[string]*sync.Pool
- // The set of content types allowed to be compressed.
- allowedTypes map[string]struct{}
- allowedWildcards map[string]struct{}
- // The list of encoders in order of decreasing precedence.
- encodingPrecedence []string
- level int // The compression level.
-}
-
-// NewCompressor creates a new Compressor that will handle encoding responses.
-//
-// The level should be one of the ones defined in the flate package.
-// The types are the content types that are allowed to be compressed.
-func NewCompressor(level int, types ...string) *Compressor {
- // If types are provided, set those as the allowed types. If none are
- // provided, use the default list.
- allowedTypes := make(map[string]struct{})
- allowedWildcards := make(map[string]struct{})
- if len(types) > 0 {
- for _, t := range types {
- if strings.Contains(strings.TrimSuffix(t, "/*"), "*") {
- panic(fmt.Sprintf("middleware/compress: Unsupported content-type wildcard pattern '%s'. Only '/*' supported", t))
- }
- if strings.HasSuffix(t, "/*") {
- allowedWildcards[strings.TrimSuffix(t, "/*")] = struct{}{}
- } else {
- allowedTypes[t] = struct{}{}
- }
- }
- } else {
- for _, t := range defaultCompressibleContentTypes {
- allowedTypes[t] = struct{}{}
- }
- }
-
- c := &Compressor{
- level: level,
- encoders: make(map[string]EncoderFunc),
- pooledEncoders: make(map[string]*sync.Pool),
- allowedTypes: allowedTypes,
- allowedWildcards: allowedWildcards,
- }
-
- // Set the default encoders. The precedence order uses the reverse
- // ordering that the encoders were added. This means adding new encoders
- // will move them to the front of the order.
- //
- // TODO:
- // lzma: Opera.
- // sdch: Chrome, Android. Gzip output + dictionary header.
- // br: Brotli, see https://github.com/go-chi/chi/pull/326
-
- // HTTP 1.1 "deflate" (RFC 2616) stands for DEFLATE data (RFC 1951)
- // wrapped with zlib (RFC 1950). The zlib wrapper uses Adler-32
- // checksum compared to CRC-32 used in "gzip" and thus is faster.
- //
- // But.. some old browsers (MSIE, Safari 5.1) incorrectly expect
- // raw DEFLATE data only, without the mentioned zlib wrapper.
- // Because of this major confusion, most modern browsers try it
- // both ways, first looking for zlib headers.
- // Quote by Mark Adler: http://stackoverflow.com/a/9186091/385548
- //
- // The list of browsers having problems is quite big, see:
- // http://zoompf.com/blog/2012/02/lose-the-wait-http-compression
- // https://web.archive.org/web/20120321182910/http://www.vervestudios.co/projects/compression-tests/results
- //
- // That's why we prefer gzip over deflate. It's just more reliable
- // and not significantly slower than deflate.
- c.SetEncoder("deflate", encoderDeflate)
-
- // TODO: Exception for old MSIE browsers that can't handle non-HTML?
- // https://zoompf.com/blog/2012/02/lose-the-wait-http-compression
- c.SetEncoder("gzip", encoderGzip)
-
- // NOTE: Not implemented, intentionally:
- // case "compress": // LZW. Deprecated.
- // case "bzip2": // Too slow on-the-fly.
- // case "zopfli": // Too slow on-the-fly.
- // case "xz": // Too slow on-the-fly.
- return c
-}
-
-// SetEncoder can be used to set the implementation of a compression algorithm.
-//
-// The encoding should be a standardised identifier. See:
-// https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Accept-Encoding
-//
-// For example, add the Brotli algorithm:
-//
-// import brotli_enc "gopkg.in/kothar/brotli-go.v0/enc"
-//
-// compressor := middleware.NewCompressor(5, "text/html")
-// compressor.SetEncoder("br", func(w io.Writer, level int) io.Writer {
-// params := brotli_enc.NewBrotliParams()
-// params.SetQuality(level)
-// return brotli_enc.NewBrotliWriter(params, w)
-// })
-func (c *Compressor) SetEncoder(encoding string, fn EncoderFunc) {
- encoding = strings.ToLower(encoding)
- if encoding == "" {
- panic("the encoding can not be empty")
- }
- if fn == nil {
- panic("attempted to set a nil encoder function")
- }
-
- // If we are adding a new encoder that is already registered, we have to
- // clear that one out first.
- delete(c.pooledEncoders, encoding)
- delete(c.encoders, encoding)
-
- // If the encoder supports Resetting (IoReseterWriter), then it can be pooled.
- encoder := fn(ioutil.Discard, c.level)
- if encoder != nil {
- if _, ok := encoder.(ioResetterWriter); ok {
- pool := &sync.Pool{
- New: func() interface{} {
- return fn(ioutil.Discard, c.level)
- },
- }
- c.pooledEncoders[encoding] = pool
- }
- }
- // If the encoder is not in the pooledEncoders, add it to the normal encoders.
- if _, ok := c.pooledEncoders[encoding]; !ok {
- c.encoders[encoding] = fn
- }
-
- for i, v := range c.encodingPrecedence {
- if v == encoding {
- c.encodingPrecedence = append(c.encodingPrecedence[:i], c.encodingPrecedence[i+1:]...)
- }
- }
-
- c.encodingPrecedence = append([]string{encoding}, c.encodingPrecedence...)
-}
-
-// Handler returns a new middleware that will compress the response based on the
-// current Compressor.
-func (c *Compressor) Handler(next http.Handler) http.Handler {
- return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
- encoder, encoding, cleanup := c.selectEncoder(r.Header, w)
-
- cw := &compressResponseWriter{
- ResponseWriter: w,
- w: w,
- contentTypes: c.allowedTypes,
- contentWildcards: c.allowedWildcards,
- encoding: encoding,
- compressible: false, // determined in post-handler
- }
- if encoder != nil {
- cw.w = encoder
- }
- // Re-add the encoder to the pool if applicable.
- defer cleanup()
- defer cw.Close()
-
- next.ServeHTTP(cw, r)
- })
-}
-
-// selectEncoder returns the encoder, the name of the encoder, and a closer function.
-func (c *Compressor) selectEncoder(h http.Header, w io.Writer) (io.Writer, string, func()) {
- header := h.Get("Accept-Encoding")
-
- // Parse the names of all accepted algorithms from the header.
- accepted := strings.Split(strings.ToLower(header), ",")
-
- // Find supported encoder by accepted list by precedence
- for _, name := range c.encodingPrecedence {
- if matchAcceptEncoding(accepted, name) {
- if pool, ok := c.pooledEncoders[name]; ok {
- encoder := pool.Get().(ioResetterWriter)
- cleanup := func() {
- pool.Put(encoder)
- }
- encoder.Reset(w)
- return encoder, name, cleanup
-
- }
- if fn, ok := c.encoders[name]; ok {
- return fn(w, c.level), name, func() {}
- }
- }
-
- }
-
- // No encoder found to match the accepted encoding
- return nil, "", func() {}
-}
-
-func matchAcceptEncoding(accepted []string, encoding string) bool {
- for _, v := range accepted {
- if strings.Contains(v, encoding) {
- return true
- }
- }
- return false
-}
-
-// An EncoderFunc is a function that wraps the provided io.Writer with a
-// streaming compression algorithm and returns it.
-//
-// In case of failure, the function should return nil.
-type EncoderFunc func(w io.Writer, level int) io.Writer
-
-// Interface for types that allow resetting io.Writers.
-type ioResetterWriter interface {
- io.Writer
- Reset(w io.Writer)
-}
-
-type compressResponseWriter struct {
- http.ResponseWriter
-
- // The streaming encoder writer to be used if there is one. Otherwise,
- // this is just the normal writer.
- w io.Writer
- contentTypes map[string]struct{}
- contentWildcards map[string]struct{}
- encoding string
- wroteHeader bool
- compressible bool
-}
-
-func (cw *compressResponseWriter) isCompressible() bool {
- // Parse the first part of the Content-Type response header.
- contentType := cw.Header().Get("Content-Type")
- if idx := strings.Index(contentType, ";"); idx >= 0 {
- contentType = contentType[0:idx]
- }
-
- // Is the content type compressible?
- if _, ok := cw.contentTypes[contentType]; ok {
- return true
- }
- if idx := strings.Index(contentType, "/"); idx > 0 {
- contentType = contentType[0:idx]
- _, ok := cw.contentWildcards[contentType]
- return ok
- }
- return false
-}
-
-func (cw *compressResponseWriter) WriteHeader(code int) {
- if cw.wroteHeader {
- cw.ResponseWriter.WriteHeader(code) // Allow multiple calls to propagate.
- return
- }
- cw.wroteHeader = true
- defer cw.ResponseWriter.WriteHeader(code)
-
- // Already compressed data?
- if cw.Header().Get("Content-Encoding") != "" {
- return
- }
-
- if !cw.isCompressible() {
- cw.compressible = false
- return
- }
-
- if cw.encoding != "" {
- cw.compressible = true
- cw.Header().Set("Content-Encoding", cw.encoding)
- cw.Header().Add("Vary", "Accept-Encoding")
-
- // The content-length after compression is unknown
- cw.Header().Del("Content-Length")
- }
-}
-
-func (cw *compressResponseWriter) Write(p []byte) (int, error) {
- if !cw.wroteHeader {
- cw.WriteHeader(http.StatusOK)
- }
-
- return cw.writer().Write(p)
-}
-
-func (cw *compressResponseWriter) writer() io.Writer {
- if cw.compressible {
- return cw.w
- }
- return cw.ResponseWriter
-}
-
-type compressFlusher interface {
- Flush() error
-}
-
-func (cw *compressResponseWriter) Flush() {
- if f, ok := cw.writer().(http.Flusher); ok {
- f.Flush()
- }
- // If the underlying writer has a compression flush signature,
- // call this Flush() method instead
- if f, ok := cw.writer().(compressFlusher); ok {
- f.Flush()
-
- // Also flush the underlying response writer
- if f, ok := cw.ResponseWriter.(http.Flusher); ok {
- f.Flush()
- }
- }
-}
-
-func (cw *compressResponseWriter) Hijack() (net.Conn, *bufio.ReadWriter, error) {
- if hj, ok := cw.writer().(http.Hijacker); ok {
- return hj.Hijack()
- }
- return nil, nil, errors.New("chi/middleware: http.Hijacker is unavailable on the writer")
-}
-
-func (cw *compressResponseWriter) Push(target string, opts *http.PushOptions) error {
- if ps, ok := cw.writer().(http.Pusher); ok {
- return ps.Push(target, opts)
- }
- return errors.New("chi/middleware: http.Pusher is unavailable on the writer")
-}
-
-func (cw *compressResponseWriter) Close() error {
- if c, ok := cw.writer().(io.WriteCloser); ok {
- return c.Close()
- }
- return errors.New("chi/middleware: io.WriteCloser is unavailable on the writer")
-}
-
-func (cw *compressResponseWriter) Unwrap() http.ResponseWriter {
- return cw.ResponseWriter
-}
-
-func encoderGzip(w io.Writer, level int) io.Writer {
- gw, err := gzip.NewWriterLevel(w, level)
- if err != nil {
- return nil
- }
- return gw
-}
-
-func encoderDeflate(w io.Writer, level int) io.Writer {
- dw, err := flate.NewWriter(w, level)
- if err != nil {
- return nil
- }
- return dw
-}
diff --git a/vendor/github.com/go-chi/chi/v5/middleware/content_charset.go b/vendor/github.com/go-chi/chi/v5/middleware/content_charset.go
deleted file mode 100644
index 07b5ce6..0000000
--- a/vendor/github.com/go-chi/chi/v5/middleware/content_charset.go
+++ /dev/null
@@ -1,51 +0,0 @@
-package middleware
-
-import (
- "net/http"
- "strings"
-)
-
-// ContentCharset generates a handler that writes a 415 Unsupported Media Type response if none of the charsets match.
-// An empty charset will allow requests with no Content-Type header or no specified charset.
-func ContentCharset(charsets ...string) func(next http.Handler) http.Handler {
- for i, c := range charsets {
- charsets[i] = strings.ToLower(c)
- }
-
- return func(next http.Handler) http.Handler {
- return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
- if !contentEncoding(r.Header.Get("Content-Type"), charsets...) {
- w.WriteHeader(http.StatusUnsupportedMediaType)
- return
- }
-
- next.ServeHTTP(w, r)
- })
- }
-}
-
-// Check the content encoding against a list of acceptable values.
-func contentEncoding(ce string, charsets ...string) bool {
- _, ce = split(strings.ToLower(ce), ";")
- _, ce = split(ce, "charset=")
- ce, _ = split(ce, ";")
- for _, c := range charsets {
- if ce == c {
- return true
- }
- }
-
- return false
-}
-
-// Split a string in two parts, cleaning any whitespace.
-func split(str, sep string) (string, string) {
- var a, b string
- var parts = strings.SplitN(str, sep, 2)
- a = strings.TrimSpace(parts[0])
- if len(parts) == 2 {
- b = strings.TrimSpace(parts[1])
- }
-
- return a, b
-}
diff --git a/vendor/github.com/go-chi/chi/v5/middleware/content_encoding.go b/vendor/github.com/go-chi/chi/v5/middleware/content_encoding.go
deleted file mode 100644
index e0b9ccc..0000000
--- a/vendor/github.com/go-chi/chi/v5/middleware/content_encoding.go
+++ /dev/null
@@ -1,34 +0,0 @@
-package middleware
-
-import (
- "net/http"
- "strings"
-)
-
-// AllowContentEncoding enforces a whitelist of request Content-Encoding otherwise responds
-// with a 415 Unsupported Media Type status.
-func AllowContentEncoding(contentEncoding ...string) func(next http.Handler) http.Handler {
- allowedEncodings := make(map[string]struct{}, len(contentEncoding))
- for _, encoding := range contentEncoding {
- allowedEncodings[strings.TrimSpace(strings.ToLower(encoding))] = struct{}{}
- }
- return func(next http.Handler) http.Handler {
- fn := func(w http.ResponseWriter, r *http.Request) {
- requestEncodings := r.Header["Content-Encoding"]
- // skip check for empty content body or no Content-Encoding
- if r.ContentLength == 0 {
- next.ServeHTTP(w, r)
- return
- }
- // All encodings in the request must be allowed
- for _, encoding := range requestEncodings {
- if _, ok := allowedEncodings[strings.TrimSpace(strings.ToLower(encoding))]; !ok {
- w.WriteHeader(http.StatusUnsupportedMediaType)
- return
- }
- }
- next.ServeHTTP(w, r)
- }
- return http.HandlerFunc(fn)
- }
-}
diff --git a/vendor/github.com/go-chi/chi/v5/middleware/content_type.go b/vendor/github.com/go-chi/chi/v5/middleware/content_type.go
deleted file mode 100644
index 023978f..0000000
--- a/vendor/github.com/go-chi/chi/v5/middleware/content_type.go
+++ /dev/null
@@ -1,49 +0,0 @@
-package middleware
-
-import (
- "net/http"
- "strings"
-)
-
-// SetHeader is a convenience handler to set a response header key/value
-func SetHeader(key, value string) func(next http.Handler) http.Handler {
- return func(next http.Handler) http.Handler {
- fn := func(w http.ResponseWriter, r *http.Request) {
- w.Header().Set(key, value)
- next.ServeHTTP(w, r)
- }
- return http.HandlerFunc(fn)
- }
-}
-
-// AllowContentType enforces a whitelist of request Content-Types otherwise responds
-// with a 415 Unsupported Media Type status.
-func AllowContentType(contentTypes ...string) func(next http.Handler) http.Handler {
- allowedContentTypes := make(map[string]struct{}, len(contentTypes))
- for _, ctype := range contentTypes {
- allowedContentTypes[strings.TrimSpace(strings.ToLower(ctype))] = struct{}{}
- }
-
- return func(next http.Handler) http.Handler {
- fn := func(w http.ResponseWriter, r *http.Request) {
- if r.ContentLength == 0 {
- // skip check for empty content body
- next.ServeHTTP(w, r)
- return
- }
-
- s := strings.ToLower(strings.TrimSpace(r.Header.Get("Content-Type")))
- if i := strings.Index(s, ";"); i > -1 {
- s = s[0:i]
- }
-
- if _, ok := allowedContentTypes[s]; ok {
- next.ServeHTTP(w, r)
- return
- }
-
- w.WriteHeader(http.StatusUnsupportedMediaType)
- }
- return http.HandlerFunc(fn)
- }
-}
diff --git a/vendor/github.com/go-chi/chi/v5/middleware/get_head.go b/vendor/github.com/go-chi/chi/v5/middleware/get_head.go
deleted file mode 100644
index d4606d8..0000000
--- a/vendor/github.com/go-chi/chi/v5/middleware/get_head.go
+++ /dev/null
@@ -1,39 +0,0 @@
-package middleware
-
-import (
- "net/http"
-
- "github.com/go-chi/chi/v5"
-)
-
-// GetHead automatically route undefined HEAD requests to GET handlers.
-func GetHead(next http.Handler) http.Handler {
- return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
- if r.Method == "HEAD" {
- rctx := chi.RouteContext(r.Context())
- routePath := rctx.RoutePath
- if routePath == "" {
- if r.URL.RawPath != "" {
- routePath = r.URL.RawPath
- } else {
- routePath = r.URL.Path
- }
- }
-
- // Temporary routing context to look-ahead before routing the request
- tctx := chi.NewRouteContext()
-
- // Attempt to find a HEAD handler for the routing path, if not found, traverse
- // the router as through its a GET route, but proceed with the request
- // with the HEAD method.
- if !rctx.Routes.Match(tctx, "HEAD", routePath) {
- rctx.RouteMethod = "GET"
- rctx.RoutePath = routePath
- next.ServeHTTP(w, r)
- return
- }
- }
-
- next.ServeHTTP(w, r)
- })
-}
diff --git a/vendor/github.com/go-chi/chi/v5/middleware/heartbeat.go b/vendor/github.com/go-chi/chi/v5/middleware/heartbeat.go
deleted file mode 100644
index f36e8cc..0000000
--- a/vendor/github.com/go-chi/chi/v5/middleware/heartbeat.go
+++ /dev/null
@@ -1,26 +0,0 @@
-package middleware
-
-import (
- "net/http"
- "strings"
-)
-
-// Heartbeat endpoint middleware useful to setting up a path like
-// `/ping` that load balancers or uptime testing external services
-// can make a request before hitting any routes. It's also convenient
-// to place this above ACL middlewares as well.
-func Heartbeat(endpoint string) func(http.Handler) http.Handler {
- f := func(h http.Handler) http.Handler {
- fn := func(w http.ResponseWriter, r *http.Request) {
- if (r.Method == "GET" || r.Method == "HEAD") && strings.EqualFold(r.URL.Path, endpoint) {
- w.Header().Set("Content-Type", "text/plain")
- w.WriteHeader(http.StatusOK)
- w.Write([]byte("."))
- return
- }
- h.ServeHTTP(w, r)
- }
- return http.HandlerFunc(fn)
- }
- return f
-}
diff --git a/vendor/github.com/go-chi/chi/v5/middleware/logger.go b/vendor/github.com/go-chi/chi/v5/middleware/logger.go
deleted file mode 100644
index cff9bd2..0000000
--- a/vendor/github.com/go-chi/chi/v5/middleware/logger.go
+++ /dev/null
@@ -1,172 +0,0 @@
-package middleware
-
-import (
- "bytes"
- "context"
- "log"
- "net/http"
- "os"
- "runtime"
- "time"
-)
-
-var (
- // LogEntryCtxKey is the context.Context key to store the request log entry.
- LogEntryCtxKey = &contextKey{"LogEntry"}
-
- // DefaultLogger is called by the Logger middleware handler to log each request.
- // Its made a package-level variable so that it can be reconfigured for custom
- // logging configurations.
- DefaultLogger func(next http.Handler) http.Handler
-)
-
-// Logger is a middleware that logs the start and end of each request, along
-// with some useful data about what was requested, what the response status was,
-// and how long it took to return. When standard output is a TTY, Logger will
-// print in color, otherwise it will print in black and white. Logger prints a
-// request ID if one is provided.
-//
-// Alternatively, look at https://github.com/goware/httplog for a more in-depth
-// http logger with structured logging support.
-//
-// IMPORTANT NOTE: Logger should go before any other middleware that may change
-// the response, such as middleware.Recoverer. Example:
-//
-// r := chi.NewRouter()
-// r.Use(middleware.Logger) // <--<< Logger should come before Recoverer
-// r.Use(middleware.Recoverer)
-// r.Get("/", handler)
-func Logger(next http.Handler) http.Handler {
- return DefaultLogger(next)
-}
-
-// RequestLogger returns a logger handler using a custom LogFormatter.
-func RequestLogger(f LogFormatter) func(next http.Handler) http.Handler {
- return func(next http.Handler) http.Handler {
- fn := func(w http.ResponseWriter, r *http.Request) {
- entry := f.NewLogEntry(r)
- ww := NewWrapResponseWriter(w, r.ProtoMajor)
-
- t1 := time.Now()
- defer func() {
- entry.Write(ww.Status(), ww.BytesWritten(), ww.Header(), time.Since(t1), nil)
- }()
-
- next.ServeHTTP(ww, WithLogEntry(r, entry))
- }
- return http.HandlerFunc(fn)
- }
-}
-
-// LogFormatter initiates the beginning of a new LogEntry per request.
-// See DefaultLogFormatter for an example implementation.
-type LogFormatter interface {
- NewLogEntry(r *http.Request) LogEntry
-}
-
-// LogEntry records the final log when a request completes.
-// See defaultLogEntry for an example implementation.
-type LogEntry interface {
- Write(status, bytes int, header http.Header, elapsed time.Duration, extra interface{})
- Panic(v interface{}, stack []byte)
-}
-
-// GetLogEntry returns the in-context LogEntry for a request.
-func GetLogEntry(r *http.Request) LogEntry {
- entry, _ := r.Context().Value(LogEntryCtxKey).(LogEntry)
- return entry
-}
-
-// WithLogEntry sets the in-context LogEntry for a request.
-func WithLogEntry(r *http.Request, entry LogEntry) *http.Request {
- r = r.WithContext(context.WithValue(r.Context(), LogEntryCtxKey, entry))
- return r
-}
-
-// LoggerInterface accepts printing to stdlib logger or compatible logger.
-type LoggerInterface interface {
- Print(v ...interface{})
-}
-
-// DefaultLogFormatter is a simple logger that implements a LogFormatter.
-type DefaultLogFormatter struct {
- Logger LoggerInterface
- NoColor bool
-}
-
-// NewLogEntry creates a new LogEntry for the request.
-func (l *DefaultLogFormatter) NewLogEntry(r *http.Request) LogEntry {
- useColor := !l.NoColor
- entry := &defaultLogEntry{
- DefaultLogFormatter: l,
- request: r,
- buf: &bytes.Buffer{},
- useColor: useColor,
- }
-
- reqID := GetReqID(r.Context())
- if reqID != "" {
- cW(entry.buf, useColor, nYellow, "[%s] ", reqID)
- }
- cW(entry.buf, useColor, nCyan, "\"")
- cW(entry.buf, useColor, bMagenta, "%s ", r.Method)
-
- scheme := "http"
- if r.TLS != nil {
- scheme = "https"
- }
- cW(entry.buf, useColor, nCyan, "%s://%s%s %s\" ", scheme, r.Host, r.RequestURI, r.Proto)
-
- entry.buf.WriteString("from ")
- entry.buf.WriteString(r.RemoteAddr)
- entry.buf.WriteString(" - ")
-
- return entry
-}
-
-type defaultLogEntry struct {
- *DefaultLogFormatter
- request *http.Request
- buf *bytes.Buffer
- useColor bool
-}
-
-func (l *defaultLogEntry) Write(status, bytes int, header http.Header, elapsed time.Duration, extra interface{}) {
- switch {
- case status < 200:
- cW(l.buf, l.useColor, bBlue, "%03d", status)
- case status < 300:
- cW(l.buf, l.useColor, bGreen, "%03d", status)
- case status < 400:
- cW(l.buf, l.useColor, bCyan, "%03d", status)
- case status < 500:
- cW(l.buf, l.useColor, bYellow, "%03d", status)
- default:
- cW(l.buf, l.useColor, bRed, "%03d", status)
- }
-
- cW(l.buf, l.useColor, bBlue, " %dB", bytes)
-
- l.buf.WriteString(" in ")
- if elapsed < 500*time.Millisecond {
- cW(l.buf, l.useColor, nGreen, "%s", elapsed)
- } else if elapsed < 5*time.Second {
- cW(l.buf, l.useColor, nYellow, "%s", elapsed)
- } else {
- cW(l.buf, l.useColor, nRed, "%s", elapsed)
- }
-
- l.Logger.Print(l.buf.String())
-}
-
-func (l *defaultLogEntry) Panic(v interface{}, stack []byte) {
- PrintPrettyStack(v)
-}
-
-func init() {
- color := true
- if runtime.GOOS == "windows" {
- color = false
- }
- DefaultLogger = RequestLogger(&DefaultLogFormatter{Logger: log.New(os.Stdout, "", log.LstdFlags), NoColor: !color})
-}
diff --git a/vendor/github.com/go-chi/chi/v5/middleware/maybe.go b/vendor/github.com/go-chi/chi/v5/middleware/maybe.go
deleted file mode 100644
index eabca00..0000000
--- a/vendor/github.com/go-chi/chi/v5/middleware/maybe.go
+++ /dev/null
@@ -1,18 +0,0 @@
-package middleware
-
-import "net/http"
-
-// Maybe middleware will allow you to change the flow of the middleware stack execution depending on return
-// value of maybeFn(request). This is useful for example if you'd like to skip a middleware handler if
-// a request does not satisfy the maybeFn logic.
-func Maybe(mw func(http.Handler) http.Handler, maybeFn func(r *http.Request) bool) func(http.Handler) http.Handler {
- return func(next http.Handler) http.Handler {
- return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
- if maybeFn(r) {
- mw(next).ServeHTTP(w, r)
- } else {
- next.ServeHTTP(w, r)
- }
- })
- }
-}
diff --git a/vendor/github.com/go-chi/chi/v5/middleware/middleware.go b/vendor/github.com/go-chi/chi/v5/middleware/middleware.go
deleted file mode 100644
index cc371e0..0000000
--- a/vendor/github.com/go-chi/chi/v5/middleware/middleware.go
+++ /dev/null
@@ -1,23 +0,0 @@
-package middleware
-
-import "net/http"
-
-// New will create a new middleware handler from a http.Handler.
-func New(h http.Handler) func(next http.Handler) http.Handler {
- return func(next http.Handler) http.Handler {
- return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
- h.ServeHTTP(w, r)
- })
- }
-}
-
-// contextKey is a value for use with context.WithValue. It's used as
-// a pointer so it fits in an interface{} without allocation. This technique
-// for defining context keys was copied from Go 1.7's new use of context in net/http.
-type contextKey struct {
- name string
-}
-
-func (k *contextKey) String() string {
- return "chi/middleware context value " + k.name
-}
diff --git a/vendor/github.com/go-chi/chi/v5/middleware/nocache.go b/vendor/github.com/go-chi/chi/v5/middleware/nocache.go
deleted file mode 100644
index 9308d40..0000000
--- a/vendor/github.com/go-chi/chi/v5/middleware/nocache.go
+++ /dev/null
@@ -1,59 +0,0 @@
-package middleware
-
-// Ported from Goji's middleware, source:
-// https://github.com/zenazn/goji/tree/master/web/middleware
-
-import (
- "net/http"
- "time"
-)
-
-// Unix epoch time
-var epoch = time.Unix(0, 0).UTC().Format(http.TimeFormat)
-
-// Taken from https://github.com/mytrile/nocache
-var noCacheHeaders = map[string]string{
- "Expires": epoch,
- "Cache-Control": "no-cache, no-store, no-transform, must-revalidate, private, max-age=0",
- "Pragma": "no-cache",
- "X-Accel-Expires": "0",
-}
-
-var etagHeaders = []string{
- "ETag",
- "If-Modified-Since",
- "If-Match",
- "If-None-Match",
- "If-Range",
- "If-Unmodified-Since",
-}
-
-// NoCache is a simple piece of middleware that sets a number of HTTP headers to prevent
-// a router (or subrouter) from being cached by an upstream proxy and/or client.
-//
-// As per http://wiki.nginx.org/HttpProxyModule - NoCache sets:
-//
-// Expires: Thu, 01 Jan 1970 00:00:00 UTC
-// Cache-Control: no-cache, private, max-age=0
-// X-Accel-Expires: 0
-// Pragma: no-cache (for HTTP/1.0 proxies/clients)
-func NoCache(h http.Handler) http.Handler {
- fn := func(w http.ResponseWriter, r *http.Request) {
-
- // Delete any ETag headers that may have been set
- for _, v := range etagHeaders {
- if r.Header.Get(v) != "" {
- r.Header.Del(v)
- }
- }
-
- // Set our NoCache headers
- for k, v := range noCacheHeaders {
- w.Header().Set(k, v)
- }
-
- h.ServeHTTP(w, r)
- }
-
- return http.HandlerFunc(fn)
-}
diff --git a/vendor/github.com/go-chi/chi/v5/middleware/page_route.go b/vendor/github.com/go-chi/chi/v5/middleware/page_route.go
deleted file mode 100644
index 32871b7..0000000
--- a/vendor/github.com/go-chi/chi/v5/middleware/page_route.go
+++ /dev/null
@@ -1,20 +0,0 @@
-package middleware
-
-import (
- "net/http"
- "strings"
-)
-
-// PageRoute is a simple middleware which allows you to route a static GET request
-// at the middleware stack level.
-func PageRoute(path string, handler http.Handler) func(http.Handler) http.Handler {
- return func(next http.Handler) http.Handler {
- return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
- if r.Method == "GET" && strings.EqualFold(r.URL.Path, path) {
- handler.ServeHTTP(w, r)
- return
- }
- next.ServeHTTP(w, r)
- })
- }
-}
diff --git a/vendor/github.com/go-chi/chi/v5/middleware/path_rewrite.go b/vendor/github.com/go-chi/chi/v5/middleware/path_rewrite.go
deleted file mode 100644
index 99af62c..0000000
--- a/vendor/github.com/go-chi/chi/v5/middleware/path_rewrite.go
+++ /dev/null
@@ -1,16 +0,0 @@
-package middleware
-
-import (
- "net/http"
- "strings"
-)
-
-// PathRewrite is a simple middleware which allows you to rewrite the request URL path.
-func PathRewrite(old, new string) func(http.Handler) http.Handler {
- return func(next http.Handler) http.Handler {
- return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
- r.URL.Path = strings.Replace(r.URL.Path, old, new, 1)
- next.ServeHTTP(w, r)
- })
- }
-}
diff --git a/vendor/github.com/go-chi/chi/v5/middleware/profiler.go b/vendor/github.com/go-chi/chi/v5/middleware/profiler.go
deleted file mode 100644
index ebd81ee..0000000
--- a/vendor/github.com/go-chi/chi/v5/middleware/profiler.go
+++ /dev/null
@@ -1,46 +0,0 @@
-package middleware
-
-import (
- "expvar"
- "net/http"
- "net/http/pprof"
-
- "github.com/go-chi/chi/v5"
-)
-
-// Profiler is a convenient subrouter used for mounting net/http/pprof. ie.
-//
-// func MyService() http.Handler {
-// r := chi.NewRouter()
-// // ..middlewares
-// r.Mount("/debug", middleware.Profiler())
-// // ..routes
-// return r
-// }
-func Profiler() http.Handler {
- r := chi.NewRouter()
- r.Use(NoCache)
-
- r.Get("/", func(w http.ResponseWriter, r *http.Request) {
- http.Redirect(w, r, r.RequestURI+"/pprof/", http.StatusMovedPermanently)
- })
- r.HandleFunc("/pprof", func(w http.ResponseWriter, r *http.Request) {
- http.Redirect(w, r, r.RequestURI+"/", http.StatusMovedPermanently)
- })
-
- r.HandleFunc("/pprof/*", pprof.Index)
- r.HandleFunc("/pprof/cmdline", pprof.Cmdline)
- r.HandleFunc("/pprof/profile", pprof.Profile)
- r.HandleFunc("/pprof/symbol", pprof.Symbol)
- r.HandleFunc("/pprof/trace", pprof.Trace)
- r.Handle("/vars", expvar.Handler())
-
- r.Handle("/pprof/goroutine", pprof.Handler("goroutine"))
- r.Handle("/pprof/threadcreate", pprof.Handler("threadcreate"))
- r.Handle("/pprof/mutex", pprof.Handler("mutex"))
- r.Handle("/pprof/heap", pprof.Handler("heap"))
- r.Handle("/pprof/block", pprof.Handler("block"))
- r.Handle("/pprof/allocs", pprof.Handler("allocs"))
-
- return r
-}
diff --git a/vendor/github.com/go-chi/chi/v5/middleware/realip.go b/vendor/github.com/go-chi/chi/v5/middleware/realip.go
deleted file mode 100644
index 2c6b3b3..0000000
--- a/vendor/github.com/go-chi/chi/v5/middleware/realip.go
+++ /dev/null
@@ -1,60 +0,0 @@
-package middleware
-
-// Ported from Goji's middleware, source:
-// https://github.com/zenazn/goji/tree/master/web/middleware
-
-import (
- "net"
- "net/http"
- "strings"
-)
-
-var trueClientIP = http.CanonicalHeaderKey("True-Client-IP")
-var xForwardedFor = http.CanonicalHeaderKey("X-Forwarded-For")
-var xRealIP = http.CanonicalHeaderKey("X-Real-IP")
-
-// RealIP is a middleware that sets a http.Request's RemoteAddr to the results
-// of parsing either the True-Client-IP, X-Real-IP or the X-Forwarded-For headers
-// (in that order).
-//
-// This middleware should be inserted fairly early in the middleware stack to
-// ensure that subsequent layers (e.g., request loggers) which examine the
-// RemoteAddr will see the intended value.
-//
-// You should only use this middleware if you can trust the headers passed to
-// you (in particular, the two headers this middleware uses), for example
-// because you have placed a reverse proxy like HAProxy or nginx in front of
-// chi. If your reverse proxies are configured to pass along arbitrary header
-// values from the client, or if you use this middleware without a reverse
-// proxy, malicious clients will be able to make you very sad (or, depending on
-// how you're using RemoteAddr, vulnerable to an attack of some sort).
-func RealIP(h http.Handler) http.Handler {
- fn := func(w http.ResponseWriter, r *http.Request) {
- if rip := realIP(r); rip != "" {
- r.RemoteAddr = rip
- }
- h.ServeHTTP(w, r)
- }
-
- return http.HandlerFunc(fn)
-}
-
-func realIP(r *http.Request) string {
- var ip string
-
- if tcip := r.Header.Get(trueClientIP); tcip != "" {
- ip = tcip
- } else if xrip := r.Header.Get(xRealIP); xrip != "" {
- ip = xrip
- } else if xff := r.Header.Get(xForwardedFor); xff != "" {
- i := strings.Index(xff, ",")
- if i == -1 {
- i = len(xff)
- }
- ip = xff[:i]
- }
- if ip == "" || net.ParseIP(ip) == nil {
- return ""
- }
- return ip
-}
diff --git a/vendor/github.com/go-chi/chi/v5/middleware/recoverer.go b/vendor/github.com/go-chi/chi/v5/middleware/recoverer.go
deleted file mode 100644
index 81342df..0000000
--- a/vendor/github.com/go-chi/chi/v5/middleware/recoverer.go
+++ /dev/null
@@ -1,203 +0,0 @@
-package middleware
-
-// The original work was derived from Goji's middleware, source:
-// https://github.com/zenazn/goji/tree/master/web/middleware
-
-import (
- "bytes"
- "errors"
- "fmt"
- "io"
- "net/http"
- "os"
- "runtime/debug"
- "strings"
-)
-
-// Recoverer is a middleware that recovers from panics, logs the panic (and a
-// backtrace), and returns a HTTP 500 (Internal Server Error) status if
-// possible. Recoverer prints a request ID if one is provided.
-//
-// Alternatively, look at https://github.com/go-chi/httplog middleware pkgs.
-func Recoverer(next http.Handler) http.Handler {
- fn := func(w http.ResponseWriter, r *http.Request) {
- defer func() {
- if rvr := recover(); rvr != nil {
- if rvr == http.ErrAbortHandler {
- // we don't recover http.ErrAbortHandler so the response
- // to the client is aborted, this should not be logged
- panic(rvr)
- }
-
- logEntry := GetLogEntry(r)
- if logEntry != nil {
- logEntry.Panic(rvr, debug.Stack())
- } else {
- PrintPrettyStack(rvr)
- }
-
- if r.Header.Get("Connection") != "Upgrade" {
- w.WriteHeader(http.StatusInternalServerError)
- }
- }
- }()
-
- next.ServeHTTP(w, r)
- }
-
- return http.HandlerFunc(fn)
-}
-
-// for ability to test the PrintPrettyStack function
-var recovererErrorWriter io.Writer = os.Stderr
-
-func PrintPrettyStack(rvr interface{}) {
- debugStack := debug.Stack()
- s := prettyStack{}
- out, err := s.parse(debugStack, rvr)
- if err == nil {
- recovererErrorWriter.Write(out)
- } else {
- // print stdlib output as a fallback
- os.Stderr.Write(debugStack)
- }
-}
-
-type prettyStack struct {
-}
-
-func (s prettyStack) parse(debugStack []byte, rvr interface{}) ([]byte, error) {
- var err error
- useColor := true
- buf := &bytes.Buffer{}
-
- cW(buf, false, bRed, "\n")
- cW(buf, useColor, bCyan, " panic: ")
- cW(buf, useColor, bBlue, "%v", rvr)
- cW(buf, false, bWhite, "\n \n")
-
- // process debug stack info
- stack := strings.Split(string(debugStack), "\n")
- lines := []string{}
-
- // locate panic line, as we may have nested panics
- for i := len(stack) - 1; i > 0; i-- {
- lines = append(lines, stack[i])
- if strings.HasPrefix(stack[i], "panic(") {
- lines = lines[0 : len(lines)-2] // remove boilerplate
- break
- }
- }
-
- // reverse
- for i := len(lines)/2 - 1; i >= 0; i-- {
- opp := len(lines) - 1 - i
- lines[i], lines[opp] = lines[opp], lines[i]
- }
-
- // decorate
- for i, line := range lines {
- lines[i], err = s.decorateLine(line, useColor, i)
- if err != nil {
- return nil, err
- }
- }
-
- for _, l := range lines {
- fmt.Fprintf(buf, "%s", l)
- }
- return buf.Bytes(), nil
-}
-
-func (s prettyStack) decorateLine(line string, useColor bool, num int) (string, error) {
- line = strings.TrimSpace(line)
- if strings.HasPrefix(line, "\t") || strings.Contains(line, ".go:") {
- return s.decorateSourceLine(line, useColor, num)
- }
- if strings.HasSuffix(line, ")") {
- return s.decorateFuncCallLine(line, useColor, num)
- }
- if strings.HasPrefix(line, "\t") {
- return strings.Replace(line, "\t", " ", 1), nil
- }
- return fmt.Sprintf(" %s\n", line), nil
-}
-
-func (s prettyStack) decorateFuncCallLine(line string, useColor bool, num int) (string, error) {
- idx := strings.LastIndex(line, "(")
- if idx < 0 {
- return "", errors.New("not a func call line")
- }
-
- buf := &bytes.Buffer{}
- pkg := line[0:idx]
- // addr := line[idx:]
- method := ""
-
- if idx := strings.LastIndex(pkg, string(os.PathSeparator)); idx < 0 {
- if idx := strings.Index(pkg, "."); idx > 0 {
- method = pkg[idx:]
- pkg = pkg[0:idx]
- }
- } else {
- method = pkg[idx+1:]
- pkg = pkg[0 : idx+1]
- if idx := strings.Index(method, "."); idx > 0 {
- pkg += method[0:idx]
- method = method[idx:]
- }
- }
- pkgColor := nYellow
- methodColor := bGreen
-
- if num == 0 {
- cW(buf, useColor, bRed, " -> ")
- pkgColor = bMagenta
- methodColor = bRed
- } else {
- cW(buf, useColor, bWhite, " ")
- }
- cW(buf, useColor, pkgColor, "%s", pkg)
- cW(buf, useColor, methodColor, "%s\n", method)
- // cW(buf, useColor, nBlack, "%s", addr)
- return buf.String(), nil
-}
-
-func (s prettyStack) decorateSourceLine(line string, useColor bool, num int) (string, error) {
- idx := strings.LastIndex(line, ".go:")
- if idx < 0 {
- return "", errors.New("not a source line")
- }
-
- buf := &bytes.Buffer{}
- path := line[0 : idx+3]
- lineno := line[idx+3:]
-
- idx = strings.LastIndex(path, string(os.PathSeparator))
- dir := path[0 : idx+1]
- file := path[idx+1:]
-
- idx = strings.Index(lineno, " ")
- if idx > 0 {
- lineno = lineno[0:idx]
- }
- fileColor := bCyan
- lineColor := bGreen
-
- if num == 1 {
- cW(buf, useColor, bRed, " -> ")
- fileColor = bRed
- lineColor = bMagenta
- } else {
- cW(buf, false, bWhite, " ")
- }
- cW(buf, useColor, bWhite, "%s", dir)
- cW(buf, useColor, fileColor, "%s", file)
- cW(buf, useColor, lineColor, "%s", lineno)
- if num == 1 {
- cW(buf, false, bWhite, "\n")
- }
- cW(buf, false, bWhite, "\n")
-
- return buf.String(), nil
-}
diff --git a/vendor/github.com/go-chi/chi/v5/middleware/request_id.go b/vendor/github.com/go-chi/chi/v5/middleware/request_id.go
deleted file mode 100644
index 4903ecc..0000000
--- a/vendor/github.com/go-chi/chi/v5/middleware/request_id.go
+++ /dev/null
@@ -1,96 +0,0 @@
-package middleware
-
-// Ported from Goji's middleware, source:
-// https://github.com/zenazn/goji/tree/master/web/middleware
-
-import (
- "context"
- "crypto/rand"
- "encoding/base64"
- "fmt"
- "net/http"
- "os"
- "strings"
- "sync/atomic"
-)
-
-// Key to use when setting the request ID.
-type ctxKeyRequestID int
-
-// RequestIDKey is the key that holds the unique request ID in a request context.
-const RequestIDKey ctxKeyRequestID = 0
-
-// RequestIDHeader is the name of the HTTP Header which contains the request id.
-// Exported so that it can be changed by developers
-var RequestIDHeader = "X-Request-Id"
-
-var prefix string
-var reqid uint64
-
-// A quick note on the statistics here: we're trying to calculate the chance that
-// two randomly generated base62 prefixes will collide. We use the formula from
-// http://en.wikipedia.org/wiki/Birthday_problem
-//
-// P[m, n] \approx 1 - e^{-m^2/2n}
-//
-// We ballpark an upper bound for $m$ by imagining (for whatever reason) a server
-// that restarts every second over 10 years, for $m = 86400 * 365 * 10 = 315360000$
-//
-// For a $k$ character base-62 identifier, we have $n(k) = 62^k$
-//
-// Plugging this in, we find $P[m, n(10)] \approx 5.75%$, which is good enough for
-// our purposes, and is surely more than anyone would ever need in practice -- a
-// process that is rebooted a handful of times a day for a hundred years has less
-// than a millionth of a percent chance of generating two colliding IDs.
-
-func init() {
- hostname, err := os.Hostname()
- if hostname == "" || err != nil {
- hostname = "localhost"
- }
- var buf [12]byte
- var b64 string
- for len(b64) < 10 {
- rand.Read(buf[:])
- b64 = base64.StdEncoding.EncodeToString(buf[:])
- b64 = strings.NewReplacer("+", "", "/", "").Replace(b64)
- }
-
- prefix = fmt.Sprintf("%s/%s", hostname, b64[0:10])
-}
-
-// RequestID is a middleware that injects a request ID into the context of each
-// request. A request ID is a string of the form "host.example.com/random-0001",
-// where "random" is a base62 random string that uniquely identifies this go
-// process, and where the last number is an atomically incremented request
-// counter.
-func RequestID(next http.Handler) http.Handler {
- fn := func(w http.ResponseWriter, r *http.Request) {
- ctx := r.Context()
- requestID := r.Header.Get(RequestIDHeader)
- if requestID == "" {
- myid := atomic.AddUint64(&reqid, 1)
- requestID = fmt.Sprintf("%s-%06d", prefix, myid)
- }
- ctx = context.WithValue(ctx, RequestIDKey, requestID)
- next.ServeHTTP(w, r.WithContext(ctx))
- }
- return http.HandlerFunc(fn)
-}
-
-// GetReqID returns a request ID from the given context if one is present.
-// Returns the empty string if a request ID cannot be found.
-func GetReqID(ctx context.Context) string {
- if ctx == nil {
- return ""
- }
- if reqID, ok := ctx.Value(RequestIDKey).(string); ok {
- return reqID
- }
- return ""
-}
-
-// NextRequestID generates the next request ID in the sequence.
-func NextRequestID() uint64 {
- return atomic.AddUint64(&reqid, 1)
-}
diff --git a/vendor/github.com/go-chi/chi/v5/middleware/request_size.go b/vendor/github.com/go-chi/chi/v5/middleware/request_size.go
deleted file mode 100644
index 678248c..0000000
--- a/vendor/github.com/go-chi/chi/v5/middleware/request_size.go
+++ /dev/null
@@ -1,18 +0,0 @@
-package middleware
-
-import (
- "net/http"
-)
-
-// RequestSize is a middleware that will limit request sizes to a specified
-// number of bytes. It uses MaxBytesReader to do so.
-func RequestSize(bytes int64) func(http.Handler) http.Handler {
- f := func(h http.Handler) http.Handler {
- fn := func(w http.ResponseWriter, r *http.Request) {
- r.Body = http.MaxBytesReader(w, r.Body, bytes)
- h.ServeHTTP(w, r)
- }
- return http.HandlerFunc(fn)
- }
- return f
-}
diff --git a/vendor/github.com/go-chi/chi/v5/middleware/route_headers.go b/vendor/github.com/go-chi/chi/v5/middleware/route_headers.go
deleted file mode 100644
index 997bed5..0000000
--- a/vendor/github.com/go-chi/chi/v5/middleware/route_headers.go
+++ /dev/null
@@ -1,151 +0,0 @@
-package middleware
-
-import (
- "net/http"
- "strings"
-)
-
-// RouteHeaders is a neat little header-based router that allows you to direct
-// the flow of a request through a middleware stack based on a request header.
-//
-// For example, lets say you'd like to setup multiple routers depending on the
-// request Host header, you could then do something as so:
-//
-// r := chi.NewRouter()
-// rSubdomain := chi.NewRouter()
-// r.Use(middleware.RouteHeaders().
-// Route("Host", "example.com", middleware.New(r)).
-// Route("Host", "*.example.com", middleware.New(rSubdomain)).
-// Handler)
-// r.Get("/", h)
-// rSubdomain.Get("/", h2)
-//
-// Another example, imagine you want to setup multiple CORS handlers, where for
-// your origin servers you allow authorized requests, but for third-party public
-// requests, authorization is disabled.
-//
-// r := chi.NewRouter()
-// r.Use(middleware.RouteHeaders().
-// Route("Origin", "https://app.skyweaver.net", cors.Handler(cors.Options{
-// AllowedOrigins: []string{"https://api.skyweaver.net"},
-// AllowedMethods: []string{"GET", "POST", "PUT", "DELETE", "OPTIONS"},
-// AllowedHeaders: []string{"Accept", "Authorization", "Content-Type"},
-// AllowCredentials: true, // <----------<<< allow credentials
-// })).
-// Route("Origin", "*", cors.Handler(cors.Options{
-// AllowedOrigins: []string{"*"},
-// AllowedMethods: []string{"GET", "POST", "PUT", "DELETE", "OPTIONS"},
-// AllowedHeaders: []string{"Accept", "Content-Type"},
-// AllowCredentials: false, // <----------<<< do not allow credentials
-// })).
-// Handler)
-func RouteHeaders() HeaderRouter {
- return HeaderRouter{}
-}
-
-type HeaderRouter map[string][]HeaderRoute
-
-func (hr HeaderRouter) Route(header, match string, middlewareHandler func(next http.Handler) http.Handler) HeaderRouter {
- header = strings.ToLower(header)
- k := hr[header]
- if k == nil {
- hr[header] = []HeaderRoute{}
- }
- hr[header] = append(hr[header], HeaderRoute{MatchOne: NewPattern(match), Middleware: middlewareHandler})
- return hr
-}
-
-func (hr HeaderRouter) RouteAny(header string, match []string, middlewareHandler func(next http.Handler) http.Handler) HeaderRouter {
- header = strings.ToLower(header)
- k := hr[header]
- if k == nil {
- hr[header] = []HeaderRoute{}
- }
- patterns := []Pattern{}
- for _, m := range match {
- patterns = append(patterns, NewPattern(m))
- }
- hr[header] = append(hr[header], HeaderRoute{MatchAny: patterns, Middleware: middlewareHandler})
- return hr
-}
-
-func (hr HeaderRouter) RouteDefault(handler func(next http.Handler) http.Handler) HeaderRouter {
- hr["*"] = []HeaderRoute{{Middleware: handler}}
- return hr
-}
-
-func (hr HeaderRouter) Handler(next http.Handler) http.Handler {
- return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
- if len(hr) == 0 {
- // skip if no routes set
- next.ServeHTTP(w, r)
- }
-
- // find first matching header route, and continue
- for header, matchers := range hr {
- headerValue := r.Header.Get(header)
- if headerValue == "" {
- continue
- }
- headerValue = strings.ToLower(headerValue)
- for _, matcher := range matchers {
- if matcher.IsMatch(headerValue) {
- matcher.Middleware(next).ServeHTTP(w, r)
- return
- }
- }
- }
-
- // if no match, check for "*" default route
- matcher, ok := hr["*"]
- if !ok || matcher[0].Middleware == nil {
- next.ServeHTTP(w, r)
- return
- }
- matcher[0].Middleware(next).ServeHTTP(w, r)
- })
-}
-
-type HeaderRoute struct {
- Middleware func(next http.Handler) http.Handler
- MatchOne Pattern
- MatchAny []Pattern
-}
-
-func (r HeaderRoute) IsMatch(value string) bool {
- if len(r.MatchAny) > 0 {
- for _, m := range r.MatchAny {
- if m.Match(value) {
- return true
- }
- }
- } else if r.MatchOne.Match(value) {
- return true
- }
- return false
-}
-
-type Pattern struct {
- prefix string
- suffix string
- wildcard bool
-}
-
-func NewPattern(value string) Pattern {
- p := Pattern{}
- if i := strings.IndexByte(value, '*'); i >= 0 {
- p.wildcard = true
- p.prefix = value[0:i]
- p.suffix = value[i+1:]
- } else {
- p.prefix = value
- }
- return p
-}
-
-func (p Pattern) Match(v string) bool {
- if !p.wildcard {
- return p.prefix == v
- }
- return len(v) >= len(p.prefix+p.suffix) && strings.HasPrefix(v, p.prefix) && strings.HasSuffix(v, p.suffix)
-}
diff --git a/vendor/github.com/go-chi/chi/v5/middleware/strip.go b/vendor/github.com/go-chi/chi/v5/middleware/strip.go
deleted file mode 100644
index ce8ebfc..0000000
--- a/vendor/github.com/go-chi/chi/v5/middleware/strip.go
+++ /dev/null
@@ -1,62 +0,0 @@
-package middleware
-
-import (
- "fmt"
- "net/http"
-
- "github.com/go-chi/chi/v5"
-)
-
-// StripSlashes is a middleware that will match request paths with a trailing
-// slash, strip it from the path and continue routing through the mux, if a route
-// matches, then it will serve the handler.
-func StripSlashes(next http.Handler) http.Handler {
- fn := func(w http.ResponseWriter, r *http.Request) {
- var path string
- rctx := chi.RouteContext(r.Context())
- if rctx != nil && rctx.RoutePath != "" {
- path = rctx.RoutePath
- } else {
- path = r.URL.Path
- }
- if len(path) > 1 && path[len(path)-1] == '/' {
- newPath := path[:len(path)-1]
- if rctx == nil {
- r.URL.Path = newPath
- } else {
- rctx.RoutePath = newPath
- }
- }
- next.ServeHTTP(w, r)
- }
- return http.HandlerFunc(fn)
-}
-
-// RedirectSlashes is a middleware that will match request paths with a trailing
-// slash and redirect to the same path, less the trailing slash.
-//
-// NOTE: RedirectSlashes middleware is *incompatible* with http.FileServer,
-// see https://github.com/go-chi/chi/issues/343
-func RedirectSlashes(next http.Handler) http.Handler {
- fn := func(w http.ResponseWriter, r *http.Request) {
- var path string
- rctx := chi.RouteContext(r.Context())
- if rctx != nil && rctx.RoutePath != "" {
- path = rctx.RoutePath
- } else {
- path = r.URL.Path
- }
- if len(path) > 1 && path[len(path)-1] == '/' {
- if r.URL.RawQuery != "" {
- path = fmt.Sprintf("%s?%s", path[:len(path)-1], r.URL.RawQuery)
- } else {
- path = path[:len(path)-1]
- }
- redirectURL := fmt.Sprintf("//%s%s", r.Host, path)
- http.Redirect(w, r, redirectURL, 301)
- return
- }
- next.ServeHTTP(w, r)
- }
- return http.HandlerFunc(fn)
-}
diff --git a/vendor/github.com/go-chi/chi/v5/middleware/sunset.go b/vendor/github.com/go-chi/chi/v5/middleware/sunset.go
deleted file mode 100644
index 18815d5..0000000
--- a/vendor/github.com/go-chi/chi/v5/middleware/sunset.go
+++ /dev/null
@@ -1,25 +0,0 @@
-package middleware
-
-import (
- "net/http"
- "time"
-)
-
-// Sunset set Deprecation/Sunset header to response
-// This can be used to enable Sunset in a route or a route group
-// For more: https://www.rfc-editor.org/rfc/rfc8594.html
-func Sunset(sunsetAt time.Time, links ...string) func(http.Handler) http.Handler {
- return func(next http.Handler) http.Handler {
- return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
- if !sunsetAt.IsZero() {
- w.Header().Set("Sunset", sunsetAt.Format(http.TimeFormat))
- w.Header().Set("Deprecation", sunsetAt.Format(http.TimeFormat))
-
- for _, link := range links {
- w.Header().Add("Link", link)
- }
- }
- next.ServeHTTP(w, r)
- })
- }
-}
diff --git a/vendor/github.com/go-chi/chi/v5/middleware/supress_notfound.go b/vendor/github.com/go-chi/chi/v5/middleware/supress_notfound.go
deleted file mode 100644
index 83a8a87..0000000
--- a/vendor/github.com/go-chi/chi/v5/middleware/supress_notfound.go
+++ /dev/null
@@ -1,27 +0,0 @@
-package middleware
-
-import (
- "net/http"
-
- "github.com/go-chi/chi/v5"
-)
-
-// SupressNotFound will quickly respond with a 404 if the route is not found
-// and will not continue to the next middleware handler.
-//
-// This is handy to put at the top of your middleware stack to avoid unnecessary
-// processing of requests that are not going to match any routes anyway. For
-// example its super annoying to see a bunch of 404's in your logs from bots.
-func SupressNotFound(router *chi.Mux) func(next http.Handler) http.Handler {
- return func(next http.Handler) http.Handler {
- return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
- rctx := chi.RouteContext(r.Context())
- match := rctx.Routes.Match(rctx, r.Method, r.URL.Path)
- if !match {
- router.NotFoundHandler().ServeHTTP(w, r)
- return
- }
- next.ServeHTTP(w, r)
- })
- }
-}
diff --git a/vendor/github.com/go-chi/chi/v5/middleware/terminal.go b/vendor/github.com/go-chi/chi/v5/middleware/terminal.go
deleted file mode 100644
index 5ead7b9..0000000
--- a/vendor/github.com/go-chi/chi/v5/middleware/terminal.go
+++ /dev/null
@@ -1,63 +0,0 @@
-package middleware
-
-// Ported from Goji's middleware, source:
-// https://github.com/zenazn/goji/tree/master/web/middleware
-
-import (
- "fmt"
- "io"
- "os"
-)
-
-var (
- // Normal colors
- nBlack = []byte{'\033', '[', '3', '0', 'm'}
- nRed = []byte{'\033', '[', '3', '1', 'm'}
- nGreen = []byte{'\033', '[', '3', '2', 'm'}
- nYellow = []byte{'\033', '[', '3', '3', 'm'}
- nBlue = []byte{'\033', '[', '3', '4', 'm'}
- nMagenta = []byte{'\033', '[', '3', '5', 'm'}
- nCyan = []byte{'\033', '[', '3', '6', 'm'}
- nWhite = []byte{'\033', '[', '3', '7', 'm'}
- // Bright colors
- bBlack = []byte{'\033', '[', '3', '0', ';', '1', 'm'}
- bRed = []byte{'\033', '[', '3', '1', ';', '1', 'm'}
- bGreen = []byte{'\033', '[', '3', '2', ';', '1', 'm'}
- bYellow = []byte{'\033', '[', '3', '3', ';', '1', 'm'}
- bBlue = []byte{'\033', '[', '3', '4', ';', '1', 'm'}
- bMagenta = []byte{'\033', '[', '3', '5', ';', '1', 'm'}
- bCyan = []byte{'\033', '[', '3', '6', ';', '1', 'm'}
- bWhite = []byte{'\033', '[', '3', '7', ';', '1', 'm'}
-
- reset = []byte{'\033', '[', '0', 'm'}
-)
-
-var IsTTY bool
-
-func init() {
- // This is sort of cheating: if stdout is a character device, we assume
- // that means it's a TTY. Unfortunately, there are many non-TTY
- // character devices, but fortunately stdout is rarely set to any of
- // them.
- //
- // We could solve this properly by pulling in a dependency on
- // code.google.com/p/go.crypto/ssh/terminal, for instance, but as a
- // heuristic for whether to print in color or in black-and-white, I'd
- // really rather not.
- fi, err := os.Stdout.Stat()
- if err == nil {
- m := os.ModeDevice | os.ModeCharDevice
- IsTTY = fi.Mode()&m == m
- }
-}
-
-// colorWrite
-func cW(w io.Writer, useColor bool, color []byte, s string, args ...interface{}) {
- if IsTTY && useColor {
- w.Write(color)
- }
- fmt.Fprintf(w, s, args...)
- if IsTTY && useColor {
- w.Write(reset)
- }
-}
diff --git a/vendor/github.com/go-chi/chi/v5/middleware/throttle.go b/vendor/github.com/go-chi/chi/v5/middleware/throttle.go
deleted file mode 100644
index bdf4f9f..0000000
--- a/vendor/github.com/go-chi/chi/v5/middleware/throttle.go
+++ /dev/null
@@ -1,132 +0,0 @@
-package middleware
-
-import (
- "net/http"
- "strconv"
- "time"
-)
-
-const (
- errCapacityExceeded = "Server capacity exceeded."
- errTimedOut = "Timed out while waiting for a pending request to complete."
- errContextCanceled = "Context was canceled."
-)
-
-var (
- defaultBacklogTimeout = time.Second * 60
-)
-
-// ThrottleOpts represents a set of throttling options.
-type ThrottleOpts struct {
- RetryAfterFn func(ctxDone bool) time.Duration
- Limit int
- BacklogLimit int
- BacklogTimeout time.Duration
-}
-
-// Throttle is a middleware that limits number of currently processed requests
-// at a time across all users. Note: Throttle is not a rate-limiter per user,
-// instead it just puts a ceiling on the number of currently in-flight requests
-// being processed from the point from where the Throttle middleware is mounted.
-func Throttle(limit int) func(http.Handler) http.Handler {
- return ThrottleWithOpts(ThrottleOpts{Limit: limit, BacklogTimeout: defaultBacklogTimeout})
-}
-
-// ThrottleBacklog is a middleware that limits number of currently processed
-// requests at a time and provides a backlog for holding a finite number of
-// pending requests.
-func ThrottleBacklog(limit, backlogLimit int, backlogTimeout time.Duration) func(http.Handler) http.Handler {
- return ThrottleWithOpts(ThrottleOpts{Limit: limit, BacklogLimit: backlogLimit, BacklogTimeout: backlogTimeout})
-}
-
-// ThrottleWithOpts is a middleware that limits number of currently processed requests using passed ThrottleOpts.
-func ThrottleWithOpts(opts ThrottleOpts) func(http.Handler) http.Handler {
- if opts.Limit < 1 {
- panic("chi/middleware: Throttle expects limit > 0")
- }
-
- if opts.BacklogLimit < 0 {
- panic("chi/middleware: Throttle expects backlogLimit to be positive")
- }
-
- t := throttler{
- tokens: make(chan token, opts.Limit),
- backlogTokens: make(chan token, opts.Limit+opts.BacklogLimit),
- backlogTimeout: opts.BacklogTimeout,
- retryAfterFn: opts.RetryAfterFn,
- }
-
- // Filling tokens.
- for i := 0; i < opts.Limit+opts.BacklogLimit; i++ {
- if i < opts.Limit {
- t.tokens <- token{}
- }
- t.backlogTokens <- token{}
- }
-
- return func(next http.Handler) http.Handler {
- fn := func(w http.ResponseWriter, r *http.Request) {
- ctx := r.Context()
-
- select {
-
- case <-ctx.Done():
- t.setRetryAfterHeaderIfNeeded(w, true)
- http.Error(w, errContextCanceled, http.StatusTooManyRequests)
- return
-
- case btok := <-t.backlogTokens:
- timer := time.NewTimer(t.backlogTimeout)
-
- defer func() {
- t.backlogTokens <- btok
- }()
-
- select {
- case <-timer.C:
- t.setRetryAfterHeaderIfNeeded(w, false)
- http.Error(w, errTimedOut, http.StatusTooManyRequests)
- return
- case <-ctx.Done():
- timer.Stop()
- t.setRetryAfterHeaderIfNeeded(w, true)
- http.Error(w, errContextCanceled, http.StatusTooManyRequests)
- return
- case tok := <-t.tokens:
- defer func() {
- timer.Stop()
- t.tokens <- tok
- }()
- next.ServeHTTP(w, r)
- }
- return
-
- default:
- t.setRetryAfterHeaderIfNeeded(w, false)
- http.Error(w, errCapacityExceeded, http.StatusTooManyRequests)
- return
- }
- }
-
- return http.HandlerFunc(fn)
- }
-}
-
-// token represents a request that is being processed.
-type token struct{}
-
-// throttler limits number of currently processed requests at a time.
-type throttler struct {
- tokens chan token
- backlogTokens chan token
- retryAfterFn func(ctxDone bool) time.Duration
- backlogTimeout time.Duration
-}
-
-// setRetryAfterHeaderIfNeeded sets Retry-After HTTP header if corresponding retryAfterFn option of throttler is initialized.
-func (t throttler) setRetryAfterHeaderIfNeeded(w http.ResponseWriter, ctxDone bool) {
- if t.retryAfterFn == nil {
- return
- }
- w.Header().Set("Retry-After", strconv.Itoa(int(t.retryAfterFn(ctxDone).Seconds())))
-}
diff --git a/vendor/github.com/go-chi/chi/v5/middleware/timeout.go b/vendor/github.com/go-chi/chi/v5/middleware/timeout.go
deleted file mode 100644
index add596d..0000000
--- a/vendor/github.com/go-chi/chi/v5/middleware/timeout.go
+++ /dev/null
@@ -1,48 +0,0 @@
-package middleware
-
-import (
- "context"
- "net/http"
- "time"
-)
-
-// Timeout is a middleware that cancels ctx after a given timeout and return
-// a 504 Gateway Timeout error to the client.
-//
-// It's required that you select the ctx.Done() channel to check for the signal
-// if the context has reached its deadline and return, otherwise the timeout
-// signal will be just ignored.
-//
-// ie. a route/handler may look like:
-//
-// r.Get("/long", func(w http.ResponseWriter, r *http.Request) {
-// ctx := r.Context()
-// processTime := time.Duration(rand.Intn(4)+1) * time.Second
-//
-// select {
-// case <-ctx.Done():
-// return
-//
-// case <-time.After(processTime):
-// // The above channel simulates some hard work.
-// }
-//
-// w.Write([]byte("done"))
-// })
-func Timeout(timeout time.Duration) func(next http.Handler) http.Handler {
- return func(next http.Handler) http.Handler {
- fn := func(w http.ResponseWriter, r *http.Request) {
- ctx, cancel := context.WithTimeout(r.Context(), timeout)
- defer func() {
- cancel()
- if ctx.Err() == context.DeadlineExceeded {
- w.WriteHeader(http.StatusGatewayTimeout)
- }
- }()
-
- r = r.WithContext(ctx)
- next.ServeHTTP(w, r)
- }
- return http.HandlerFunc(fn)
- }
-}
diff --git a/vendor/github.com/go-chi/chi/v5/middleware/url_format.go b/vendor/github.com/go-chi/chi/v5/middleware/url_format.go
deleted file mode 100644
index d8a651e..0000000
--- a/vendor/github.com/go-chi/chi/v5/middleware/url_format.go
+++ /dev/null
@@ -1,75 +0,0 @@
-package middleware
-
-import (
- "context"
- "net/http"
- "strings"
-
- "github.com/go-chi/chi/v5"
-)
-
-var (
- // URLFormatCtxKey is the context.Context key to store the URL format data
- // for a request.
- URLFormatCtxKey = &contextKey{"URLFormat"}
-)
-
-// URLFormat is a middleware that parses the url extension from a request path and stores it
-// on the context as a string under the key `middleware.URLFormatCtxKey`. The middleware will
-// trim the suffix from the routing path and continue routing.
-//
-// Routers should not include a url parameter for the suffix when using this middleware.
-//
-// Sample usage for url paths `/articles/1`, `/articles/1.json` and `/articles/1.xml`:
-//
-// func routes() http.Handler {
-// r := chi.NewRouter()
-// r.Use(middleware.URLFormat)
-//
-// r.Get("/articles/{id}", ListArticles)
-//
-// return r
-// }
-//
-// func ListArticles(w http.ResponseWriter, r *http.Request) {
-// urlFormat, _ := r.Context().Value(middleware.URLFormatCtxKey).(string)
-//
-// switch urlFormat {
-// case "json":
-// render.JSON(w, r, articles)
-// case "xml:"
-// render.XML(w, r, articles)
-// default:
-// render.JSON(w, r, articles)
-// }
-// }
-func URLFormat(next http.Handler) http.Handler {
- fn := func(w http.ResponseWriter, r *http.Request) {
- ctx := r.Context()
-
- var format string
- path := r.URL.Path
-
- rctx := chi.RouteContext(r.Context())
- if rctx != nil && rctx.RoutePath != "" {
- path = rctx.RoutePath
- }
-
- if strings.Index(path, ".") > 0 {
- base := strings.LastIndex(path, "/")
- idx := strings.LastIndex(path[base:], ".")
-
- if idx > 0 {
- idx += base
- format = path[idx+1:]
-
- rctx.RoutePath = path[:idx]
- }
- }
-
- r = r.WithContext(context.WithValue(ctx, URLFormatCtxKey, format))
-
- next.ServeHTTP(w, r)
- }
- return http.HandlerFunc(fn)
-}
diff --git a/vendor/github.com/go-chi/chi/v5/middleware/value.go b/vendor/github.com/go-chi/chi/v5/middleware/value.go
deleted file mode 100644
index a9dfd43..0000000
--- a/vendor/github.com/go-chi/chi/v5/middleware/value.go
+++ /dev/null
@@ -1,17 +0,0 @@
-package middleware
-
-import (
- "context"
- "net/http"
-)
-
-// WithValue is a middleware that sets a given key/value in a context chain.
-func WithValue(key, val interface{}) func(next http.Handler) http.Handler {
- return func(next http.Handler) http.Handler {
- fn := func(w http.ResponseWriter, r *http.Request) {
- r = r.WithContext(context.WithValue(r.Context(), key, val))
- next.ServeHTTP(w, r)
- }
- return http.HandlerFunc(fn)
- }
-}
diff --git a/vendor/github.com/go-chi/chi/v5/middleware/wrap_writer.go b/vendor/github.com/go-chi/chi/v5/middleware/wrap_writer.go
deleted file mode 100644
index cf5c44d..0000000
--- a/vendor/github.com/go-chi/chi/v5/middleware/wrap_writer.go
+++ /dev/null
@@ -1,219 +0,0 @@
-package middleware
-
-// The original work was derived from Goji's middleware, source:
-// https://github.com/zenazn/goji/tree/master/web/middleware
-
-import (
- "bufio"
- "io"
- "net"
- "net/http"
-)
-
-// NewWrapResponseWriter wraps an http.ResponseWriter, returning a proxy that allows you to
-// hook into various parts of the response process.
-func NewWrapResponseWriter(w http.ResponseWriter, protoMajor int) WrapResponseWriter {
- _, fl := w.(http.Flusher)
-
- bw := basicWriter{ResponseWriter: w}
-
- if protoMajor == 2 {
- _, ps := w.(http.Pusher)
- if fl && ps {
- return &http2FancyWriter{bw}
- }
- } else {
- _, hj := w.(http.Hijacker)
- _, rf := w.(io.ReaderFrom)
- if fl && hj && rf {
- return &httpFancyWriter{bw}
- }
- if fl && hj {
- return &flushHijackWriter{bw}
- }
- if hj {
- return &hijackWriter{bw}
- }
- }
-
- if fl {
- return &flushWriter{bw}
- }
-
- return &bw
-}
-
-// WrapResponseWriter is a proxy around an http.ResponseWriter that allows you to hook
-// into various parts of the response process.
-type WrapResponseWriter interface {
- http.ResponseWriter
- // Status returns the HTTP status of the request, or 0 if one has not
- // yet been sent.
- Status() int
- // BytesWritten returns the total number of bytes sent to the client.
- BytesWritten() int
- // Tee causes the response body to be written to the given io.Writer in
- // addition to proxying the writes through. Only one io.Writer can be
- // tee'd to at once: setting a second one will overwrite the first.
- // Writes will be sent to the proxy before being written to this
- // io.Writer. It is illegal for the tee'd writer to be modified
- // concurrently with writes.
- Tee(io.Writer)
- // Unwrap returns the original proxied target.
- Unwrap() http.ResponseWriter
-}
-
-// basicWriter wraps a http.ResponseWriter that implements the minimal
-// http.ResponseWriter interface.
-type basicWriter struct {
- http.ResponseWriter
- wroteHeader bool
- code int
- bytes int
- tee io.Writer
-}
-
-func (b *basicWriter) WriteHeader(code int) {
- if !b.wroteHeader {
- b.code = code
- b.wroteHeader = true
- b.ResponseWriter.WriteHeader(code)
- }
-}
-
-func (b *basicWriter) Write(buf []byte) (int, error) {
- b.maybeWriteHeader()
- n, err := b.ResponseWriter.Write(buf)
- if b.tee != nil {
- _, err2 := b.tee.Write(buf[:n])
- // Prefer errors generated by the proxied writer.
- if err == nil {
- err = err2
- }
- }
- b.bytes += n
- return n, err
-}
-
-func (b *basicWriter) maybeWriteHeader() {
- if !b.wroteHeader {
- b.WriteHeader(http.StatusOK)
- }
-}
-
-func (b *basicWriter) Status() int {
- return b.code
-}
-
-func (b *basicWriter) BytesWritten() int {
- return b.bytes
-}
-
-func (b *basicWriter) Tee(w io.Writer) {
- b.tee = w
-}
-
-func (b *basicWriter) Unwrap() http.ResponseWriter {
- return b.ResponseWriter
-}
-
-// flushWriter ...
-type flushWriter struct {
- basicWriter
-}
-
-func (f *flushWriter) Flush() {
- f.wroteHeader = true
- fl := f.basicWriter.ResponseWriter.(http.Flusher)
- fl.Flush()
-}
-
-var _ http.Flusher = &flushWriter{}
-
-// hijackWriter ...
-type hijackWriter struct {
- basicWriter
-}
-
-func (f *hijackWriter) Hijack() (net.Conn, *bufio.ReadWriter, error) {
- hj := f.basicWriter.ResponseWriter.(http.Hijacker)
- return hj.Hijack()
-}
-
-var _ http.Hijacker = &hijackWriter{}
-
-// flushHijackWriter ...
-type flushHijackWriter struct {
- basicWriter
-}
-
-func (f *flushHijackWriter) Flush() {
- f.wroteHeader = true
- fl := f.basicWriter.ResponseWriter.(http.Flusher)
- fl.Flush()
-}
-
-func (f *flushHijackWriter) Hijack() (net.Conn, *bufio.ReadWriter, error) {
- hj := f.basicWriter.ResponseWriter.(http.Hijacker)
- return hj.Hijack()
-}
-
-var _ http.Flusher = &flushHijackWriter{}
-var _ http.Hijacker = &flushHijackWriter{}
-
-// httpFancyWriter is a HTTP writer that additionally satisfies
-// http.Flusher, http.Hijacker, and io.ReaderFrom. It exists for the common case
-// of wrapping the http.ResponseWriter that package http gives you, in order to
-// make the proxied object support the full method set of the proxied object.
-type httpFancyWriter struct {
- basicWriter
-}
-
-func (f *httpFancyWriter) Flush() {
- f.wroteHeader = true
- fl := f.basicWriter.ResponseWriter.(http.Flusher)
- fl.Flush()
-}
-
-func (f *httpFancyWriter) Hijack() (net.Conn, *bufio.ReadWriter, error) {
- hj := f.basicWriter.ResponseWriter.(http.Hijacker)
- return hj.Hijack()
-}
-
-func (f *http2FancyWriter) Push(target string, opts *http.PushOptions) error {
- return f.basicWriter.ResponseWriter.(http.Pusher).Push(target, opts)
-}
-
-func (f *httpFancyWriter) ReadFrom(r io.Reader) (int64, error) {
- if f.basicWriter.tee != nil {
- n, err := io.Copy(&f.basicWriter, r)
- f.basicWriter.bytes += int(n)
- return n, err
- }
- rf := f.basicWriter.ResponseWriter.(io.ReaderFrom)
- f.basicWriter.maybeWriteHeader()
- n, err := rf.ReadFrom(r)
- f.basicWriter.bytes += int(n)
- return n, err
-}
-
-var _ http.Flusher = &httpFancyWriter{}
-var _ http.Hijacker = &httpFancyWriter{}
-var _ http.Pusher = &http2FancyWriter{}
-var _ io.ReaderFrom = &httpFancyWriter{}
-
-// http2FancyWriter is a HTTP2 writer that additionally satisfies
-// http.Flusher, and io.ReaderFrom. It exists for the common case
-// of wrapping the http.ResponseWriter that package http gives you, in order to
-// make the proxied object support the full method set of the proxied object.
-type http2FancyWriter struct {
- basicWriter
-}
-
-func (f *http2FancyWriter) Flush() {
- f.wroteHeader = true
- fl := f.basicWriter.ResponseWriter.(http.Flusher)
- fl.Flush()
-}
-
-var _ http.Flusher = &http2FancyWriter{}
diff --git a/vendor/github.com/go-chi/chi/v5/mux.go b/vendor/github.com/go-chi/chi/v5/mux.go
deleted file mode 100644
index 6dc1904..0000000
--- a/vendor/github.com/go-chi/chi/v5/mux.go
+++ /dev/null
@@ -1,508 +0,0 @@
-package chi
-
-import (
- "context"
- "fmt"
- "net/http"
- "strings"
- "sync"
-)
-
-var _ Router = &Mux{}
-
-// Mux is a simple HTTP route multiplexer that parses a request path,
-// records any URL params, and executes an end handler. It implements
-// the http.Handler interface and is friendly with the standard library.
-//
-// Mux is designed to be fast, minimal and offer a powerful API for building
-// modular and composable HTTP services with a large set of handlers. It's
-// particularly useful for writing large REST API services that break a handler
-// into many smaller parts composed of middlewares and end handlers.
-type Mux struct {
- // The computed mux handler made of the chained middleware stack and
- // the tree router
- handler http.Handler
-
- // The radix trie router
- tree *node
-
- // Custom method not allowed handler
- methodNotAllowedHandler http.HandlerFunc
-
- // A reference to the parent mux used by subrouters when mounting
- // to a parent mux
- parent *Mux
-
- // Routing context pool
- pool *sync.Pool
-
- // Custom route not found handler
- notFoundHandler http.HandlerFunc
-
- // The middleware stack
- middlewares []func(http.Handler) http.Handler
-
- // Controls the behaviour of middleware chain generation when a mux
- // is registered as an inline group inside another mux.
- inline bool
-}
-
-// NewMux returns a newly initialized Mux object that implements the Router
-// interface.
-func NewMux() *Mux {
- mux := &Mux{tree: &node{}, pool: &sync.Pool{}}
- mux.pool.New = func() interface{} {
- return NewRouteContext()
- }
- return mux
-}
-
-// ServeHTTP is the single method of the http.Handler interface that makes
-// Mux interoperable with the standard library. It uses a sync.Pool to get and
-// reuse routing contexts for each request.
-func (mx *Mux) ServeHTTP(w http.ResponseWriter, r *http.Request) {
- // Ensure the mux has some routes defined on the mux
- if mx.handler == nil {
- mx.NotFoundHandler().ServeHTTP(w, r)
- return
- }
-
- // Check if a routing context already exists from a parent router.
- rctx, _ := r.Context().Value(RouteCtxKey).(*Context)
- if rctx != nil {
- mx.handler.ServeHTTP(w, r)
- return
- }
-
- // Fetch a RouteContext object from the sync pool, and call the computed
- // mx.handler that is comprised of mx.middlewares + mx.routeHTTP.
- // Once the request is finished, reset the routing context and put it back
- // into the pool for reuse from another request.
- rctx = mx.pool.Get().(*Context)
- rctx.Reset()
- rctx.Routes = mx
- rctx.parentCtx = r.Context()
-
- // NOTE: r.WithContext() causes 2 allocations and context.WithValue() causes 1 allocation
- r = r.WithContext(context.WithValue(r.Context(), RouteCtxKey, rctx))
-
- // Serve the request and once its done, put the request context back in the sync pool
- mx.handler.ServeHTTP(w, r)
- mx.pool.Put(rctx)
-}
-
-// Use appends a middleware handler to the Mux middleware stack.
-//
-// The middleware stack for any Mux will execute before searching for a matching
-// route to a specific handler, which provides opportunity to respond early,
-// change the course of the request execution, or set request-scoped values for
-// the next http.Handler.
-func (mx *Mux) Use(middlewares ...func(http.Handler) http.Handler) {
- if mx.handler != nil {
- panic("chi: all middlewares must be defined before routes on a mux")
- }
- mx.middlewares = append(mx.middlewares, middlewares...)
-}
-
-// Handle adds the route `pattern` that matches any http method to
-// execute the `handler` http.Handler.
-func (mx *Mux) Handle(pattern string, handler http.Handler) {
- parts := strings.SplitN(pattern, " ", 2)
- if len(parts) == 2 {
- mx.Method(parts[0], parts[1], handler)
- return
- }
-
- mx.handle(mALL, pattern, handler)
-}
-
-// HandleFunc adds the route `pattern` that matches any http method to
-// execute the `handlerFn` http.HandlerFunc.
-func (mx *Mux) HandleFunc(pattern string, handlerFn http.HandlerFunc) {
- parts := strings.SplitN(pattern, " ", 2)
- if len(parts) == 2 {
- mx.Method(parts[0], parts[1], handlerFn)
- return
- }
-
- mx.handle(mALL, pattern, handlerFn)
-}
-
-// Method adds the route `pattern` that matches `method` http method to
-// execute the `handler` http.Handler.
-func (mx *Mux) Method(method, pattern string, handler http.Handler) {
- m, ok := methodMap[strings.ToUpper(method)]
- if !ok {
- panic(fmt.Sprintf("chi: '%s' http method is not supported.", method))
- }
- mx.handle(m, pattern, handler)
-}
-
-// MethodFunc adds the route `pattern` that matches `method` http method to
-// execute the `handlerFn` http.HandlerFunc.
-func (mx *Mux) MethodFunc(method, pattern string, handlerFn http.HandlerFunc) {
- mx.Method(method, pattern, handlerFn)
-}
-
-// Connect adds the route `pattern` that matches a CONNECT http method to
-// execute the `handlerFn` http.HandlerFunc.
-func (mx *Mux) Connect(pattern string, handlerFn http.HandlerFunc) {
- mx.handle(mCONNECT, pattern, handlerFn)
-}
-
-// Delete adds the route `pattern` that matches a DELETE http method to
-// execute the `handlerFn` http.HandlerFunc.
-func (mx *Mux) Delete(pattern string, handlerFn http.HandlerFunc) {
- mx.handle(mDELETE, pattern, handlerFn)
-}
-
-// Get adds the route `pattern` that matches a GET http method to
-// execute the `handlerFn` http.HandlerFunc.
-func (mx *Mux) Get(pattern string, handlerFn http.HandlerFunc) {
- mx.handle(mGET, pattern, handlerFn)
-}
-
-// Head adds the route `pattern` that matches a HEAD http method to
-// execute the `handlerFn` http.HandlerFunc.
-func (mx *Mux) Head(pattern string, handlerFn http.HandlerFunc) {
- mx.handle(mHEAD, pattern, handlerFn)
-}
-
-// Options adds the route `pattern` that matches an OPTIONS http method to
-// execute the `handlerFn` http.HandlerFunc.
-func (mx *Mux) Options(pattern string, handlerFn http.HandlerFunc) {
- mx.handle(mOPTIONS, pattern, handlerFn)
-}
-
-// Patch adds the route `pattern` that matches a PATCH http method to
-// execute the `handlerFn` http.HandlerFunc.
-func (mx *Mux) Patch(pattern string, handlerFn http.HandlerFunc) {
- mx.handle(mPATCH, pattern, handlerFn)
-}
-
-// Post adds the route `pattern` that matches a POST http method to
-// execute the `handlerFn` http.HandlerFunc.
-func (mx *Mux) Post(pattern string, handlerFn http.HandlerFunc) {
- mx.handle(mPOST, pattern, handlerFn)
-}
-
-// Put adds the route `pattern` that matches a PUT http method to
-// execute the `handlerFn` http.HandlerFunc.
-func (mx *Mux) Put(pattern string, handlerFn http.HandlerFunc) {
- mx.handle(mPUT, pattern, handlerFn)
-}
-
-// Trace adds the route `pattern` that matches a TRACE http method to
-// execute the `handlerFn` http.HandlerFunc.
-func (mx *Mux) Trace(pattern string, handlerFn http.HandlerFunc) {
- mx.handle(mTRACE, pattern, handlerFn)
-}
-
-// NotFound sets a custom http.HandlerFunc for routing paths that could
-// not be found. The default 404 handler is `http.NotFound`.
-func (mx *Mux) NotFound(handlerFn http.HandlerFunc) {
- // Build NotFound handler chain
- m := mx
- hFn := handlerFn
- if mx.inline && mx.parent != nil {
- m = mx.parent
- hFn = Chain(mx.middlewares...).HandlerFunc(hFn).ServeHTTP
- }
-
- // Update the notFoundHandler from this point forward
- m.notFoundHandler = hFn
- m.updateSubRoutes(func(subMux *Mux) {
- if subMux.notFoundHandler == nil {
- subMux.NotFound(hFn)
- }
- })
-}
-
-// MethodNotAllowed sets a custom http.HandlerFunc for routing paths where the
-// method is unresolved. The default handler returns a 405 with an empty body.
-func (mx *Mux) MethodNotAllowed(handlerFn http.HandlerFunc) {
- // Build MethodNotAllowed handler chain
- m := mx
- hFn := handlerFn
- if mx.inline && mx.parent != nil {
- m = mx.parent
- hFn = Chain(mx.middlewares...).HandlerFunc(hFn).ServeHTTP
- }
-
- // Update the methodNotAllowedHandler from this point forward
- m.methodNotAllowedHandler = hFn
- m.updateSubRoutes(func(subMux *Mux) {
- if subMux.methodNotAllowedHandler == nil {
- subMux.MethodNotAllowed(hFn)
- }
- })
-}
-
-// With adds inline middlewares for an endpoint handler.
-func (mx *Mux) With(middlewares ...func(http.Handler) http.Handler) Router {
- // Similarly as in handle(), we must build the mux handler once additional
- // middleware registration isn't allowed for this stack, like now.
- if !mx.inline && mx.handler == nil {
- mx.updateRouteHandler()
- }
-
- // Copy middlewares from parent inline muxs
- var mws Middlewares
- if mx.inline {
- mws = make(Middlewares, len(mx.middlewares))
- copy(mws, mx.middlewares)
- }
- mws = append(mws, middlewares...)
-
- im := &Mux{
- pool: mx.pool, inline: true, parent: mx, tree: mx.tree, middlewares: mws,
- notFoundHandler: mx.notFoundHandler, methodNotAllowedHandler: mx.methodNotAllowedHandler,
- }
-
- return im
-}
-
-// Group creates a new inline-Mux with a copy of middleware stack. It's useful
-// for a group of handlers along the same routing path that use an additional
-// set of middlewares. See _examples/.
-func (mx *Mux) Group(fn func(r Router)) Router {
- im := mx.With()
- if fn != nil {
- fn(im)
- }
- return im
-}
-
-// Route creates a new Mux and mounts it along the `pattern` as a subrouter.
-// Effectively, this is a short-hand call to Mount. See _examples/.
-func (mx *Mux) Route(pattern string, fn func(r Router)) Router {
- if fn == nil {
- panic(fmt.Sprintf("chi: attempting to Route() a nil subrouter on '%s'", pattern))
- }
- subRouter := NewRouter()
- fn(subRouter)
- mx.Mount(pattern, subRouter)
- return subRouter
-}
-
-// Mount attaches another http.Handler or chi Router as a subrouter along a routing
-// path. It's very useful to split up a large API as many independent routers and
-// compose them as a single service using Mount. See _examples/.
-//
-// Note that Mount() simply sets a wildcard along the `pattern` that will continue
-// routing at the `handler`, which in most cases is another chi.Router. As a result,
-// if you define two Mount() routes on the exact same pattern the mount will panic.
-func (mx *Mux) Mount(pattern string, handler http.Handler) {
- if handler == nil {
- panic(fmt.Sprintf("chi: attempting to Mount() a nil handler on '%s'", pattern))
- }
-
- // Provide runtime safety for ensuring a pattern isn't mounted on an existing
- // routing pattern.
- if mx.tree.findPattern(pattern+"*") || mx.tree.findPattern(pattern+"/*") {
- panic(fmt.Sprintf("chi: attempting to Mount() a handler on an existing path, '%s'", pattern))
- }
-
- // Assign sub-Router's with the parent not found & method not allowed handler if not specified.
- subr, ok := handler.(*Mux)
- if ok && subr.notFoundHandler == nil && mx.notFoundHandler != nil {
- subr.NotFound(mx.notFoundHandler)
- }
- if ok && subr.methodNotAllowedHandler == nil && mx.methodNotAllowedHandler != nil {
- subr.MethodNotAllowed(mx.methodNotAllowedHandler)
- }
-
- mountHandler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
- rctx := RouteContext(r.Context())
-
- // shift the url path past the previous subrouter
- rctx.RoutePath = mx.nextRoutePath(rctx)
-
- // reset the wildcard URLParam which connects the subrouter
- n := len(rctx.URLParams.Keys) - 1
- if n >= 0 && rctx.URLParams.Keys[n] == "*" && len(rctx.URLParams.Values) > n {
- rctx.URLParams.Values[n] = ""
- }
-
- handler.ServeHTTP(w, r)
- })
-
- if pattern == "" || pattern[len(pattern)-1] != '/' {
- mx.handle(mALL|mSTUB, pattern, mountHandler)
- mx.handle(mALL|mSTUB, pattern+"/", mountHandler)
- pattern += "/"
- }
-
- method := mALL
- subroutes, _ := handler.(Routes)
- if subroutes != nil {
- method |= mSTUB
- }
- n := mx.handle(method, pattern+"*", mountHandler)
-
- if subroutes != nil {
- n.subroutes = subroutes
- }
-}
-
-// Routes returns a slice of routing information from the tree,
-// useful for traversing available routes of a router.
-func (mx *Mux) Routes() []Route {
- return mx.tree.routes()
-}
-
-// Middlewares returns a slice of middleware handler functions.
-func (mx *Mux) Middlewares() Middlewares {
- return mx.middlewares
-}
-
-// Match searches the routing tree for a handler that matches the method/path.
-// It's similar to routing a http request, but without executing the handler
-// thereafter.
-//
-// Note: the *Context state is updated during execution, so manage
-// the state carefully or make a NewRouteContext().
-func (mx *Mux) Match(rctx *Context, method, path string) bool {
- m, ok := methodMap[method]
- if !ok {
- return false
- }
-
- node, _, h := mx.tree.FindRoute(rctx, m, path)
-
- if node != nil && node.subroutes != nil {
- rctx.RoutePath = mx.nextRoutePath(rctx)
- return node.subroutes.Match(rctx, method, rctx.RoutePath)
- }
-
- return h != nil
-}
-
-// NotFoundHandler returns the default Mux 404 responder whenever a route
-// cannot be found.
-func (mx *Mux) NotFoundHandler() http.HandlerFunc {
- if mx.notFoundHandler != nil {
- return mx.notFoundHandler
- }
- return http.NotFound
-}
-
-// MethodNotAllowedHandler returns the default Mux 405 responder whenever
-// a method cannot be resolved for a route.
-func (mx *Mux) MethodNotAllowedHandler(methodsAllowed ...methodTyp) http.HandlerFunc {
- if mx.methodNotAllowedHandler != nil {
- return mx.methodNotAllowedHandler
- }
- return methodNotAllowedHandler(methodsAllowed...)
-}
-
-// handle registers a http.Handler in the routing tree for a particular http method
-// and routing pattern.
-func (mx *Mux) handle(method methodTyp, pattern string, handler http.Handler) *node {
- if len(pattern) == 0 || pattern[0] != '/' {
- panic(fmt.Sprintf("chi: routing pattern must begin with '/' in '%s'", pattern))
- }
-
- // Build the computed routing handler for this routing pattern.
- if !mx.inline && mx.handler == nil {
- mx.updateRouteHandler()
- }
-
- // Build endpoint handler with inline middlewares for the route
- var h http.Handler
- if mx.inline {
- mx.handler = http.HandlerFunc(mx.routeHTTP)
- h = Chain(mx.middlewares...).Handler(handler)
- } else {
- h = handler
- }
-
- // Add the endpoint to the tree and return the node
- return mx.tree.InsertRoute(method, pattern, h)
-}
-
-// routeHTTP routes a http.Request through the Mux routing tree to serve
-// the matching handler for a particular http method.
-func (mx *Mux) routeHTTP(w http.ResponseWriter, r *http.Request) {
- // Grab the route context object
- rctx := r.Context().Value(RouteCtxKey).(*Context)
-
- // The request routing path
- routePath := rctx.RoutePath
- if routePath == "" {
- if r.URL.RawPath != "" {
- routePath = r.URL.RawPath
- } else {
- routePath = r.URL.Path
- }
- if routePath == "" {
- routePath = "/"
- }
- }
-
- // Check if method is supported by chi
- if rctx.RouteMethod == "" {
- rctx.RouteMethod = r.Method
- }
- method, ok := methodMap[rctx.RouteMethod]
- if !ok {
- mx.MethodNotAllowedHandler().ServeHTTP(w, r)
- return
- }
-
- // Find the route
- if _, _, h := mx.tree.FindRoute(rctx, method, routePath); h != nil {
- if supportsPathValue {
- setPathValue(rctx, r)
- }
-
- h.ServeHTTP(w, r)
- return
- }
- if rctx.methodNotAllowed {
- mx.MethodNotAllowedHandler(rctx.methodsAllowed...).ServeHTTP(w, r)
- } else {
- mx.NotFoundHandler().ServeHTTP(w, r)
- }
-}
-
-func (mx *Mux) nextRoutePath(rctx *Context) string {
- routePath := "/"
- nx := len(rctx.routeParams.Keys) - 1 // index of last param in list
- if nx >= 0 && rctx.routeParams.Keys[nx] == "*" && len(rctx.routeParams.Values) > nx {
- routePath = "/" + rctx.routeParams.Values[nx]
- }
- return routePath
-}
-
-// Recursively update data on child routers.
-func (mx *Mux) updateSubRoutes(fn func(subMux *Mux)) {
- for _, r := range mx.tree.routes() {
- subMux, ok := r.SubRoutes.(*Mux)
- if !ok {
- continue
- }
- fn(subMux)
- }
-}
-
-// updateRouteHandler builds the single mux handler that is a chain of the middleware
-// stack, as defined by calls to Use(), and the tree router (Mux) itself. After this
-// point, no other middlewares can be registered on this Mux's stack. But you can still
-// compose additional middlewares via Group()'s or using a chained middleware handler.
-func (mx *Mux) updateRouteHandler() {
- mx.handler = chain(mx.middlewares, http.HandlerFunc(mx.routeHTTP))
-}
-
-// methodNotAllowedHandler is a helper function to respond with a 405,
-// method not allowed. It sets the Allow header with the list of allowed
-// methods for the route.
-func methodNotAllowedHandler(methodsAllowed ...methodTyp) func(w http.ResponseWriter, r *http.Request) {
- return func(w http.ResponseWriter, r *http.Request) {
- for _, m := range methodsAllowed {
- w.Header().Add("Allow", reverseMethodMap[m])
- }
- w.WriteHeader(405)
- w.Write(nil)
- }
-}
diff --git a/vendor/github.com/go-chi/chi/v5/path_value.go b/vendor/github.com/go-chi/chi/v5/path_value.go
deleted file mode 100644
index 7e78171..0000000
--- a/vendor/github.com/go-chi/chi/v5/path_value.go
+++ /dev/null
@@ -1,20 +0,0 @@
-//go:build go1.22
-// +build go1.22
-
-package chi
-
-import "net/http"
-
-// supportsPathValue is true if the Go version is 1.22 and above.
-//
-// If this is true, `net/http.Request` has methods `SetPathValue` and `PathValue`.
-const supportsPathValue = true
-
-// setPathValue sets the path values in the Request value
-// based on the provided request context.
-func setPathValue(rctx *Context, r *http.Request) {
- for i, key := range rctx.URLParams.Keys {
- value := rctx.URLParams.Values[i]
- r.SetPathValue(key, value)
- }
-}
diff --git a/vendor/github.com/go-chi/chi/v5/path_value_fallback.go b/vendor/github.com/go-chi/chi/v5/path_value_fallback.go
deleted file mode 100644
index f551781..0000000
--- a/vendor/github.com/go-chi/chi/v5/path_value_fallback.go
+++ /dev/null
@@ -1,19 +0,0 @@
-//go:build !go1.22
-// +build !go1.22
-
-package chi
-
-import "net/http"
-
-// supportsPathValue is true if the Go version is 1.22 and above.
-//
-// If this is true, `net/http.Request` has methods `SetPathValue` and `PathValue`.
-const supportsPathValue = false
-
-// setPathValue sets the path values in the Request value
-// based on the provided request context.
-//
-// setPathValue is only supported in Go 1.22 and above so
-// this is just a blank function so that it compiles.
-func setPathValue(rctx *Context, r *http.Request) {
-}
diff --git a/vendor/github.com/go-chi/chi/v5/tree.go b/vendor/github.com/go-chi/chi/v5/tree.go
deleted file mode 100644
index c7d3bc5..0000000
--- a/vendor/github.com/go-chi/chi/v5/tree.go
+++ /dev/null
@@ -1,892 +0,0 @@
-package chi
-
-// Radix tree implementation below is a based on the original work by
-// Armon Dadgar in https://github.com/armon/go-radix/blob/master/radix.go
-// (MIT licensed). It's been heavily modified for use as a HTTP routing tree.
-
-import (
- "fmt"
- "net/http"
- "regexp"
- "sort"
- "strconv"
- "strings"
-)
-
-type methodTyp uint
-
-const (
- mSTUB methodTyp = 1 << iota
- mCONNECT
- mDELETE
- mGET
- mHEAD
- mOPTIONS
- mPATCH
- mPOST
- mPUT
- mTRACE
-)
-
-var mALL = mCONNECT | mDELETE | mGET | mHEAD |
- mOPTIONS | mPATCH | mPOST | mPUT | mTRACE
-
-var methodMap = map[string]methodTyp{
- http.MethodConnect: mCONNECT,
- http.MethodDelete: mDELETE,
- http.MethodGet: mGET,
- http.MethodHead: mHEAD,
- http.MethodOptions: mOPTIONS,
- http.MethodPatch: mPATCH,
- http.MethodPost: mPOST,
- http.MethodPut: mPUT,
- http.MethodTrace: mTRACE,
-}
-
-var reverseMethodMap = map[methodTyp]string{
- mCONNECT: http.MethodConnect,
- mDELETE: http.MethodDelete,
- mGET: http.MethodGet,
- mHEAD: http.MethodHead,
- mOPTIONS: http.MethodOptions,
- mPATCH: http.MethodPatch,
- mPOST: http.MethodPost,
- mPUT: http.MethodPut,
- mTRACE: http.MethodTrace,
-}
-
-// RegisterMethod adds support for custom HTTP method handlers, available
-// via Router#Method and Router#MethodFunc
-func RegisterMethod(method string) {
- if method == "" {
- return
- }
- method = strings.ToUpper(method)
- if _, ok := methodMap[method]; ok {
- return
- }
- n := len(methodMap)
- if n > strconv.IntSize-2 {
- panic(fmt.Sprintf("chi: max number of methods reached (%d)", strconv.IntSize))
- }
- mt := methodTyp(2 << n)
- methodMap[method] = mt
- mALL |= mt
-}
-
-type nodeTyp uint8
-
-const (
- ntStatic nodeTyp = iota // /home
- ntRegexp // /{id:[0-9]+}
- ntParam // /{user}
- ntCatchAll // /api/v1/*
-)
-
-type node struct {
- // subroutes on the leaf node
- subroutes Routes
-
- // regexp matcher for regexp nodes
- rex *regexp.Regexp
-
- // HTTP handler endpoints on the leaf node
- endpoints endpoints
-
- // prefix is the common prefix we ignore
- prefix string
-
- // child nodes should be stored in-order for iteration,
- // in groups of the node type.
- children [ntCatchAll + 1]nodes
-
- // first byte of the child prefix
- tail byte
-
- // node type: static, regexp, param, catchAll
- typ nodeTyp
-
- // first byte of the prefix
- label byte
-}
-
-// endpoints is a mapping of http method constants to handlers
-// for a given route.
-type endpoints map[methodTyp]*endpoint
-
-type endpoint struct {
- // endpoint handler
- handler http.Handler
-
- // pattern is the routing pattern for handler nodes
- pattern string
-
- // parameter keys recorded on handler nodes
- paramKeys []string
-}
-
-func (s endpoints) Value(method methodTyp) *endpoint {
- mh, ok := s[method]
- if !ok {
- mh = &endpoint{}
- s[method] = mh
- }
- return mh
-}
-
-func (n *node) InsertRoute(method methodTyp, pattern string, handler http.Handler) *node {
- var parent *node
- search := pattern
-
- for {
- // Handle key exhaustion
- if len(search) == 0 {
- // Insert or update the node's leaf handler
- n.setEndpoint(method, handler, pattern)
- return n
- }
-
- // We're going to be searching for a wild node next,
- // in this case, we need to get the tail
- var label = search[0]
- var segTail byte
- var segEndIdx int
- var segTyp nodeTyp
- var segRexpat string
- if label == '{' || label == '*' {
- segTyp, _, segRexpat, segTail, _, segEndIdx = patNextSegment(search)
- }
-
- var prefix string
- if segTyp == ntRegexp {
- prefix = segRexpat
- }
-
- // Look for the edge to attach to
- parent = n
- n = n.getEdge(segTyp, label, segTail, prefix)
-
- // No edge, create one
- if n == nil {
- child := &node{label: label, tail: segTail, prefix: search}
- hn := parent.addChild(child, search)
- hn.setEndpoint(method, handler, pattern)
-
- return hn
- }
-
- // Found an edge to match the pattern
-
- if n.typ > ntStatic {
- // We found a param node, trim the param from the search path and continue.
- // This param/wild pattern segment would already be on the tree from a previous
- // call to addChild when creating a new node.
- search = search[segEndIdx:]
- continue
- }
-
- // Static nodes fall below here.
- // Determine longest prefix of the search key on match.
- commonPrefix := longestPrefix(search, n.prefix)
- if commonPrefix == len(n.prefix) {
- // the common prefix is as long as the current node's prefix we're attempting to insert.
- // keep the search going.
- search = search[commonPrefix:]
- continue
- }
-
- // Split the node
- child := &node{
- typ: ntStatic,
- prefix: search[:commonPrefix],
- }
- parent.replaceChild(search[0], segTail, child)
-
- // Restore the existing node
- n.label = n.prefix[commonPrefix]
- n.prefix = n.prefix[commonPrefix:]
- child.addChild(n, n.prefix)
-
- // If the new key is a subset, set the method/handler on this node and finish.
- search = search[commonPrefix:]
- if len(search) == 0 {
- child.setEndpoint(method, handler, pattern)
- return child
- }
-
- // Create a new edge for the node
- subchild := &node{
- typ: ntStatic,
- label: search[0],
- prefix: search,
- }
- hn := child.addChild(subchild, search)
- hn.setEndpoint(method, handler, pattern)
- return hn
- }
-}
-
-// addChild appends the new `child` node to the tree using the `pattern` as the trie key.
-// For a URL router like chi's, we split the static, param, regexp and wildcard segments
-// into different nodes. In addition, addChild will recursively call itself until every
-// pattern segment is added to the url pattern tree as individual nodes, depending on type.
-func (n *node) addChild(child *node, prefix string) *node {
- search := prefix
-
- // handler leaf node added to the tree is the child.
- // this may be overridden later down the flow
- hn := child
-
- // Parse next segment
- segTyp, _, segRexpat, segTail, segStartIdx, segEndIdx := patNextSegment(search)
-
- // Add child depending on next up segment
- switch segTyp {
-
- case ntStatic:
- // Search prefix is all static (that is, has no params in path)
- // noop
-
- default:
- // Search prefix contains a param, regexp or wildcard
-
- if segTyp == ntRegexp {
- rex, err := regexp.Compile(segRexpat)
- if err != nil {
- panic(fmt.Sprintf("chi: invalid regexp pattern '%s' in route param", segRexpat))
- }
- child.prefix = segRexpat
- child.rex = rex
- }
-
- if segStartIdx == 0 {
- // Route starts with a param
- child.typ = segTyp
-
- if segTyp == ntCatchAll {
- segStartIdx = -1
- } else {
- segStartIdx = segEndIdx
- }
- if segStartIdx < 0 {
- segStartIdx = len(search)
- }
- child.tail = segTail // for params, we set the tail
-
- if segStartIdx != len(search) {
- // add static edge for the remaining part, split the end.
- // its not possible to have adjacent param nodes, so its certainly
- // going to be a static node next.
-
- search = search[segStartIdx:] // advance search position
-
- nn := &node{
- typ: ntStatic,
- label: search[0],
- prefix: search,
- }
- hn = child.addChild(nn, search)
- }
-
- } else if segStartIdx > 0 {
- // Route has some param
-
- // starts with a static segment
- child.typ = ntStatic
- child.prefix = search[:segStartIdx]
- child.rex = nil
-
- // add the param edge node
- search = search[segStartIdx:]
-
- nn := &node{
- typ: segTyp,
- label: search[0],
- tail: segTail,
- }
- hn = child.addChild(nn, search)
-
- }
- }
-
- n.children[child.typ] = append(n.children[child.typ], child)
- n.children[child.typ].Sort()
- return hn
-}
-
-func (n *node) replaceChild(label, tail byte, child *node) {
- for i := 0; i < len(n.children[child.typ]); i++ {
- if n.children[child.typ][i].label == label && n.children[child.typ][i].tail == tail {
- n.children[child.typ][i] = child
- n.children[child.typ][i].label = label
- n.children[child.typ][i].tail = tail
- return
- }
- }
- panic("chi: replacing missing child")
-}
-
-func (n *node) getEdge(ntyp nodeTyp, label, tail byte, prefix string) *node {
- nds := n.children[ntyp]
- for i := 0; i < len(nds); i++ {
- if nds[i].label == label && nds[i].tail == tail {
- if ntyp == ntRegexp && nds[i].prefix != prefix {
- continue
- }
- return nds[i]
- }
- }
- return nil
-}
-
-func (n *node) setEndpoint(method methodTyp, handler http.Handler, pattern string) {
- // Set the handler for the method type on the node
- if n.endpoints == nil {
- n.endpoints = make(endpoints)
- }
-
- paramKeys := patParamKeys(pattern)
-
- if method&mSTUB == mSTUB {
- n.endpoints.Value(mSTUB).handler = handler
- }
- if method&mALL == mALL {
- h := n.endpoints.Value(mALL)
- h.handler = handler
- h.pattern = pattern
- h.paramKeys = paramKeys
- for _, m := range methodMap {
- h := n.endpoints.Value(m)
- h.handler = handler
- h.pattern = pattern
- h.paramKeys = paramKeys
- }
- } else {
- h := n.endpoints.Value(method)
- h.handler = handler
- h.pattern = pattern
- h.paramKeys = paramKeys
- }
-}
-
-func (n *node) FindRoute(rctx *Context, method methodTyp, path string) (*node, endpoints, http.Handler) {
- // Reset the context routing pattern and params
- rctx.routePattern = ""
- rctx.routeParams.Keys = rctx.routeParams.Keys[:0]
- rctx.routeParams.Values = rctx.routeParams.Values[:0]
-
- // Find the routing handlers for the path
- rn := n.findRoute(rctx, method, path)
- if rn == nil {
- return nil, nil, nil
- }
-
- // Record the routing params in the request lifecycle
- rctx.URLParams.Keys = append(rctx.URLParams.Keys, rctx.routeParams.Keys...)
- rctx.URLParams.Values = append(rctx.URLParams.Values, rctx.routeParams.Values...)
-
- // Record the routing pattern in the request lifecycle
- if rn.endpoints[method].pattern != "" {
- rctx.routePattern = rn.endpoints[method].pattern
- rctx.RoutePatterns = append(rctx.RoutePatterns, rctx.routePattern)
- }
-
- return rn, rn.endpoints, rn.endpoints[method].handler
-}
-
-// Recursive edge traversal by checking all nodeTyp groups along the way.
-// It's like searching through a multi-dimensional radix trie.
-func (n *node) findRoute(rctx *Context, method methodTyp, path string) *node {
- nn := n
- search := path
-
- for t, nds := range nn.children {
- ntyp := nodeTyp(t)
- if len(nds) == 0 {
- continue
- }
-
- var xn *node
- xsearch := search
-
- var label byte
- if search != "" {
- label = search[0]
- }
-
- switch ntyp {
- case ntStatic:
- xn = nds.findEdge(label)
- if xn == nil || !strings.HasPrefix(xsearch, xn.prefix) {
- continue
- }
- xsearch = xsearch[len(xn.prefix):]
-
- case ntParam, ntRegexp:
- // short-circuit and return no matching route for empty param values
- if xsearch == "" {
- continue
- }
-
- // serially loop through each node grouped by the tail delimiter
- for idx := 0; idx < len(nds); idx++ {
- xn = nds[idx]
-
- // label for param nodes is the delimiter byte
- p := strings.IndexByte(xsearch, xn.tail)
-
- if p < 0 {
- if xn.tail == '/' {
- p = len(xsearch)
- } else {
- continue
- }
- } else if ntyp == ntRegexp && p == 0 {
- continue
- }
-
- if ntyp == ntRegexp && xn.rex != nil {
- if !xn.rex.MatchString(xsearch[:p]) {
- continue
- }
- } else if strings.IndexByte(xsearch[:p], '/') != -1 {
- // avoid a match across path segments
- continue
- }
-
- prevlen := len(rctx.routeParams.Values)
- rctx.routeParams.Values = append(rctx.routeParams.Values, xsearch[:p])
- xsearch = xsearch[p:]
-
- if len(xsearch) == 0 {
- if xn.isLeaf() {
- h := xn.endpoints[method]
- if h != nil && h.handler != nil {
- rctx.routeParams.Keys = append(rctx.routeParams.Keys, h.paramKeys...)
- return xn
- }
-
- for endpoints := range xn.endpoints {
- if endpoints == mALL || endpoints == mSTUB {
- continue
- }
- rctx.methodsAllowed = append(rctx.methodsAllowed, endpoints)
- }
-
- // flag that the routing context found a route, but not a corresponding
- // supported method
- rctx.methodNotAllowed = true
- }
- }
-
- // recursively find the next node on this branch
- fin := xn.findRoute(rctx, method, xsearch)
- if fin != nil {
- return fin
- }
-
- // not found on this branch, reset vars
- rctx.routeParams.Values = rctx.routeParams.Values[:prevlen]
- xsearch = search
- }
-
- rctx.routeParams.Values = append(rctx.routeParams.Values, "")
-
- default:
- // catch-all nodes
- rctx.routeParams.Values = append(rctx.routeParams.Values, search)
- xn = nds[0]
- xsearch = ""
- }
-
- if xn == nil {
- continue
- }
-
- // did we find it yet?
- if len(xsearch) == 0 {
- if xn.isLeaf() {
- h := xn.endpoints[method]
- if h != nil && h.handler != nil {
- rctx.routeParams.Keys = append(rctx.routeParams.Keys, h.paramKeys...)
- return xn
- }
-
- for endpoints := range xn.endpoints {
- if endpoints == mALL || endpoints == mSTUB {
- continue
- }
- rctx.methodsAllowed = append(rctx.methodsAllowed, endpoints)
- }
-
- // flag that the routing context found a route, but not a corresponding
- // supported method
- rctx.methodNotAllowed = true
- }
- }
-
- // recursively find the next node..
- fin := xn.findRoute(rctx, method, xsearch)
- if fin != nil {
- return fin
- }
-
- // Did not find final handler, let's remove the param here if it was set
- if xn.typ > ntStatic {
- if len(rctx.routeParams.Values) > 0 {
- rctx.routeParams.Values = rctx.routeParams.Values[:len(rctx.routeParams.Values)-1]
- }
- }
-
- }
-
- return nil
-}
-
-func (n *node) findEdge(ntyp nodeTyp, label byte) *node {
- nds := n.children[ntyp]
- num := len(nds)
- idx := 0
-
- switch ntyp {
- case ntStatic, ntParam, ntRegexp:
- i, j := 0, num-1
- for i <= j {
- idx = i + (j-i)/2
- if label > nds[idx].label {
- i = idx + 1
- } else if label < nds[idx].label {
- j = idx - 1
- } else {
- i = num // breaks cond
- }
- }
- if nds[idx].label != label {
- return nil
- }
- return nds[idx]
-
- default: // catch all
- return nds[idx]
- }
-}
-
-func (n *node) isLeaf() bool {
- return n.endpoints != nil
-}
-
-func (n *node) findPattern(pattern string) bool {
- nn := n
- for _, nds := range nn.children {
- if len(nds) == 0 {
- continue
- }
-
- n = nn.findEdge(nds[0].typ, pattern[0])
- if n == nil {
- continue
- }
-
- var idx int
- var xpattern string
-
- switch n.typ {
- case ntStatic:
- idx = longestPrefix(pattern, n.prefix)
- if idx < len(n.prefix) {
- continue
- }
-
- case ntParam, ntRegexp:
- idx = strings.IndexByte(pattern, '}') + 1
-
- case ntCatchAll:
- idx = longestPrefix(pattern, "*")
-
- default:
- panic("chi: unknown node type")
- }
-
- xpattern = pattern[idx:]
- if len(xpattern) == 0 {
- return true
- }
-
- return n.findPattern(xpattern)
- }
- return false
-}
-
-func (n *node) routes() []Route {
- rts := []Route{}
-
- n.walk(func(eps endpoints, subroutes Routes) bool {
- if eps[mSTUB] != nil && eps[mSTUB].handler != nil && subroutes == nil {
- return false
- }
-
- // Group methodHandlers by unique patterns
- pats := make(map[string]endpoints)
-
- for mt, h := range eps {
- if h.pattern == "" {
- continue
- }
- p, ok := pats[h.pattern]
- if !ok {
- p = endpoints{}
- pats[h.pattern] = p
- }
- p[mt] = h
- }
-
- for p, mh := range pats {
- hs := make(map[string]http.Handler)
- if mh[mALL] != nil && mh[mALL].handler != nil {
- hs["*"] = mh[mALL].handler
- }
-
- for mt, h := range mh {
- if h.handler == nil {
- continue
- }
- m := methodTypString(mt)
- if m == "" {
- continue
- }
- hs[m] = h.handler
- }
-
- rt := Route{subroutes, hs, p}
- rts = append(rts, rt)
- }
-
- return false
- })
-
- return rts
-}
-
-func (n *node) walk(fn func(eps endpoints, subroutes Routes) bool) bool {
- // Visit the leaf values if any
- if (n.endpoints != nil || n.subroutes != nil) && fn(n.endpoints, n.subroutes) {
- return true
- }
-
- // Recurse on the children
- for _, ns := range n.children {
- for _, cn := range ns {
- if cn.walk(fn) {
- return true
- }
- }
- }
- return false
-}
-
-// patNextSegment returns the next segment details from a pattern:
-// node type, param key, regexp string, param tail byte, param starting index, param ending index
-func patNextSegment(pattern string) (nodeTyp, string, string, byte, int, int) {
- ps := strings.Index(pattern, "{")
- ws := strings.Index(pattern, "*")
-
- if ps < 0 && ws < 0 {
- return ntStatic, "", "", 0, 0, len(pattern) // we return the entire thing
- }
-
- // Sanity check
- if ps >= 0 && ws >= 0 && ws < ps {
- panic("chi: wildcard '*' must be the last pattern in a route, otherwise use a '{param}'")
- }
-
- var tail byte = '/' // Default endpoint tail to / byte
-
- if ps >= 0 {
- // Param/Regexp pattern is next
- nt := ntParam
-
- // Read to closing } taking into account opens and closes in curl count (cc)
- cc := 0
- pe := ps
- for i, c := range pattern[ps:] {
- if c == '{' {
- cc++
- } else if c == '}' {
- cc--
- if cc == 0 {
- pe = ps + i
- break
- }
- }
- }
- if pe == ps {
- panic("chi: route param closing delimiter '}' is missing")
- }
-
- key := pattern[ps+1 : pe]
- pe++ // set end to next position
-
- if pe < len(pattern) {
- tail = pattern[pe]
- }
-
- var rexpat string
- if idx := strings.Index(key, ":"); idx >= 0 {
- nt = ntRegexp
- rexpat = key[idx+1:]
- key = key[:idx]
- }
-
- if len(rexpat) > 0 {
- if rexpat[0] != '^' {
- rexpat = "^" + rexpat
- }
- if rexpat[len(rexpat)-1] != '$' {
- rexpat += "$"
- }
- }
-
- return nt, key, rexpat, tail, ps, pe
- }
-
- // Wildcard pattern as finale
- if ws < len(pattern)-1 {
- panic("chi: wildcard '*' must be the last value in a route. trim trailing text or use a '{param}' instead")
- }
- return ntCatchAll, "*", "", 0, ws, len(pattern)
-}
-
-func patParamKeys(pattern string) []string {
- pat := pattern
- paramKeys := []string{}
- for {
- ptyp, paramKey, _, _, _, e := patNextSegment(pat)
- if ptyp == ntStatic {
- return paramKeys
- }
- for i := 0; i < len(paramKeys); i++ {
- if paramKeys[i] == paramKey {
- panic(fmt.Sprintf("chi: routing pattern '%s' contains duplicate param key, '%s'", pattern, paramKey))
- }
- }
- paramKeys = append(paramKeys, paramKey)
- pat = pat[e:]
- }
-}
-
-// longestPrefix finds the length of the shared prefix
-// of two strings
-func longestPrefix(k1, k2 string) int {
- max := len(k1)
- if l := len(k2); l < max {
- max = l
- }
- var i int
- for i = 0; i < max; i++ {
- if k1[i] != k2[i] {
- break
- }
- }
- return i
-}
-
-func methodTypString(method methodTyp) string {
- for s, t := range methodMap {
- if method == t {
- return s
- }
- }
- return ""
-}
-
-type nodes []*node
-
-// Sort the list of nodes by label
-func (ns nodes) Sort() { sort.Sort(ns); ns.tailSort() }
-func (ns nodes) Len() int { return len(ns) }
-func (ns nodes) Swap(i, j int) { ns[i], ns[j] = ns[j], ns[i] }
-func (ns nodes) Less(i, j int) bool { return ns[i].label < ns[j].label }
-
-// tailSort pushes nodes with '/' as the tail to the end of the list for param nodes.
-// The list order determines the traversal order.
-func (ns nodes) tailSort() {
- for i := len(ns) - 1; i >= 0; i-- {
- if ns[i].typ > ntStatic && ns[i].tail == '/' {
- ns.Swap(i, len(ns)-1)
- return
- }
- }
-}
-
-func (ns nodes) findEdge(label byte) *node {
- num := len(ns)
- idx := 0
- i, j := 0, num-1
- for i <= j {
- idx = i + (j-i)/2
- if label > ns[idx].label {
- i = idx + 1
- } else if label < ns[idx].label {
- j = idx - 1
- } else {
- i = num // breaks cond
- }
- }
- if ns[idx].label != label {
- return nil
- }
- return ns[idx]
-}
-
-// Route describes the details of a routing handler.
-// Handlers map key is an HTTP method
-type Route struct {
- SubRoutes Routes
- Handlers map[string]http.Handler
- Pattern string
-}
-
-// WalkFunc is the type of the function called for each method and route visited by Walk.
-type WalkFunc func(method string, route string, handler http.Handler, middlewares ...func(http.Handler) http.Handler) error
-
-// Walk walks any router tree that implements Routes interface.
-func Walk(r Routes, walkFn WalkFunc) error {
- return walk(r, walkFn, "")
-}
-
-func walk(r Routes, walkFn WalkFunc, parentRoute string, parentMw ...func(http.Handler) http.Handler) error {
- for _, route := range r.Routes() {
- mws := make([]func(http.Handler) http.Handler, len(parentMw))
- copy(mws, parentMw)
- mws = append(mws, r.Middlewares()...)
-
- if route.SubRoutes != nil {
- if err := walk(route.SubRoutes, walkFn, parentRoute+route.Pattern, mws...); err != nil {
- return err
- }
- continue
- }
-
- for method, handler := range route.Handlers {
- if method == "*" {
- // Ignore a "catchAll" method, since we pass down all the specific methods for each route.
- continue
- }
-
- fullRoute := parentRoute + route.Pattern
- fullRoute = strings.Replace(fullRoute, "/*/", "/", -1)
-
- if chain, ok := handler.(*ChainHandler); ok {
- if err := walkFn(method, fullRoute, chain.Endpoint, append(mws, chain.Middlewares...)...); err != nil {
- return err
- }
- } else {
- if err := walkFn(method, fullRoute, handler, mws...); err != nil {
- return err
- }
- }
- }
- }
-
- return nil
-}
diff --git a/vendor/github.com/gofrs/uuid/v5/.gitignore b/vendor/github.com/gofrs/uuid/v5/.gitignore
deleted file mode 100644
index 666dbbb..0000000
--- a/vendor/github.com/gofrs/uuid/v5/.gitignore
+++ /dev/null
@@ -1,15 +0,0 @@
-# Binaries for programs and plugins
-*.exe
-*.exe~
-*.dll
-*.so
-*.dylib
-
-# Test binary, build with `go test -c`
-*.test
-
-# Output of the go coverage tool, specifically when used with LiteIDE
-*.out
-
-# binary bundle generated by go-fuzz
-uuid-fuzz.zip
diff --git a/vendor/github.com/gofrs/uuid/v5/LICENSE b/vendor/github.com/gofrs/uuid/v5/LICENSE
deleted file mode 100644
index 926d549..0000000
--- a/vendor/github.com/gofrs/uuid/v5/LICENSE
+++ /dev/null
@@ -1,20 +0,0 @@
-Copyright (C) 2013-2018 by Maxim Bublis
-
-Permission is hereby granted, free of charge, to any person obtaining
-a copy of this software and associated documentation files (the
-"Software"), to deal in the Software without restriction, including
-without limitation the rights to use, copy, modify, merge, publish,
-distribute, sublicense, and/or sell copies of the Software, and to
-permit persons to whom the Software is furnished to do so, subject to
-the following conditions:
-
-The above copyright notice and this permission notice shall be
-included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/vendor/github.com/gofrs/uuid/v5/README.md b/vendor/github.com/gofrs/uuid/v5/README.md
deleted file mode 100644
index d9bdd5a..0000000
--- a/vendor/github.com/gofrs/uuid/v5/README.md
+++ /dev/null
@@ -1,95 +0,0 @@
-# UUID
-
-[](https://github.com/gofrs/uuid/blob/master/LICENSE)
-[](https://travis-ci.org/gofrs/uuid)
-[](http://godoc.org/github.com/gofrs/uuid)
-[](https://codecov.io/gh/gofrs/uuid/)
-[](https://goreportcard.com/report/github.com/gofrs/uuid)
-
-Package uuid provides a pure Go implementation of Universally Unique Identifiers
-(UUID) variant as defined in RFC-4122. This package supports both the creation
-and parsing of UUIDs in different formats.
-
-This package supports the following UUID versions:
-* Version 1, based on timestamp and MAC address (RFC-4122)
-* Version 3, based on MD5 hashing of a named value (RFC-4122)
-* Version 4, based on random numbers (RFC-4122)
-* Version 5, based on SHA-1 hashing of a named value (RFC-4122)
-
-This package also supports experimental Universally Unique Identifier implementations based on a
-[draft RFC](https://www.ietf.org/archive/id/draft-peabody-dispatch-new-uuid-format-04.html) that updates RFC-4122
-* Version 6, a k-sortable id based on timestamp, and field-compatible with v1 (draft-peabody-dispatch-new-uuid-format, RFC-4122)
-* Version 7, a k-sortable id based on timestamp (draft-peabody-dispatch-new-uuid-format, RFC-4122)
-
-The v6 and v7 IDs are **not** considered a part of the stable API, and may be subject to behavior or API changes as part of minor releases
-to this package. They will be updated as the draft RFC changes, and will become stable if and when the draft RFC is accepted.
-
-## Project History
-
-This project was originally forked from the
-[github.com/satori/go.uuid](https://github.com/satori/go.uuid) repository after
-it appeared to be no longer maintained, while exhibiting [critical
-flaws](https://github.com/satori/go.uuid/issues/73). We have decided to take
-over this project to ensure it receives regular maintenance for the benefit of
-the larger Go community.
-
-We'd like to thank Maxim Bublis for his hard work on the original iteration of
-the package.
-
-## License
-
-This source code of this package is released under the MIT License. Please see
-the [LICENSE](https://github.com/gofrs/uuid/blob/master/LICENSE) for the full
-content of the license.
-
-## Recommended Package Version
-
-We recommend using v2.0.0+ of this package, as versions prior to 2.0.0 were
-created before our fork of the original package and have some known
-deficiencies.
-
-## Requirements
-
-This package requres Go 1.17 or later
-
-## Usage
-
-Here is a quick overview of how to use this package. For more detailed
-documentation, please see the [GoDoc Page](http://godoc.org/github.com/gofrs/uuid).
-
-```go
-package main
-
-import (
- "log"
-
- "github.com/gofrs/uuid"
-)
-
-// Create a Version 4 UUID, panicking on error.
-// Use this form to initialize package-level variables.
-var u1 = uuid.Must(uuid.NewV4())
-
-func main() {
- // Create a Version 4 UUID.
- u2, err := uuid.NewV4()
- if err != nil {
- log.Fatalf("failed to generate UUID: %v", err)
- }
- log.Printf("generated Version 4 UUID %v", u2)
-
- // Parse a UUID from a string.
- s := "6ba7b810-9dad-11d1-80b4-00c04fd430c8"
- u3, err := uuid.FromString(s)
- if err != nil {
- log.Fatalf("failed to parse UUID %q: %v", s, err)
- }
- log.Printf("successfully parsed UUID %v", u3)
-}
-```
-
-## References
-
-* [RFC-4122](https://tools.ietf.org/html/rfc4122)
-* [DCE 1.1: Authentication and Security Services](http://pubs.opengroup.org/onlinepubs/9696989899/chap5.htm#tagcjh_08_02_01_01)
-* [New UUID Formats RFC Draft (Peabody) Rev 04](https://www.ietf.org/archive/id/draft-peabody-dispatch-new-uuid-format-04.html#)
diff --git a/vendor/github.com/gofrs/uuid/v5/codec.go b/vendor/github.com/gofrs/uuid/v5/codec.go
deleted file mode 100644
index 6650264..0000000
--- a/vendor/github.com/gofrs/uuid/v5/codec.go
+++ /dev/null
@@ -1,234 +0,0 @@
-// Copyright (C) 2013-2018 by Maxim Bublis
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-package uuid
-
-import (
- "errors"
- "fmt"
-)
-
-// FromBytes returns a UUID generated from the raw byte slice input.
-// It will return an error if the slice isn't 16 bytes long.
-func FromBytes(input []byte) (UUID, error) {
- u := UUID{}
- err := u.UnmarshalBinary(input)
- return u, err
-}
-
-// FromBytesOrNil returns a UUID generated from the raw byte slice input.
-// Same behavior as FromBytes(), but returns uuid.Nil instead of an error.
-func FromBytesOrNil(input []byte) UUID {
- uuid, err := FromBytes(input)
- if err != nil {
- return Nil
- }
- return uuid
-}
-
-var errInvalidFormat = errors.New("uuid: invalid UUID format")
-
-func fromHexChar(c byte) byte {
- switch {
- case '0' <= c && c <= '9':
- return c - '0'
- case 'a' <= c && c <= 'f':
- return c - 'a' + 10
- case 'A' <= c && c <= 'F':
- return c - 'A' + 10
- }
- return 255
-}
-
-// Parse parses the UUID stored in the string text. Parsing and supported
-// formats are the same as UnmarshalText.
-func (u *UUID) Parse(s string) error {
- switch len(s) {
- case 32: // hash
- case 36: // canonical
- case 34, 38:
- if s[0] != '{' || s[len(s)-1] != '}' {
- return fmt.Errorf("uuid: incorrect UUID format in string %q", s)
- }
- s = s[1 : len(s)-1]
- case 41, 45:
- if s[:9] != "urn:uuid:" {
- return fmt.Errorf("uuid: incorrect UUID format in string %q", s[:9])
- }
- s = s[9:]
- default:
- return fmt.Errorf("uuid: incorrect UUID length %d in string %q", len(s), s)
- }
- // canonical
- if len(s) == 36 {
- if s[8] != '-' || s[13] != '-' || s[18] != '-' || s[23] != '-' {
- return fmt.Errorf("uuid: incorrect UUID format in string %q", s)
- }
- for i, x := range [16]byte{
- 0, 2, 4, 6,
- 9, 11,
- 14, 16,
- 19, 21,
- 24, 26, 28, 30, 32, 34,
- } {
- v1 := fromHexChar(s[x])
- v2 := fromHexChar(s[x+1])
- if v1|v2 == 255 {
- return errInvalidFormat
- }
- u[i] = (v1 << 4) | v2
- }
- return nil
- }
- // hash like
- for i := 0; i < 32; i += 2 {
- v1 := fromHexChar(s[i])
- v2 := fromHexChar(s[i+1])
- if v1|v2 == 255 {
- return errInvalidFormat
- }
- u[i/2] = (v1 << 4) | v2
- }
- return nil
-}
-
-// FromString returns a UUID parsed from the input string.
-// Input is expected in a form accepted by UnmarshalText.
-func FromString(text string) (UUID, error) {
- var u UUID
- err := u.Parse(text)
- return u, err
-}
-
-// FromStringOrNil returns a UUID parsed from the input string.
-// Same behavior as FromString(), but returns uuid.Nil instead of an error.
-func FromStringOrNil(input string) UUID {
- uuid, err := FromString(input)
- if err != nil {
- return Nil
- }
- return uuid
-}
-
-// MarshalText implements the encoding.TextMarshaler interface.
-// The encoding is the same as returned by the String() method.
-func (u UUID) MarshalText() ([]byte, error) {
- var buf [36]byte
- encodeCanonical(buf[:], u)
- return buf[:], nil
-}
-
-// UnmarshalText implements the encoding.TextUnmarshaler interface.
-// Following formats are supported:
-//
-// "6ba7b810-9dad-11d1-80b4-00c04fd430c8",
-// "{6ba7b810-9dad-11d1-80b4-00c04fd430c8}",
-// "urn:uuid:6ba7b810-9dad-11d1-80b4-00c04fd430c8"
-// "6ba7b8109dad11d180b400c04fd430c8"
-// "{6ba7b8109dad11d180b400c04fd430c8}",
-// "urn:uuid:6ba7b8109dad11d180b400c04fd430c8"
-//
-// ABNF for supported UUID text representation follows:
-//
-// URN := 'urn'
-// UUID-NID := 'uuid'
-//
-// hexdig := '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9' |
-// 'a' | 'b' | 'c' | 'd' | 'e' | 'f' |
-// 'A' | 'B' | 'C' | 'D' | 'E' | 'F'
-//
-// hexoct := hexdig hexdig
-// 2hexoct := hexoct hexoct
-// 4hexoct := 2hexoct 2hexoct
-// 6hexoct := 4hexoct 2hexoct
-// 12hexoct := 6hexoct 6hexoct
-//
-// hashlike := 12hexoct
-// canonical := 4hexoct '-' 2hexoct '-' 2hexoct '-' 6hexoct
-//
-// plain := canonical | hashlike
-// uuid := canonical | hashlike | braced | urn
-//
-// braced := '{' plain '}' | '{' hashlike '}'
-// urn := URN ':' UUID-NID ':' plain
-func (u *UUID) UnmarshalText(b []byte) error {
- switch len(b) {
- case 32: // hash
- case 36: // canonical
- case 34, 38:
- if b[0] != '{' || b[len(b)-1] != '}' {
- return fmt.Errorf("uuid: incorrect UUID format in string %q", b)
- }
- b = b[1 : len(b)-1]
- case 41, 45:
- if string(b[:9]) != "urn:uuid:" {
- return fmt.Errorf("uuid: incorrect UUID format in string %q", b[:9])
- }
- b = b[9:]
- default:
- return fmt.Errorf("uuid: incorrect UUID length %d in string %q", len(b), b)
- }
- if len(b) == 36 {
- if b[8] != '-' || b[13] != '-' || b[18] != '-' || b[23] != '-' {
- return fmt.Errorf("uuid: incorrect UUID format in string %q", b)
- }
- for i, x := range [16]byte{
- 0, 2, 4, 6,
- 9, 11,
- 14, 16,
- 19, 21,
- 24, 26, 28, 30, 32, 34,
- } {
- v1 := fromHexChar(b[x])
- v2 := fromHexChar(b[x+1])
- if v1|v2 == 255 {
- return errInvalidFormat
- }
- u[i] = (v1 << 4) | v2
- }
- return nil
- }
- for i := 0; i < 32; i += 2 {
- v1 := fromHexChar(b[i])
- v2 := fromHexChar(b[i+1])
- if v1|v2 == 255 {
- return errInvalidFormat
- }
- u[i/2] = (v1 << 4) | v2
- }
- return nil
-}
-
-// MarshalBinary implements the encoding.BinaryMarshaler interface.
-func (u UUID) MarshalBinary() ([]byte, error) {
- return u.Bytes(), nil
-}
-
-// UnmarshalBinary implements the encoding.BinaryUnmarshaler interface.
-// It will return an error if the slice isn't 16 bytes long.
-func (u *UUID) UnmarshalBinary(data []byte) error {
- if len(data) != Size {
- return fmt.Errorf("uuid: UUID must be exactly 16 bytes long, got %d bytes", len(data))
- }
- copy(u[:], data)
-
- return nil
-}
diff --git a/vendor/github.com/gofrs/uuid/v5/fuzz.go b/vendor/github.com/gofrs/uuid/v5/fuzz.go
deleted file mode 100644
index ccf8d4c..0000000
--- a/vendor/github.com/gofrs/uuid/v5/fuzz.go
+++ /dev/null
@@ -1,48 +0,0 @@
-// Copyright (c) 2018 Andrei Tudor Călin
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-//go:build gofuzz
-// +build gofuzz
-
-package uuid
-
-// Fuzz implements a simple fuzz test for FromString / UnmarshalText.
-//
-// To run:
-//
-// $ go get github.com/dvyukov/go-fuzz/...
-// $ cd $GOPATH/src/github.com/gofrs/uuid
-// $ go-fuzz-build github.com/gofrs/uuid
-// $ go-fuzz -bin=uuid-fuzz.zip -workdir=./testdata
-//
-// If you make significant changes to FromString / UnmarshalText and add
-// new cases to fromStringTests (in codec_test.go), please run
-//
-// $ go test -seed_fuzz_corpus
-//
-// to seed the corpus with the new interesting inputs, then run the fuzzer.
-func Fuzz(data []byte) int {
- _, err := FromString(string(data))
- if err != nil {
- return 0
- }
- return 1
-}
diff --git a/vendor/github.com/gofrs/uuid/v5/generator.go b/vendor/github.com/gofrs/uuid/v5/generator.go
deleted file mode 100644
index 44be9e1..0000000
--- a/vendor/github.com/gofrs/uuid/v5/generator.go
+++ /dev/null
@@ -1,456 +0,0 @@
-// Copyright (C) 2013-2018 by Maxim Bublis
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-package uuid
-
-import (
- "crypto/md5"
- "crypto/rand"
- "crypto/sha1"
- "encoding/binary"
- "fmt"
- "hash"
- "io"
- "net"
- "sync"
- "time"
-)
-
-// Difference in 100-nanosecond intervals between
-// UUID epoch (October 15, 1582) and Unix epoch (January 1, 1970).
-const epochStart = 122192928000000000
-
-// EpochFunc is the function type used to provide the current time.
-type EpochFunc func() time.Time
-
-// HWAddrFunc is the function type used to provide hardware (MAC) addresses.
-type HWAddrFunc func() (net.HardwareAddr, error)
-
-// DefaultGenerator is the default UUID Generator used by this package.
-var DefaultGenerator Generator = NewGen()
-
-// NewV1 returns a UUID based on the current timestamp and MAC address.
-func NewV1() (UUID, error) {
- return DefaultGenerator.NewV1()
-}
-
-// NewV3 returns a UUID based on the MD5 hash of the namespace UUID and name.
-func NewV3(ns UUID, name string) UUID {
- return DefaultGenerator.NewV3(ns, name)
-}
-
-// NewV4 returns a randomly generated UUID.
-func NewV4() (UUID, error) {
- return DefaultGenerator.NewV4()
-}
-
-// NewV5 returns a UUID based on SHA-1 hash of the namespace UUID and name.
-func NewV5(ns UUID, name string) UUID {
- return DefaultGenerator.NewV5(ns, name)
-}
-
-// NewV6 returns a k-sortable UUID based on a timestamp and 48 bits of
-// pseudorandom data. The timestamp in a V6 UUID is the same as V1, with the bit
-// order being adjusted to allow the UUID to be k-sortable.
-//
-// This is implemented based on revision 03 of the Peabody UUID draft, and may
-// be subject to change pending further revisions. Until the final specification
-// revision is finished, changes required to implement updates to the spec will
-// not be considered a breaking change. They will happen as a minor version
-// releases until the spec is final.
-func NewV6() (UUID, error) {
- return DefaultGenerator.NewV6()
-}
-
-// NewV7 returns a k-sortable UUID based on the current millisecond precision
-// UNIX epoch and 74 bits of pseudorandom data. It supports single-node batch generation (multiple UUIDs in the same timestamp) with a Monotonic Random counter.
-//
-// This is implemented based on revision 04 of the Peabody UUID draft, and may
-// be subject to change pending further revisions. Until the final specification
-// revision is finished, changes required to implement updates to the spec will
-// not be considered a breaking change. They will happen as a minor version
-// releases until the spec is final.
-func NewV7() (UUID, error) {
- return DefaultGenerator.NewV7()
-}
-
-// Generator provides an interface for generating UUIDs.
-type Generator interface {
- NewV1() (UUID, error)
- NewV3(ns UUID, name string) UUID
- NewV4() (UUID, error)
- NewV5(ns UUID, name string) UUID
- NewV6() (UUID, error)
- NewV7() (UUID, error)
-}
-
-// Gen is a reference UUID generator based on the specifications laid out in
-// RFC-4122 and DCE 1.1: Authentication and Security Services. This type
-// satisfies the Generator interface as defined in this package.
-//
-// For consumers who are generating V1 UUIDs, but don't want to expose the MAC
-// address of the node generating the UUIDs, the NewGenWithHWAF() function has been
-// provided as a convenience. See the function's documentation for more info.
-//
-// The authors of this package do not feel that the majority of users will need
-// to obfuscate their MAC address, and so we recommend using NewGen() to create
-// a new generator.
-type Gen struct {
- clockSequenceOnce sync.Once
- hardwareAddrOnce sync.Once
- storageMutex sync.Mutex
-
- rand io.Reader
-
- epochFunc EpochFunc
- hwAddrFunc HWAddrFunc
- lastTime uint64
- clockSequence uint16
- hardwareAddr [6]byte
-}
-
-// GenOption is a function type that can be used to configure a Gen generator.
-type GenOption func(*Gen)
-
-// interface check -- build will fail if *Gen doesn't satisfy Generator
-var _ Generator = (*Gen)(nil)
-
-// NewGen returns a new instance of Gen with some default values set. Most
-// people should use this.
-func NewGen() *Gen {
- return NewGenWithHWAF(defaultHWAddrFunc)
-}
-
-// NewGenWithHWAF builds a new UUID generator with the HWAddrFunc provided. Most
-// consumers should use NewGen() instead.
-//
-// This is used so that consumers can generate their own MAC addresses, for use
-// in the generated UUIDs, if there is some concern about exposing the physical
-// address of the machine generating the UUID.
-//
-// The Gen generator will only invoke the HWAddrFunc once, and cache that MAC
-// address for all the future UUIDs generated by it. If you'd like to switch the
-// MAC address being used, you'll need to create a new generator using this
-// function.
-func NewGenWithHWAF(hwaf HWAddrFunc) *Gen {
- return NewGenWithOptions(WithHWAddrFunc(hwaf))
-}
-
-// NewGenWithOptions returns a new instance of Gen with the options provided.
-// Most people should use NewGen() or NewGenWithHWAF() instead.
-//
-// To customize the generator, you can pass in one or more GenOption functions.
-// For example:
-//
-// gen := NewGenWithOptions(
-// WithHWAddrFunc(myHWAddrFunc),
-// WithEpochFunc(myEpochFunc),
-// WithRandomReader(myRandomReader),
-// )
-//
-// NewGenWithOptions(WithHWAddrFunc(myHWAddrFunc)) is equivalent to calling
-// NewGenWithHWAF(myHWAddrFunc)
-// NewGenWithOptions() is equivalent to calling NewGen()
-func NewGenWithOptions(opts ...GenOption) *Gen {
- gen := &Gen{
- epochFunc: time.Now,
- hwAddrFunc: defaultHWAddrFunc,
- rand: rand.Reader,
- }
-
- for _, opt := range opts {
- opt(gen)
- }
-
- return gen
-}
-
-// WithHWAddrFunc is a GenOption that allows you to provide your own HWAddrFunc
-// function.
-// When this option is nil, the defaultHWAddrFunc is used.
-func WithHWAddrFunc(hwaf HWAddrFunc) GenOption {
- return func(gen *Gen) {
- if hwaf == nil {
- hwaf = defaultHWAddrFunc
- }
-
- gen.hwAddrFunc = hwaf
- }
-}
-
-// WithEpochFunc is a GenOption that allows you to provide your own EpochFunc
-// function.
-// When this option is nil, time.Now is used.
-func WithEpochFunc(epochf EpochFunc) GenOption {
- return func(gen *Gen) {
- if epochf == nil {
- epochf = time.Now
- }
-
- gen.epochFunc = epochf
- }
-}
-
-// WithRandomReader is a GenOption that allows you to provide your own random
-// reader.
-// When this option is nil, the default rand.Reader is used.
-func WithRandomReader(reader io.Reader) GenOption {
- return func(gen *Gen) {
- if reader == nil {
- reader = rand.Reader
- }
-
- gen.rand = reader
- }
-}
-
-// NewV1 returns a UUID based on the current timestamp and MAC address.
-func (g *Gen) NewV1() (UUID, error) {
- u := UUID{}
-
- timeNow, clockSeq, err := g.getClockSequence(false)
- if err != nil {
- return Nil, err
- }
- binary.BigEndian.PutUint32(u[0:], uint32(timeNow))
- binary.BigEndian.PutUint16(u[4:], uint16(timeNow>>32))
- binary.BigEndian.PutUint16(u[6:], uint16(timeNow>>48))
- binary.BigEndian.PutUint16(u[8:], clockSeq)
-
- hardwareAddr, err := g.getHardwareAddr()
- if err != nil {
- return Nil, err
- }
- copy(u[10:], hardwareAddr)
-
- u.SetVersion(V1)
- u.SetVariant(VariantRFC4122)
-
- return u, nil
-}
-
-// NewV3 returns a UUID based on the MD5 hash of the namespace UUID and name.
-func (g *Gen) NewV3(ns UUID, name string) UUID {
- u := newFromHash(md5.New(), ns, name)
- u.SetVersion(V3)
- u.SetVariant(VariantRFC4122)
-
- return u
-}
-
-// NewV4 returns a randomly generated UUID.
-func (g *Gen) NewV4() (UUID, error) {
- u := UUID{}
- if _, err := io.ReadFull(g.rand, u[:]); err != nil {
- return Nil, err
- }
- u.SetVersion(V4)
- u.SetVariant(VariantRFC4122)
-
- return u, nil
-}
-
-// NewV5 returns a UUID based on SHA-1 hash of the namespace UUID and name.
-func (g *Gen) NewV5(ns UUID, name string) UUID {
- u := newFromHash(sha1.New(), ns, name)
- u.SetVersion(V5)
- u.SetVariant(VariantRFC4122)
-
- return u
-}
-
-// NewV6 returns a k-sortable UUID based on a timestamp and 48 bits of
-// pseudorandom data. The timestamp in a V6 UUID is the same as V1, with the bit
-// order being adjusted to allow the UUID to be k-sortable.
-//
-// This is implemented based on revision 03 of the Peabody UUID draft, and may
-// be subject to change pending further revisions. Until the final specification
-// revision is finished, changes required to implement updates to the spec will
-// not be considered a breaking change. They will happen as a minor version
-// releases until the spec is final.
-func (g *Gen) NewV6() (UUID, error) {
- var u UUID
-
- if _, err := io.ReadFull(g.rand, u[10:]); err != nil {
- return Nil, err
- }
-
- timeNow, clockSeq, err := g.getClockSequence(false)
- if err != nil {
- return Nil, err
- }
-
- binary.BigEndian.PutUint32(u[0:], uint32(timeNow>>28)) // set time_high
- binary.BigEndian.PutUint16(u[4:], uint16(timeNow>>12)) // set time_mid
- binary.BigEndian.PutUint16(u[6:], uint16(timeNow&0xfff)) // set time_low (minus four version bits)
- binary.BigEndian.PutUint16(u[8:], clockSeq&0x3fff) // set clk_seq_hi_res (minus two variant bits)
-
- u.SetVersion(V6)
- u.SetVariant(VariantRFC4122)
-
- return u, nil
-}
-
-// getClockSequence returns the epoch and clock sequence for V1,V6 and V7 UUIDs.
-//
-// When useUnixTSMs is false, it uses the Coordinated Universal Time (UTC) as a count of 100-
-//
-// nanosecond intervals since 00:00:00.00, 15 October 1582 (the date of Gregorian reform to the Christian calendar).
-func (g *Gen) getClockSequence(useUnixTSMs bool) (uint64, uint16, error) {
- var err error
- g.clockSequenceOnce.Do(func() {
- buf := make([]byte, 2)
- if _, err = io.ReadFull(g.rand, buf); err != nil {
- return
- }
- g.clockSequence = binary.BigEndian.Uint16(buf)
- })
- if err != nil {
- return 0, 0, err
- }
-
- g.storageMutex.Lock()
- defer g.storageMutex.Unlock()
-
- var timeNow uint64
- if useUnixTSMs {
- timeNow = uint64(g.epochFunc().UnixMilli())
- } else {
- timeNow = g.getEpoch()
- }
- // Clock didn't change since last UUID generation.
- // Should increase clock sequence.
- if timeNow <= g.lastTime {
- g.clockSequence++
- }
- g.lastTime = timeNow
-
- return timeNow, g.clockSequence, nil
-}
-
-// NewV7 returns a k-sortable UUID based on the current millisecond precision
-// UNIX epoch and 74 bits of pseudorandom data.
-//
-// This is implemented based on revision 04 of the Peabody UUID draft, and may
-// be subject to change pending further revisions. Until the final specification
-// revision is finished, changes required to implement updates to the spec will
-// not be considered a breaking change. They will happen as a minor version
-// releases until the spec is final.
-func (g *Gen) NewV7() (UUID, error) {
- var u UUID
- /* https://www.ietf.org/archive/id/draft-peabody-dispatch-new-uuid-format-04.html#name-uuid-version-7
- 0 1 2 3
- 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | unix_ts_ms |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | unix_ts_ms | ver | rand_a |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- |var| rand_b |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | rand_b |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ */
-
- ms, clockSeq, err := g.getClockSequence(true)
- if err != nil {
- return Nil, err
- }
- //UUIDv7 features a 48 bit timestamp. First 32bit (4bytes) represents seconds since 1970, followed by 2 bytes for the ms granularity.
- u[0] = byte(ms >> 40) //1-6 bytes: big-endian unsigned number of Unix epoch timestamp
- u[1] = byte(ms >> 32)
- u[2] = byte(ms >> 24)
- u[3] = byte(ms >> 16)
- u[4] = byte(ms >> 8)
- u[5] = byte(ms)
-
- //support batching by using a monotonic pseudo-random sequence
- //The 6th byte contains the version and partially rand_a data.
- //We will lose the most significant bites from the clockSeq (with SetVersion), but it is ok, we need the least significant that contains the counter to ensure the monotonic property
- binary.BigEndian.PutUint16(u[6:8], clockSeq) // set rand_a with clock seq which is random and monotonic
-
- //override first 4bits of u[6].
- u.SetVersion(V7)
-
- //set rand_b 64bits of pseudo-random bits (first 2 will be overridden)
- if _, err = io.ReadFull(g.rand, u[8:16]); err != nil {
- return Nil, err
- }
- //override first 2 bits of byte[8] for the variant
- u.SetVariant(VariantRFC4122)
-
- return u, nil
-}
-
-// Returns the hardware address.
-func (g *Gen) getHardwareAddr() ([]byte, error) {
- var err error
- g.hardwareAddrOnce.Do(func() {
- var hwAddr net.HardwareAddr
- if hwAddr, err = g.hwAddrFunc(); err == nil {
- copy(g.hardwareAddr[:], hwAddr)
- return
- }
-
- // Initialize hardwareAddr randomly in case
- // of real network interfaces absence.
- if _, err = io.ReadFull(g.rand, g.hardwareAddr[:]); err != nil {
- return
- }
- // Set multicast bit as recommended by RFC-4122
- g.hardwareAddr[0] |= 0x01
- })
- if err != nil {
- return []byte{}, err
- }
- return g.hardwareAddr[:], nil
-}
-
-// Returns the difference between UUID epoch (October 15, 1582)
-// and current time in 100-nanosecond intervals.
-func (g *Gen) getEpoch() uint64 {
- return epochStart + uint64(g.epochFunc().UnixNano()/100)
-}
-
-// Returns the UUID based on the hashing of the namespace UUID and name.
-func newFromHash(h hash.Hash, ns UUID, name string) UUID {
- u := UUID{}
- h.Write(ns[:])
- h.Write([]byte(name))
- copy(u[:], h.Sum(nil))
-
- return u
-}
-
-var netInterfaces = net.Interfaces
-
-// Returns the hardware address.
-func defaultHWAddrFunc() (net.HardwareAddr, error) {
- ifaces, err := netInterfaces()
- if err != nil {
- return []byte{}, err
- }
- for _, iface := range ifaces {
- if len(iface.HardwareAddr) >= 6 {
- return iface.HardwareAddr, nil
- }
- }
- return []byte{}, fmt.Errorf("uuid: no HW address found")
-}
diff --git a/vendor/github.com/gofrs/uuid/v5/sql.go b/vendor/github.com/gofrs/uuid/v5/sql.go
deleted file mode 100644
index 01d5d88..0000000
--- a/vendor/github.com/gofrs/uuid/v5/sql.go
+++ /dev/null
@@ -1,116 +0,0 @@
-// Copyright (C) 2013-2018 by Maxim Bublis
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-package uuid
-
-import (
- "database/sql"
- "database/sql/driver"
- "fmt"
-)
-
-var _ driver.Valuer = UUID{}
-var _ sql.Scanner = (*UUID)(nil)
-
-// Value implements the driver.Valuer interface.
-func (u UUID) Value() (driver.Value, error) {
- return u.String(), nil
-}
-
-// Scan implements the sql.Scanner interface.
-// A 16-byte slice will be handled by UnmarshalBinary, while
-// a longer byte slice or a string will be handled by UnmarshalText.
-func (u *UUID) Scan(src interface{}) error {
- switch src := src.(type) {
- case UUID: // support gorm convert from UUID to NullUUID
- *u = src
- return nil
-
- case []byte:
- if len(src) == Size {
- return u.UnmarshalBinary(src)
- }
- return u.UnmarshalText(src)
-
- case string:
- uu, err := FromString(src)
- *u = uu
- return err
- }
-
- return fmt.Errorf("uuid: cannot convert %T to UUID", src)
-}
-
-// NullUUID can be used with the standard sql package to represent a
-// UUID value that can be NULL in the database.
-type NullUUID struct {
- UUID UUID
- Valid bool
-}
-
-// Value implements the driver.Valuer interface.
-func (u NullUUID) Value() (driver.Value, error) {
- if !u.Valid {
- return nil, nil
- }
- // Delegate to UUID Value function
- return u.UUID.Value()
-}
-
-// Scan implements the sql.Scanner interface.
-func (u *NullUUID) Scan(src interface{}) error {
- if src == nil {
- u.UUID, u.Valid = Nil, false
- return nil
- }
-
- // Delegate to UUID Scan function
- u.Valid = true
- return u.UUID.Scan(src)
-}
-
-var nullJSON = []byte("null")
-
-// MarshalJSON marshals the NullUUID as null or the nested UUID
-func (u NullUUID) MarshalJSON() ([]byte, error) {
- if !u.Valid {
- return nullJSON, nil
- }
- var buf [38]byte
- buf[0] = '"'
- encodeCanonical(buf[1:37], u.UUID)
- buf[37] = '"'
- return buf[:], nil
-}
-
-// UnmarshalJSON unmarshals a NullUUID
-func (u *NullUUID) UnmarshalJSON(b []byte) error {
- if string(b) == "null" {
- u.UUID, u.Valid = Nil, false
- return nil
- }
- if n := len(b); n >= 2 && b[0] == '"' {
- b = b[1 : n-1]
- }
- err := u.UUID.UnmarshalText(b)
- u.Valid = (err == nil)
- return err
-}
diff --git a/vendor/github.com/gofrs/uuid/v5/uuid.go b/vendor/github.com/gofrs/uuid/v5/uuid.go
deleted file mode 100644
index 5320fb5..0000000
--- a/vendor/github.com/gofrs/uuid/v5/uuid.go
+++ /dev/null
@@ -1,285 +0,0 @@
-// Copyright (C) 2013-2018 by Maxim Bublis
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-// Package uuid provides implementations of the Universally Unique Identifier
-// (UUID), as specified in RFC-4122 and the Peabody RFC Draft (revision 03).
-//
-// RFC-4122[1] provides the specification for versions 1, 3, 4, and 5. The
-// Peabody UUID RFC Draft[2] provides the specification for the new k-sortable
-// UUIDs, versions 6 and 7.
-//
-// DCE 1.1[3] provides the specification for version 2, but version 2 support
-// was removed from this package in v4 due to some concerns with the
-// specification itself. Reading the spec, it seems that it would result in
-// generating UUIDs that aren't very unique. In having read the spec it seemed
-// that our implementation did not meet the spec. It also seems to be at-odds
-// with RFC 4122, meaning we would need quite a bit of special code to support
-// it. Lastly, there were no Version 2 implementations that we could find to
-// ensure we were understanding the specification correctly.
-//
-// [1] https://tools.ietf.org/html/rfc4122
-// [2] https://datatracker.ietf.org/doc/html/draft-peabody-dispatch-new-uuid-format-03
-// [3] http://pubs.opengroup.org/onlinepubs/9696989899/chap5.htm#tagcjh_08_02_01_01
-package uuid
-
-import (
- "encoding/binary"
- "encoding/hex"
- "fmt"
- "time"
-)
-
-// Size of a UUID in bytes.
-const Size = 16
-
-// UUID is an array type to represent the value of a UUID, as defined in RFC-4122.
-type UUID [Size]byte
-
-// UUID versions.
-const (
- _ byte = iota
- V1 // Version 1 (date-time and MAC address)
- _ // Version 2 (date-time and MAC address, DCE security version) [removed]
- V3 // Version 3 (namespace name-based)
- V4 // Version 4 (random)
- V5 // Version 5 (namespace name-based)
- V6 // Version 6 (k-sortable timestamp and random data, field-compatible with v1) [peabody draft]
- V7 // Version 7 (k-sortable timestamp and random data) [peabody draft]
- _ // Version 8 (k-sortable timestamp, meant for custom implementations) [peabody draft] [not implemented]
-)
-
-// UUID layout variants.
-const (
- VariantNCS byte = iota
- VariantRFC4122
- VariantMicrosoft
- VariantFuture
-)
-
-// UUID DCE domains.
-const (
- DomainPerson = iota
- DomainGroup
- DomainOrg
-)
-
-// Timestamp is the count of 100-nanosecond intervals since 00:00:00.00,
-// 15 October 1582 within a V1 UUID. This type has no meaning for other
-// UUID versions since they don't have an embedded timestamp.
-type Timestamp uint64
-
-const _100nsPerSecond = 10000000
-
-// Time returns the UTC time.Time representation of a Timestamp
-func (t Timestamp) Time() (time.Time, error) {
- secs := uint64(t) / _100nsPerSecond
- nsecs := 100 * (uint64(t) % _100nsPerSecond)
-
- return time.Unix(int64(secs)-(epochStart/_100nsPerSecond), int64(nsecs)), nil
-}
-
-// TimestampFromV1 returns the Timestamp embedded within a V1 UUID.
-// Returns an error if the UUID is any version other than 1.
-func TimestampFromV1(u UUID) (Timestamp, error) {
- if u.Version() != 1 {
- err := fmt.Errorf("uuid: %s is version %d, not version 1", u, u.Version())
- return 0, err
- }
-
- low := binary.BigEndian.Uint32(u[0:4])
- mid := binary.BigEndian.Uint16(u[4:6])
- hi := binary.BigEndian.Uint16(u[6:8]) & 0xfff
-
- return Timestamp(uint64(low) + (uint64(mid) << 32) + (uint64(hi) << 48)), nil
-}
-
-// TimestampFromV6 returns the Timestamp embedded within a V6 UUID. This
-// function returns an error if the UUID is any version other than 6.
-//
-// This is implemented based on revision 03 of the Peabody UUID draft, and may
-// be subject to change pending further revisions. Until the final specification
-// revision is finished, changes required to implement updates to the spec will
-// not be considered a breaking change. They will happen as a minor version
-// releases until the spec is final.
-func TimestampFromV6(u UUID) (Timestamp, error) {
- if u.Version() != 6 {
- return 0, fmt.Errorf("uuid: %s is version %d, not version 6", u, u.Version())
- }
-
- hi := binary.BigEndian.Uint32(u[0:4])
- mid := binary.BigEndian.Uint16(u[4:6])
- low := binary.BigEndian.Uint16(u[6:8]) & 0xfff
-
- return Timestamp(uint64(low) + (uint64(mid) << 12) + (uint64(hi) << 28)), nil
-}
-
-// Nil is the nil UUID, as specified in RFC-4122, that has all 128 bits set to
-// zero.
-var Nil = UUID{}
-
-// Predefined namespace UUIDs.
-var (
- NamespaceDNS = Must(FromString("6ba7b810-9dad-11d1-80b4-00c04fd430c8"))
- NamespaceURL = Must(FromString("6ba7b811-9dad-11d1-80b4-00c04fd430c8"))
- NamespaceOID = Must(FromString("6ba7b812-9dad-11d1-80b4-00c04fd430c8"))
- NamespaceX500 = Must(FromString("6ba7b814-9dad-11d1-80b4-00c04fd430c8"))
-)
-
-// IsNil returns if the UUID is equal to the nil UUID
-func (u UUID) IsNil() bool {
- return u == Nil
-}
-
-// Version returns the algorithm version used to generate the UUID.
-func (u UUID) Version() byte {
- return u[6] >> 4
-}
-
-// Variant returns the UUID layout variant.
-func (u UUID) Variant() byte {
- switch {
- case (u[8] >> 7) == 0x00:
- return VariantNCS
- case (u[8] >> 6) == 0x02:
- return VariantRFC4122
- case (u[8] >> 5) == 0x06:
- return VariantMicrosoft
- case (u[8] >> 5) == 0x07:
- fallthrough
- default:
- return VariantFuture
- }
-}
-
-// Bytes returns a byte slice representation of the UUID.
-func (u UUID) Bytes() []byte {
- return u[:]
-}
-
-// encodeCanonical encodes the canonical RFC-4122 form of UUID u into the
-// first 36 bytes dst.
-func encodeCanonical(dst []byte, u UUID) {
- const hextable = "0123456789abcdef"
- dst[8] = '-'
- dst[13] = '-'
- dst[18] = '-'
- dst[23] = '-'
- for i, x := range [16]byte{
- 0, 2, 4, 6,
- 9, 11,
- 14, 16,
- 19, 21,
- 24, 26, 28, 30, 32, 34,
- } {
- c := u[i]
- dst[x] = hextable[c>>4]
- dst[x+1] = hextable[c&0x0f]
- }
-}
-
-// String returns a canonical RFC-4122 string representation of the UUID:
-// xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.
-func (u UUID) String() string {
- var buf [36]byte
- encodeCanonical(buf[:], u)
- return string(buf[:])
-}
-
-// Format implements fmt.Formatter for UUID values.
-//
-// The behavior is as follows:
-// The 'x' and 'X' verbs output only the hex digits of the UUID, using a-f for 'x' and A-F for 'X'.
-// The 'v', '+v', 's' and 'q' verbs return the canonical RFC-4122 string representation.
-// The 'S' verb returns the RFC-4122 format, but with capital hex digits.
-// The '#v' verb returns the "Go syntax" representation, which is a 16 byte array initializer.
-// All other verbs not handled directly by the fmt package (like '%p') are unsupported and will return
-// "%!verb(uuid.UUID=value)" as recommended by the fmt package.
-func (u UUID) Format(f fmt.State, c rune) {
- if c == 'v' && f.Flag('#') {
- fmt.Fprintf(f, "%#v", [Size]byte(u))
- return
- }
- switch c {
- case 'x', 'X':
- b := make([]byte, 32)
- hex.Encode(b, u[:])
- if c == 'X' {
- toUpperHex(b)
- }
- _, _ = f.Write(b)
- case 'v', 's', 'S':
- b, _ := u.MarshalText()
- if c == 'S' {
- toUpperHex(b)
- }
- _, _ = f.Write(b)
- case 'q':
- b := make([]byte, 38)
- b[0] = '"'
- encodeCanonical(b[1:], u)
- b[37] = '"'
- _, _ = f.Write(b)
- default:
- // invalid/unsupported format verb
- fmt.Fprintf(f, "%%!%c(uuid.UUID=%s)", c, u.String())
- }
-}
-
-func toUpperHex(b []byte) {
- for i, c := range b {
- if 'a' <= c && c <= 'f' {
- b[i] = c - ('a' - 'A')
- }
- }
-}
-
-// SetVersion sets the version bits.
-func (u *UUID) SetVersion(v byte) {
- u[6] = (u[6] & 0x0f) | (v << 4)
-}
-
-// SetVariant sets the variant bits.
-func (u *UUID) SetVariant(v byte) {
- switch v {
- case VariantNCS:
- u[8] = (u[8]&(0xff>>1) | (0x00 << 7))
- case VariantRFC4122:
- u[8] = (u[8]&(0xff>>2) | (0x02 << 6))
- case VariantMicrosoft:
- u[8] = (u[8]&(0xff>>3) | (0x06 << 5))
- case VariantFuture:
- fallthrough
- default:
- u[8] = (u[8]&(0xff>>3) | (0x07 << 5))
- }
-}
-
-// Must is a helper that wraps a call to a function returning (UUID, error)
-// and panics if the error is non-nil. It is intended for use in variable
-// initializations such as
-//
-// var packageUUID = uuid.Must(uuid.FromString("123e4567-e89b-12d3-a456-426655440000"))
-func Must(u UUID, err error) UUID {
- if err != nil {
- panic(err)
- }
- return u
-}
diff --git a/vendor/github.com/gorilla/mux/.editorconfig b/vendor/github.com/gorilla/mux/.editorconfig
deleted file mode 100644
index c6b74c3..0000000
--- a/vendor/github.com/gorilla/mux/.editorconfig
+++ /dev/null
@@ -1,20 +0,0 @@
-; https://editorconfig.org/
-
-root = true
-
-[*]
-insert_final_newline = true
-charset = utf-8
-trim_trailing_whitespace = true
-indent_style = space
-indent_size = 2
-
-[{Makefile,go.mod,go.sum,*.go,.gitmodules}]
-indent_style = tab
-indent_size = 4
-
-[*.md]
-indent_size = 4
-trim_trailing_whitespace = false
-
-eclint_indent_style = unset
\ No newline at end of file
diff --git a/vendor/github.com/gorilla/mux/.gitignore b/vendor/github.com/gorilla/mux/.gitignore
deleted file mode 100644
index 84039fe..0000000
--- a/vendor/github.com/gorilla/mux/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-coverage.coverprofile
diff --git a/vendor/github.com/gorilla/mux/LICENSE b/vendor/github.com/gorilla/mux/LICENSE
deleted file mode 100644
index bb9d80b..0000000
--- a/vendor/github.com/gorilla/mux/LICENSE
+++ /dev/null
@@ -1,27 +0,0 @@
-Copyright (c) 2023 The Gorilla 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.
diff --git a/vendor/github.com/gorilla/mux/Makefile b/vendor/github.com/gorilla/mux/Makefile
deleted file mode 100644
index 98f5ab7..0000000
--- a/vendor/github.com/gorilla/mux/Makefile
+++ /dev/null
@@ -1,34 +0,0 @@
-GO_LINT=$(shell which golangci-lint 2> /dev/null || echo '')
-GO_LINT_URI=github.com/golangci/golangci-lint/cmd/golangci-lint@latest
-
-GO_SEC=$(shell which gosec 2> /dev/null || echo '')
-GO_SEC_URI=github.com/securego/gosec/v2/cmd/gosec@latest
-
-GO_VULNCHECK=$(shell which govulncheck 2> /dev/null || echo '')
-GO_VULNCHECK_URI=golang.org/x/vuln/cmd/govulncheck@latest
-
-.PHONY: golangci-lint
-golangci-lint:
- $(if $(GO_LINT), ,go install $(GO_LINT_URI))
- @echo "##### Running golangci-lint"
- golangci-lint run -v
-
-.PHONY: gosec
-gosec:
- $(if $(GO_SEC), ,go install $(GO_SEC_URI))
- @echo "##### Running gosec"
- gosec ./...
-
-.PHONY: govulncheck
-govulncheck:
- $(if $(GO_VULNCHECK), ,go install $(GO_VULNCHECK_URI))
- @echo "##### Running govulncheck"
- govulncheck ./...
-
-.PHONY: verify
-verify: golangci-lint gosec govulncheck
-
-.PHONY: test
-test:
- @echo "##### Running tests"
- go test -race -cover -coverprofile=coverage.coverprofile -covermode=atomic -v ./...
\ No newline at end of file
diff --git a/vendor/github.com/gorilla/mux/README.md b/vendor/github.com/gorilla/mux/README.md
deleted file mode 100644
index 382513d..0000000
--- a/vendor/github.com/gorilla/mux/README.md
+++ /dev/null
@@ -1,812 +0,0 @@
-# gorilla/mux
-
-
-[](https://codecov.io/github/gorilla/mux)
-[](https://godoc.org/github.com/gorilla/mux)
-[](https://sourcegraph.com/github.com/gorilla/mux?badge)
-
-
-
-
-Package `gorilla/mux` implements a request router and dispatcher for matching incoming requests to
-their respective handler.
-
-The name mux stands for "HTTP request multiplexer". Like the standard `http.ServeMux`, `mux.Router` matches incoming requests against a list of registered routes and calls a handler for the route that matches the URL or other conditions. The main features are:
-
-* It implements the `http.Handler` interface so it is compatible with the standard `http.ServeMux`.
-* Requests can be matched based on URL host, path, path prefix, schemes, header and query values, HTTP methods or using custom matchers.
-* URL hosts, paths and query values can have variables with an optional regular expression.
-* Registered URLs can be built, or "reversed", which helps maintaining references to resources.
-* Routes can be used as subrouters: nested routes are only tested if the parent route matches. This is useful to define groups of routes that share common conditions like a host, a path prefix or other repeated attributes. As a bonus, this optimizes request matching.
-
----
-
-* [Install](#install)
-* [Examples](#examples)
-* [Matching Routes](#matching-routes)
-* [Static Files](#static-files)
-* [Serving Single Page Applications](#serving-single-page-applications) (e.g. React, Vue, Ember.js, etc.)
-* [Registered URLs](#registered-urls)
-* [Walking Routes](#walking-routes)
-* [Graceful Shutdown](#graceful-shutdown)
-* [Middleware](#middleware)
-* [Handling CORS Requests](#handling-cors-requests)
-* [Testing Handlers](#testing-handlers)
-* [Full Example](#full-example)
-
----
-
-## Install
-
-With a [correctly configured](https://golang.org/doc/install#testing) Go toolchain:
-
-```sh
-go get -u github.com/gorilla/mux
-```
-
-## Examples
-
-Let's start registering a couple of URL paths and handlers:
-
-```go
-func main() {
- r := mux.NewRouter()
- r.HandleFunc("/", HomeHandler)
- r.HandleFunc("/products", ProductsHandler)
- r.HandleFunc("/articles", ArticlesHandler)
- http.Handle("/", r)
-}
-```
-
-Here we register three routes mapping URL paths to handlers. This is equivalent to how `http.HandleFunc()` works: if an incoming request URL matches one of the paths, the corresponding handler is called passing (`http.ResponseWriter`, `*http.Request`) as parameters.
-
-Paths can have variables. They are defined using the format `{name}` or `{name:pattern}`. If a regular expression pattern is not defined, the matched variable will be anything until the next slash. For example:
-
-```go
-r := mux.NewRouter()
-r.HandleFunc("/products/{key}", ProductHandler)
-r.HandleFunc("/articles/{category}/", ArticlesCategoryHandler)
-r.HandleFunc("/articles/{category}/{id:[0-9]+}", ArticleHandler)
-```
-
-The names are used to create a map of route variables which can be retrieved calling `mux.Vars()`:
-
-```go
-func ArticlesCategoryHandler(w http.ResponseWriter, r *http.Request) {
- vars := mux.Vars(r)
- w.WriteHeader(http.StatusOK)
- fmt.Fprintf(w, "Category: %v\n", vars["category"])
-}
-```
-
-And this is all you need to know about the basic usage. More advanced options are explained below.
-
-### Matching Routes
-
-Routes can also be restricted to a domain or subdomain. Just define a host pattern to be matched. They can also have variables:
-
-```go
-r := mux.NewRouter()
-// Only matches if domain is "www.example.com".
-r.Host("www.example.com")
-// Matches a dynamic subdomain.
-r.Host("{subdomain:[a-z]+}.example.com")
-```
-
-There are several other matchers that can be added. To match path prefixes:
-
-```go
-r.PathPrefix("/products/")
-```
-
-...or HTTP methods:
-
-```go
-r.Methods("GET", "POST")
-```
-
-...or URL schemes:
-
-```go
-r.Schemes("https")
-```
-
-...or header values:
-
-```go
-r.Headers("X-Requested-With", "XMLHttpRequest")
-```
-
-...or query values:
-
-```go
-r.Queries("key", "value")
-```
-
-...or to use a custom matcher function:
-
-```go
-r.MatcherFunc(func(r *http.Request, rm *RouteMatch) bool {
- return r.ProtoMajor == 0
-})
-```
-
-...and finally, it is possible to combine several matchers in a single route:
-
-```go
-r.HandleFunc("/products", ProductsHandler).
- Host("www.example.com").
- Methods("GET").
- Schemes("http")
-```
-
-Routes are tested in the order they were added to the router. If two routes match, the first one wins:
-
-```go
-r := mux.NewRouter()
-r.HandleFunc("/specific", specificHandler)
-r.PathPrefix("/").Handler(catchAllHandler)
-```
-
-Setting the same matching conditions again and again can be boring, so we have a way to group several routes that share the same requirements. We call it "subrouting".
-
-For example, let's say we have several URLs that should only match when the host is `www.example.com`. Create a route for that host and get a "subrouter" from it:
-
-```go
-r := mux.NewRouter()
-s := r.Host("www.example.com").Subrouter()
-```
-
-Then register routes in the subrouter:
-
-```go
-s.HandleFunc("/products/", ProductsHandler)
-s.HandleFunc("/products/{key}", ProductHandler)
-s.HandleFunc("/articles/{category}/{id:[0-9]+}", ArticleHandler)
-```
-
-The three URL paths we registered above will only be tested if the domain is `www.example.com`, because the subrouter is tested first. This is not only convenient, but also optimizes request matching. You can create subrouters combining any attribute matchers accepted by a route.
-
-Subrouters can be used to create domain or path "namespaces": you define subrouters in a central place and then parts of the app can register its paths relatively to a given subrouter.
-
-There's one more thing about subroutes. When a subrouter has a path prefix, the inner routes use it as base for their paths:
-
-```go
-r := mux.NewRouter()
-s := r.PathPrefix("/products").Subrouter()
-// "/products/"
-s.HandleFunc("/", ProductsHandler)
-// "/products/{key}/"
-s.HandleFunc("/{key}/", ProductHandler)
-// "/products/{key}/details"
-s.HandleFunc("/{key}/details", ProductDetailsHandler)
-```
-
-
-### Static Files
-
-Note that the path provided to `PathPrefix()` represents a "wildcard": calling
-`PathPrefix("/static/").Handler(...)` means that the handler will be passed any
-request that matches "/static/\*". This makes it easy to serve static files with mux:
-
-```go
-func main() {
- var dir string
-
- flag.StringVar(&dir, "dir", ".", "the directory to serve files from. Defaults to the current dir")
- flag.Parse()
- r := mux.NewRouter()
-
- // This will serve files under http://localhost:8000/static/
- r.PathPrefix("/static/").Handler(http.StripPrefix("/static/", http.FileServer(http.Dir(dir))))
-
- srv := &http.Server{
- Handler: r,
- Addr: "127.0.0.1:8000",
- // Good practice: enforce timeouts for servers you create!
- WriteTimeout: 15 * time.Second,
- ReadTimeout: 15 * time.Second,
- }
-
- log.Fatal(srv.ListenAndServe())
-}
-```
-
-### Serving Single Page Applications
-
-Most of the time it makes sense to serve your SPA on a separate web server from your API,
-but sometimes it's desirable to serve them both from one place. It's possible to write a simple
-handler for serving your SPA (for use with React Router's [BrowserRouter](https://reacttraining.com/react-router/web/api/BrowserRouter) for example), and leverage
-mux's powerful routing for your API endpoints.
-
-```go
-package main
-
-import (
- "encoding/json"
- "log"
- "net/http"
- "os"
- "path/filepath"
- "time"
-
- "github.com/gorilla/mux"
-)
-
-// spaHandler implements the http.Handler interface, so we can use it
-// to respond to HTTP requests. The path to the static directory and
-// path to the index file within that static directory are used to
-// serve the SPA in the given static directory.
-type spaHandler struct {
- staticPath string
- indexPath string
-}
-
-// ServeHTTP inspects the URL path to locate a file within the static dir
-// on the SPA handler. If a file is found, it will be served. If not, the
-// file located at the index path on the SPA handler will be served. This
-// is suitable behavior for serving an SPA (single page application).
-func (h spaHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
- // Join internally call path.Clean to prevent directory traversal
- path := filepath.Join(h.staticPath, r.URL.Path)
-
- // check whether a file exists or is a directory at the given path
- fi, err := os.Stat(path)
- if os.IsNotExist(err) || fi.IsDir() {
- // file does not exist or path is a directory, serve index.html
- http.ServeFile(w, r, filepath.Join(h.staticPath, h.indexPath))
- return
- }
-
- if err != nil {
- // if we got an error (that wasn't that the file doesn't exist) stating the
- // file, return a 500 internal server error and stop
- http.Error(w, err.Error(), http.StatusInternalServerError)
- return
- }
-
- // otherwise, use http.FileServer to serve the static file
- http.FileServer(http.Dir(h.staticPath)).ServeHTTP(w, r)
-}
-
-func main() {
- router := mux.NewRouter()
-
- router.HandleFunc("/api/health", func(w http.ResponseWriter, r *http.Request) {
- // an example API handler
- json.NewEncoder(w).Encode(map[string]bool{"ok": true})
- })
-
- spa := spaHandler{staticPath: "build", indexPath: "index.html"}
- router.PathPrefix("/").Handler(spa)
-
- srv := &http.Server{
- Handler: router,
- Addr: "127.0.0.1:8000",
- // Good practice: enforce timeouts for servers you create!
- WriteTimeout: 15 * time.Second,
- ReadTimeout: 15 * time.Second,
- }
-
- log.Fatal(srv.ListenAndServe())
-}
-```
-
-### Registered URLs
-
-Now let's see how to build registered URLs.
-
-Routes can be named. All routes that define a name can have their URLs built, or "reversed". We define a name calling `Name()` on a route. For example:
-
-```go
-r := mux.NewRouter()
-r.HandleFunc("/articles/{category}/{id:[0-9]+}", ArticleHandler).
- Name("article")
-```
-
-To build a URL, get the route and call the `URL()` method, passing a sequence of key/value pairs for the route variables. For the previous route, we would do:
-
-```go
-url, err := r.Get("article").URL("category", "technology", "id", "42")
-```
-
-...and the result will be a `url.URL` with the following path:
-
-```
-"/articles/technology/42"
-```
-
-This also works for host and query value variables:
-
-```go
-r := mux.NewRouter()
-r.Host("{subdomain}.example.com").
- Path("/articles/{category}/{id:[0-9]+}").
- Queries("filter", "{filter}").
- HandlerFunc(ArticleHandler).
- Name("article")
-
-// url.String() will be "http://news.example.com/articles/technology/42?filter=gorilla"
-url, err := r.Get("article").URL("subdomain", "news",
- "category", "technology",
- "id", "42",
- "filter", "gorilla")
-```
-
-All variables defined in the route are required, and their values must conform to the corresponding patterns. These requirements guarantee that a generated URL will always match a registered route -- the only exception is for explicitly defined "build-only" routes which never match.
-
-Regex support also exists for matching Headers within a route. For example, we could do:
-
-```go
-r.HeadersRegexp("Content-Type", "application/(text|json)")
-```
-
-...and the route will match both requests with a Content-Type of `application/json` as well as `application/text`
-
-There's also a way to build only the URL host or path for a route: use the methods `URLHost()` or `URLPath()` instead. For the previous route, we would do:
-
-```go
-// "http://news.example.com/"
-host, err := r.Get("article").URLHost("subdomain", "news")
-
-// "/articles/technology/42"
-path, err := r.Get("article").URLPath("category", "technology", "id", "42")
-```
-
-And if you use subrouters, host and path defined separately can be built as well:
-
-```go
-r := mux.NewRouter()
-s := r.Host("{subdomain}.example.com").Subrouter()
-s.Path("/articles/{category}/{id:[0-9]+}").
- HandlerFunc(ArticleHandler).
- Name("article")
-
-// "http://news.example.com/articles/technology/42"
-url, err := r.Get("article").URL("subdomain", "news",
- "category", "technology",
- "id", "42")
-```
-
-To find all the required variables for a given route when calling `URL()`, the method `GetVarNames()` is available:
-```go
-r := mux.NewRouter()
-r.Host("{domain}").
- Path("/{group}/{item_id}").
- Queries("some_data1", "{some_data1}").
- Queries("some_data2", "{some_data2}").
- Name("article")
-
-// Will print [domain group item_id some_data1 some_data2]
-fmt.Println(r.Get("article").GetVarNames())
-
-```
-### Walking Routes
-
-The `Walk` function on `mux.Router` can be used to visit all of the routes that are registered on a router. For example,
-the following prints all of the registered routes:
-
-```go
-package main
-
-import (
- "fmt"
- "net/http"
- "strings"
-
- "github.com/gorilla/mux"
-)
-
-func handler(w http.ResponseWriter, r *http.Request) {
- return
-}
-
-func main() {
- r := mux.NewRouter()
- r.HandleFunc("/", handler)
- r.HandleFunc("/products", handler).Methods("POST")
- r.HandleFunc("/articles", handler).Methods("GET")
- r.HandleFunc("/articles/{id}", handler).Methods("GET", "PUT")
- r.HandleFunc("/authors", handler).Queries("surname", "{surname}")
- err := r.Walk(func(route *mux.Route, router *mux.Router, ancestors []*mux.Route) error {
- pathTemplate, err := route.GetPathTemplate()
- if err == nil {
- fmt.Println("ROUTE:", pathTemplate)
- }
- pathRegexp, err := route.GetPathRegexp()
- if err == nil {
- fmt.Println("Path regexp:", pathRegexp)
- }
- queriesTemplates, err := route.GetQueriesTemplates()
- if err == nil {
- fmt.Println("Queries templates:", strings.Join(queriesTemplates, ","))
- }
- queriesRegexps, err := route.GetQueriesRegexp()
- if err == nil {
- fmt.Println("Queries regexps:", strings.Join(queriesRegexps, ","))
- }
- methods, err := route.GetMethods()
- if err == nil {
- fmt.Println("Methods:", strings.Join(methods, ","))
- }
- fmt.Println()
- return nil
- })
-
- if err != nil {
- fmt.Println(err)
- }
-
- http.Handle("/", r)
-}
-```
-
-### Graceful Shutdown
-
-Go 1.8 introduced the ability to [gracefully shutdown](https://golang.org/doc/go1.8#http_shutdown) a `*http.Server`. Here's how to do that alongside `mux`:
-
-```go
-package main
-
-import (
- "context"
- "flag"
- "log"
- "net/http"
- "os"
- "os/signal"
- "time"
-
- "github.com/gorilla/mux"
-)
-
-func main() {
- var wait time.Duration
- flag.DurationVar(&wait, "graceful-timeout", time.Second * 15, "the duration for which the server gracefully wait for existing connections to finish - e.g. 15s or 1m")
- flag.Parse()
-
- r := mux.NewRouter()
- // Add your routes as needed
-
- srv := &http.Server{
- Addr: "0.0.0.0:8080",
- // Good practice to set timeouts to avoid Slowloris attacks.
- WriteTimeout: time.Second * 15,
- ReadTimeout: time.Second * 15,
- IdleTimeout: time.Second * 60,
- Handler: r, // Pass our instance of gorilla/mux in.
- }
-
- // Run our server in a goroutine so that it doesn't block.
- go func() {
- if err := srv.ListenAndServe(); err != nil {
- log.Println(err)
- }
- }()
-
- c := make(chan os.Signal, 1)
- // We'll accept graceful shutdowns when quit via SIGINT (Ctrl+C)
- // SIGKILL, SIGQUIT or SIGTERM (Ctrl+/) will not be caught.
- signal.Notify(c, os.Interrupt)
-
- // Block until we receive our signal.
- <-c
-
- // Create a deadline to wait for.
- ctx, cancel := context.WithTimeout(context.Background(), wait)
- defer cancel()
- // Doesn't block if no connections, but will otherwise wait
- // until the timeout deadline.
- srv.Shutdown(ctx)
- // Optionally, you could run srv.Shutdown in a goroutine and block on
- // <-ctx.Done() if your application should wait for other services
- // to finalize based on context cancellation.
- log.Println("shutting down")
- os.Exit(0)
-}
-```
-
-### Middleware
-
-Mux supports the addition of middlewares to a [Router](https://godoc.org/github.com/gorilla/mux#Router), which are executed in the order they are added if a match is found, including its subrouters.
-Middlewares are (typically) small pieces of code which take one request, do something with it, and pass it down to another middleware or the final handler. Some common use cases for middleware are request logging, header manipulation, or `ResponseWriter` hijacking.
-
-Mux middlewares are defined using the de facto standard type:
-
-```go
-type MiddlewareFunc func(http.Handler) http.Handler
-```
-
-Typically, the returned handler is a closure which does something with the http.ResponseWriter and http.Request passed to it, and then calls the handler passed as parameter to the MiddlewareFunc. This takes advantage of closures being able access variables from the context where they are created, while retaining the signature enforced by the receivers.
-
-A very basic middleware which logs the URI of the request being handled could be written as:
-
-```go
-func loggingMiddleware(next http.Handler) http.Handler {
- return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
- // Do stuff here
- log.Println(r.RequestURI)
- // Call the next handler, which can be another middleware in the chain, or the final handler.
- next.ServeHTTP(w, r)
- })
-}
-```
-
-Middlewares can be added to a router using `Router.Use()`:
-
-```go
-r := mux.NewRouter()
-r.HandleFunc("/", handler)
-r.Use(loggingMiddleware)
-```
-
-A more complex authentication middleware, which maps session token to users, could be written as:
-
-```go
-// Define our struct
-type authenticationMiddleware struct {
- tokenUsers map[string]string
-}
-
-// Initialize it somewhere
-func (amw *authenticationMiddleware) Populate() {
- amw.tokenUsers["00000000"] = "user0"
- amw.tokenUsers["aaaaaaaa"] = "userA"
- amw.tokenUsers["05f717e5"] = "randomUser"
- amw.tokenUsers["deadbeef"] = "user0"
-}
-
-// Middleware function, which will be called for each request
-func (amw *authenticationMiddleware) Middleware(next http.Handler) http.Handler {
- return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
- token := r.Header.Get("X-Session-Token")
-
- if user, found := amw.tokenUsers[token]; found {
- // We found the token in our map
- log.Printf("Authenticated user %s\n", user)
- // Pass down the request to the next middleware (or final handler)
- next.ServeHTTP(w, r)
- } else {
- // Write an error and stop the handler chain
- http.Error(w, "Forbidden", http.StatusForbidden)
- }
- })
-}
-```
-
-```go
-r := mux.NewRouter()
-r.HandleFunc("/", handler)
-
-amw := authenticationMiddleware{tokenUsers: make(map[string]string)}
-amw.Populate()
-
-r.Use(amw.Middleware)
-```
-
-Note: The handler chain will be stopped if your middleware doesn't call `next.ServeHTTP()` with the corresponding parameters. This can be used to abort a request if the middleware writer wants to. Middlewares _should_ write to `ResponseWriter` if they _are_ going to terminate the request, and they _should not_ write to `ResponseWriter` if they _are not_ going to terminate it.
-
-### Handling CORS Requests
-
-[CORSMethodMiddleware](https://godoc.org/github.com/gorilla/mux#CORSMethodMiddleware) intends to make it easier to strictly set the `Access-Control-Allow-Methods` response header.
-
-* You will still need to use your own CORS handler to set the other CORS headers such as `Access-Control-Allow-Origin`
-* The middleware will set the `Access-Control-Allow-Methods` header to all the method matchers (e.g. `r.Methods(http.MethodGet, http.MethodPut, http.MethodOptions)` -> `Access-Control-Allow-Methods: GET,PUT,OPTIONS`) on a route
-* If you do not specify any methods, then:
-> _Important_: there must be an `OPTIONS` method matcher for the middleware to set the headers.
-
-Here is an example of using `CORSMethodMiddleware` along with a custom `OPTIONS` handler to set all the required CORS headers:
-
-```go
-package main
-
-import (
- "net/http"
- "github.com/gorilla/mux"
-)
-
-func main() {
- r := mux.NewRouter()
-
- // IMPORTANT: you must specify an OPTIONS method matcher for the middleware to set CORS headers
- r.HandleFunc("/foo", fooHandler).Methods(http.MethodGet, http.MethodPut, http.MethodPatch, http.MethodOptions)
- r.Use(mux.CORSMethodMiddleware(r))
-
- http.ListenAndServe(":8080", r)
-}
-
-func fooHandler(w http.ResponseWriter, r *http.Request) {
- w.Header().Set("Access-Control-Allow-Origin", "*")
- if r.Method == http.MethodOptions {
- return
- }
-
- w.Write([]byte("foo"))
-}
-```
-
-And an request to `/foo` using something like:
-
-```bash
-curl localhost:8080/foo -v
-```
-
-Would look like:
-
-```bash
-* Trying ::1...
-* TCP_NODELAY set
-* Connected to localhost (::1) port 8080 (#0)
-> GET /foo HTTP/1.1
-> Host: localhost:8080
-> User-Agent: curl/7.59.0
-> Accept: */*
->
-< HTTP/1.1 200 OK
-< Access-Control-Allow-Methods: GET,PUT,PATCH,OPTIONS
-< Access-Control-Allow-Origin: *
-< Date: Fri, 28 Jun 2019 20:13:30 GMT
-< Content-Length: 3
-< Content-Type: text/plain; charset=utf-8
-<
-* Connection #0 to host localhost left intact
-foo
-```
-
-### Testing Handlers
-
-Testing handlers in a Go web application is straightforward, and _mux_ doesn't complicate this any further. Given two files: `endpoints.go` and `endpoints_test.go`, here's how we'd test an application using _mux_.
-
-First, our simple HTTP handler:
-
-```go
-// endpoints.go
-package main
-
-func HealthCheckHandler(w http.ResponseWriter, r *http.Request) {
- // A very simple health check.
- w.Header().Set("Content-Type", "application/json")
- w.WriteHeader(http.StatusOK)
-
- // In the future we could report back on the status of our DB, or our cache
- // (e.g. Redis) by performing a simple PING, and include them in the response.
- io.WriteString(w, `{"alive": true}`)
-}
-
-func main() {
- r := mux.NewRouter()
- r.HandleFunc("/health", HealthCheckHandler)
-
- log.Fatal(http.ListenAndServe("localhost:8080", r))
-}
-```
-
-Our test code:
-
-```go
-// endpoints_test.go
-package main
-
-import (
- "net/http"
- "net/http/httptest"
- "testing"
-)
-
-func TestHealthCheckHandler(t *testing.T) {
- // Create a request to pass to our handler. We don't have any query parameters for now, so we'll
- // pass 'nil' as the third parameter.
- req, err := http.NewRequest("GET", "/health", nil)
- if err != nil {
- t.Fatal(err)
- }
-
- // We create a ResponseRecorder (which satisfies http.ResponseWriter) to record the response.
- rr := httptest.NewRecorder()
- handler := http.HandlerFunc(HealthCheckHandler)
-
- // Our handlers satisfy http.Handler, so we can call their ServeHTTP method
- // directly and pass in our Request and ResponseRecorder.
- handler.ServeHTTP(rr, req)
-
- // Check the status code is what we expect.
- if status := rr.Code; status != http.StatusOK {
- t.Errorf("handler returned wrong status code: got %v want %v",
- status, http.StatusOK)
- }
-
- // Check the response body is what we expect.
- expected := `{"alive": true}`
- if rr.Body.String() != expected {
- t.Errorf("handler returned unexpected body: got %v want %v",
- rr.Body.String(), expected)
- }
-}
-```
-
-In the case that our routes have [variables](#examples), we can pass those in the request. We could write
-[table-driven tests](https://dave.cheney.net/2013/06/09/writing-table-driven-tests-in-go) to test multiple
-possible route variables as needed.
-
-```go
-// endpoints.go
-func main() {
- r := mux.NewRouter()
- // A route with a route variable:
- r.HandleFunc("/metrics/{type}", MetricsHandler)
-
- log.Fatal(http.ListenAndServe("localhost:8080", r))
-}
-```
-
-Our test file, with a table-driven test of `routeVariables`:
-
-```go
-// endpoints_test.go
-func TestMetricsHandler(t *testing.T) {
- tt := []struct{
- routeVariable string
- shouldPass bool
- }{
- {"goroutines", true},
- {"heap", true},
- {"counters", true},
- {"queries", true},
- {"adhadaeqm3k", false},
- }
-
- for _, tc := range tt {
- path := fmt.Sprintf("/metrics/%s", tc.routeVariable)
- req, err := http.NewRequest("GET", path, nil)
- if err != nil {
- t.Fatal(err)
- }
-
- rr := httptest.NewRecorder()
-
- // To add the vars to the context,
- // we need to create a router through which we can pass the request.
- router := mux.NewRouter()
- router.HandleFunc("/metrics/{type}", MetricsHandler)
- router.ServeHTTP(rr, req)
-
- // In this case, our MetricsHandler returns a non-200 response
- // for a route variable it doesn't know about.
- if rr.Code == http.StatusOK && !tc.shouldPass {
- t.Errorf("handler should have failed on routeVariable %s: got %v want %v",
- tc.routeVariable, rr.Code, http.StatusOK)
- }
- }
-}
-```
-
-## Full Example
-
-Here's a complete, runnable example of a small `mux` based server:
-
-```go
-package main
-
-import (
- "net/http"
- "log"
- "github.com/gorilla/mux"
-)
-
-func YourHandler(w http.ResponseWriter, r *http.Request) {
- w.Write([]byte("Gorilla!\n"))
-}
-
-func main() {
- r := mux.NewRouter()
- // Routes consist of a path and a handler function.
- r.HandleFunc("/", YourHandler)
-
- // Bind to a port and pass our router in
- log.Fatal(http.ListenAndServe(":8000", r))
-}
-```
-
-## License
-
-BSD licensed. See the LICENSE file for details.
diff --git a/vendor/github.com/gorilla/mux/doc.go b/vendor/github.com/gorilla/mux/doc.go
deleted file mode 100644
index 8060135..0000000
--- a/vendor/github.com/gorilla/mux/doc.go
+++ /dev/null
@@ -1,305 +0,0 @@
-// Copyright 2012 The Gorilla Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-/*
-Package mux implements a request router and dispatcher.
-
-The name mux stands for "HTTP request multiplexer". Like the standard
-http.ServeMux, mux.Router matches incoming requests against a list of
-registered routes and calls a handler for the route that matches the URL
-or other conditions. The main features are:
-
- - Requests can be matched based on URL host, path, path prefix, schemes,
- header and query values, HTTP methods or using custom matchers.
- - URL hosts, paths and query values can have variables with an optional
- regular expression.
- - Registered URLs can be built, or "reversed", which helps maintaining
- references to resources.
- - Routes can be used as subrouters: nested routes are only tested if the
- parent route matches. This is useful to define groups of routes that
- share common conditions like a host, a path prefix or other repeated
- attributes. As a bonus, this optimizes request matching.
- - It implements the http.Handler interface so it is compatible with the
- standard http.ServeMux.
-
-Let's start registering a couple of URL paths and handlers:
-
- func main() {
- r := mux.NewRouter()
- r.HandleFunc("/", HomeHandler)
- r.HandleFunc("/products", ProductsHandler)
- r.HandleFunc("/articles", ArticlesHandler)
- http.Handle("/", r)
- }
-
-Here we register three routes mapping URL paths to handlers. This is
-equivalent to how http.HandleFunc() works: if an incoming request URL matches
-one of the paths, the corresponding handler is called passing
-(http.ResponseWriter, *http.Request) as parameters.
-
-Paths can have variables. They are defined using the format {name} or
-{name:pattern}. If a regular expression pattern is not defined, the matched
-variable will be anything until the next slash. For example:
-
- r := mux.NewRouter()
- r.HandleFunc("/products/{key}", ProductHandler)
- r.HandleFunc("/articles/{category}/", ArticlesCategoryHandler)
- r.HandleFunc("/articles/{category}/{id:[0-9]+}", ArticleHandler)
-
-Groups can be used inside patterns, as long as they are non-capturing (?:re). For example:
-
- r.HandleFunc("/articles/{category}/{sort:(?:asc|desc|new)}", ArticlesCategoryHandler)
-
-The names are used to create a map of route variables which can be retrieved
-calling mux.Vars():
-
- vars := mux.Vars(request)
- category := vars["category"]
-
-Note that if any capturing groups are present, mux will panic() during parsing. To prevent
-this, convert any capturing groups to non-capturing, e.g. change "/{sort:(asc|desc)}" to
-"/{sort:(?:asc|desc)}". This is a change from prior versions which behaved unpredictably
-when capturing groups were present.
-
-And this is all you need to know about the basic usage. More advanced options
-are explained below.
-
-Routes can also be restricted to a domain or subdomain. Just define a host
-pattern to be matched. They can also have variables:
-
- r := mux.NewRouter()
- // Only matches if domain is "www.example.com".
- r.Host("www.example.com")
- // Matches a dynamic subdomain.
- r.Host("{subdomain:[a-z]+}.domain.com")
-
-There are several other matchers that can be added. To match path prefixes:
-
- r.PathPrefix("/products/")
-
-...or HTTP methods:
-
- r.Methods("GET", "POST")
-
-...or URL schemes:
-
- r.Schemes("https")
-
-...or header values:
-
- r.Headers("X-Requested-With", "XMLHttpRequest")
-
-...or query values:
-
- r.Queries("key", "value")
-
-...or to use a custom matcher function:
-
- r.MatcherFunc(func(r *http.Request, rm *RouteMatch) bool {
- return r.ProtoMajor == 0
- })
-
-...and finally, it is possible to combine several matchers in a single route:
-
- r.HandleFunc("/products", ProductsHandler).
- Host("www.example.com").
- Methods("GET").
- Schemes("http")
-
-Setting the same matching conditions again and again can be boring, so we have
-a way to group several routes that share the same requirements.
-We call it "subrouting".
-
-For example, let's say we have several URLs that should only match when the
-host is "www.example.com". Create a route for that host and get a "subrouter"
-from it:
-
- r := mux.NewRouter()
- s := r.Host("www.example.com").Subrouter()
-
-Then register routes in the subrouter:
-
- s.HandleFunc("/products/", ProductsHandler)
- s.HandleFunc("/products/{key}", ProductHandler)
- s.HandleFunc("/articles/{category}/{id:[0-9]+}"), ArticleHandler)
-
-The three URL paths we registered above will only be tested if the domain is
-"www.example.com", because the subrouter is tested first. This is not
-only convenient, but also optimizes request matching. You can create
-subrouters combining any attribute matchers accepted by a route.
-
-Subrouters can be used to create domain or path "namespaces": you define
-subrouters in a central place and then parts of the app can register its
-paths relatively to a given subrouter.
-
-There's one more thing about subroutes. When a subrouter has a path prefix,
-the inner routes use it as base for their paths:
-
- r := mux.NewRouter()
- s := r.PathPrefix("/products").Subrouter()
- // "/products/"
- s.HandleFunc("/", ProductsHandler)
- // "/products/{key}/"
- s.HandleFunc("/{key}/", ProductHandler)
- // "/products/{key}/details"
- s.HandleFunc("/{key}/details", ProductDetailsHandler)
-
-Note that the path provided to PathPrefix() represents a "wildcard": calling
-PathPrefix("/static/").Handler(...) means that the handler will be passed any
-request that matches "/static/*". This makes it easy to serve static files with mux:
-
- func main() {
- var dir string
-
- flag.StringVar(&dir, "dir", ".", "the directory to serve files from. Defaults to the current dir")
- flag.Parse()
- r := mux.NewRouter()
-
- // This will serve files under http://localhost:8000/static/
- r.PathPrefix("/static/").Handler(http.StripPrefix("/static/", http.FileServer(http.Dir(dir))))
-
- srv := &http.Server{
- Handler: r,
- Addr: "127.0.0.1:8000",
- // Good practice: enforce timeouts for servers you create!
- WriteTimeout: 15 * time.Second,
- ReadTimeout: 15 * time.Second,
- }
-
- log.Fatal(srv.ListenAndServe())
- }
-
-Now let's see how to build registered URLs.
-
-Routes can be named. All routes that define a name can have their URLs built,
-or "reversed". We define a name calling Name() on a route. For example:
-
- r := mux.NewRouter()
- r.HandleFunc("/articles/{category}/{id:[0-9]+}", ArticleHandler).
- Name("article")
-
-To build a URL, get the route and call the URL() method, passing a sequence of
-key/value pairs for the route variables. For the previous route, we would do:
-
- url, err := r.Get("article").URL("category", "technology", "id", "42")
-
-...and the result will be a url.URL with the following path:
-
- "/articles/technology/42"
-
-This also works for host and query value variables:
-
- r := mux.NewRouter()
- r.Host("{subdomain}.domain.com").
- Path("/articles/{category}/{id:[0-9]+}").
- Queries("filter", "{filter}").
- HandlerFunc(ArticleHandler).
- Name("article")
-
- // url.String() will be "http://news.domain.com/articles/technology/42?filter=gorilla"
- url, err := r.Get("article").URL("subdomain", "news",
- "category", "technology",
- "id", "42",
- "filter", "gorilla")
-
-All variables defined in the route are required, and their values must
-conform to the corresponding patterns. These requirements guarantee that a
-generated URL will always match a registered route -- the only exception is
-for explicitly defined "build-only" routes which never match.
-
-Regex support also exists for matching Headers within a route. For example, we could do:
-
- r.HeadersRegexp("Content-Type", "application/(text|json)")
-
-...and the route will match both requests with a Content-Type of `application/json` as well as
-`application/text`
-
-There's also a way to build only the URL host or path for a route:
-use the methods URLHost() or URLPath() instead. For the previous route,
-we would do:
-
- // "http://news.domain.com/"
- host, err := r.Get("article").URLHost("subdomain", "news")
-
- // "/articles/technology/42"
- path, err := r.Get("article").URLPath("category", "technology", "id", "42")
-
-And if you use subrouters, host and path defined separately can be built
-as well:
-
- r := mux.NewRouter()
- s := r.Host("{subdomain}.domain.com").Subrouter()
- s.Path("/articles/{category}/{id:[0-9]+}").
- HandlerFunc(ArticleHandler).
- Name("article")
-
- // "http://news.domain.com/articles/technology/42"
- url, err := r.Get("article").URL("subdomain", "news",
- "category", "technology",
- "id", "42")
-
-Mux supports the addition of middlewares to a Router, which are executed in the order they are added if a match is found, including its subrouters. Middlewares are (typically) small pieces of code which take one request, do something with it, and pass it down to another middleware or the final handler. Some common use cases for middleware are request logging, header manipulation, or ResponseWriter hijacking.
-
- type MiddlewareFunc func(http.Handler) http.Handler
-
-Typically, the returned handler is a closure which does something with the http.ResponseWriter and http.Request passed to it, and then calls the handler passed as parameter to the MiddlewareFunc (closures can access variables from the context where they are created).
-
-A very basic middleware which logs the URI of the request being handled could be written as:
-
- func simpleMw(next http.Handler) http.Handler {
- return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
- // Do stuff here
- log.Println(r.RequestURI)
- // Call the next handler, which can be another middleware in the chain, or the final handler.
- next.ServeHTTP(w, r)
- })
- }
-
-Middlewares can be added to a router using `Router.Use()`:
-
- r := mux.NewRouter()
- r.HandleFunc("/", handler)
- r.Use(simpleMw)
-
-A more complex authentication middleware, which maps session token to users, could be written as:
-
- // Define our struct
- type authenticationMiddleware struct {
- tokenUsers map[string]string
- }
-
- // Initialize it somewhere
- func (amw *authenticationMiddleware) Populate() {
- amw.tokenUsers["00000000"] = "user0"
- amw.tokenUsers["aaaaaaaa"] = "userA"
- amw.tokenUsers["05f717e5"] = "randomUser"
- amw.tokenUsers["deadbeef"] = "user0"
- }
-
- // Middleware function, which will be called for each request
- func (amw *authenticationMiddleware) Middleware(next http.Handler) http.Handler {
- return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
- token := r.Header.Get("X-Session-Token")
-
- if user, found := amw.tokenUsers[token]; found {
- // We found the token in our map
- log.Printf("Authenticated user %s\n", user)
- next.ServeHTTP(w, r)
- } else {
- http.Error(w, "Forbidden", http.StatusForbidden)
- }
- })
- }
-
- r := mux.NewRouter()
- r.HandleFunc("/", handler)
-
- amw := authenticationMiddleware{tokenUsers: make(map[string]string)}
- amw.Populate()
-
- r.Use(amw.Middleware)
-
-Note: The handler chain will be stopped if your middleware doesn't call `next.ServeHTTP()` with the corresponding parameters. This can be used to abort a request if the middleware writer wants to.
-*/
-package mux
diff --git a/vendor/github.com/gorilla/mux/middleware.go b/vendor/github.com/gorilla/mux/middleware.go
deleted file mode 100644
index cb51c56..0000000
--- a/vendor/github.com/gorilla/mux/middleware.go
+++ /dev/null
@@ -1,74 +0,0 @@
-package mux
-
-import (
- "net/http"
- "strings"
-)
-
-// MiddlewareFunc is a function which receives an http.Handler and returns another http.Handler.
-// Typically, the returned handler is a closure which does something with the http.ResponseWriter and http.Request passed
-// to it, and then calls the handler passed as parameter to the MiddlewareFunc.
-type MiddlewareFunc func(http.Handler) http.Handler
-
-// middleware interface is anything which implements a MiddlewareFunc named Middleware.
-type middleware interface {
- Middleware(handler http.Handler) http.Handler
-}
-
-// Middleware allows MiddlewareFunc to implement the middleware interface.
-func (mw MiddlewareFunc) Middleware(handler http.Handler) http.Handler {
- return mw(handler)
-}
-
-// Use appends a MiddlewareFunc to the chain. Middleware can be used to intercept or otherwise modify requests and/or responses, and are executed in the order that they are applied to the Router.
-func (r *Router) Use(mwf ...MiddlewareFunc) {
- for _, fn := range mwf {
- r.middlewares = append(r.middlewares, fn)
- }
-}
-
-// useInterface appends a middleware to the chain. Middleware can be used to intercept or otherwise modify requests and/or responses, and are executed in the order that they are applied to the Router.
-func (r *Router) useInterface(mw middleware) {
- r.middlewares = append(r.middlewares, mw)
-}
-
-// CORSMethodMiddleware automatically sets the Access-Control-Allow-Methods response header
-// on requests for routes that have an OPTIONS method matcher to all the method matchers on
-// the route. Routes that do not explicitly handle OPTIONS requests will not be processed
-// by the middleware. See examples for usage.
-func CORSMethodMiddleware(r *Router) MiddlewareFunc {
- return func(next http.Handler) http.Handler {
- return http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
- allMethods, err := getAllMethodsForRoute(r, req)
- if err == nil {
- for _, v := range allMethods {
- if v == http.MethodOptions {
- w.Header().Set("Access-Control-Allow-Methods", strings.Join(allMethods, ","))
- }
- }
- }
-
- next.ServeHTTP(w, req)
- })
- }
-}
-
-// getAllMethodsForRoute returns all the methods from method matchers matching a given
-// request.
-func getAllMethodsForRoute(r *Router, req *http.Request) ([]string, error) {
- var allMethods []string
-
- for _, route := range r.routes {
- var match RouteMatch
- if route.Match(req, &match) || match.MatchErr == ErrMethodMismatch {
- methods, err := route.GetMethods()
- if err != nil {
- return nil, err
- }
-
- allMethods = append(allMethods, methods...)
- }
- }
-
- return allMethods, nil
-}
diff --git a/vendor/github.com/gorilla/mux/mux.go b/vendor/github.com/gorilla/mux/mux.go
deleted file mode 100644
index 1e08990..0000000
--- a/vendor/github.com/gorilla/mux/mux.go
+++ /dev/null
@@ -1,608 +0,0 @@
-// Copyright 2012 The Gorilla Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package mux
-
-import (
- "context"
- "errors"
- "fmt"
- "net/http"
- "path"
- "regexp"
-)
-
-var (
- // ErrMethodMismatch is returned when the method in the request does not match
- // the method defined against the route.
- ErrMethodMismatch = errors.New("method is not allowed")
- // ErrNotFound is returned when no route match is found.
- ErrNotFound = errors.New("no matching route was found")
-)
-
-// NewRouter returns a new router instance.
-func NewRouter() *Router {
- return &Router{namedRoutes: make(map[string]*Route)}
-}
-
-// Router registers routes to be matched and dispatches a handler.
-//
-// It implements the http.Handler interface, so it can be registered to serve
-// requests:
-//
-// var router = mux.NewRouter()
-//
-// func main() {
-// http.Handle("/", router)
-// }
-//
-// Or, for Google App Engine, register it in a init() function:
-//
-// func init() {
-// http.Handle("/", router)
-// }
-//
-// This will send all incoming requests to the router.
-type Router struct {
- // Configurable Handler to be used when no route matches.
- // This can be used to render your own 404 Not Found errors.
- NotFoundHandler http.Handler
-
- // Configurable Handler to be used when the request method does not match the route.
- // This can be used to render your own 405 Method Not Allowed errors.
- MethodNotAllowedHandler http.Handler
-
- // Routes to be matched, in order.
- routes []*Route
-
- // Routes by name for URL building.
- namedRoutes map[string]*Route
-
- // If true, do not clear the request context after handling the request.
- //
- // Deprecated: No effect, since the context is stored on the request itself.
- KeepContext bool
-
- // Slice of middlewares to be called after a match is found
- middlewares []middleware
-
- // configuration shared with `Route`
- routeConf
-}
-
-// common route configuration shared between `Router` and `Route`
-type routeConf struct {
- // If true, "/path/foo%2Fbar/to" will match the path "/path/{var}/to"
- useEncodedPath bool
-
- // If true, when the path pattern is "/path/", accessing "/path" will
- // redirect to the former and vice versa.
- strictSlash bool
-
- // If true, when the path pattern is "/path//to", accessing "/path//to"
- // will not redirect
- skipClean bool
-
- // Manager for the variables from host and path.
- regexp routeRegexpGroup
-
- // List of matchers.
- matchers []matcher
-
- // The scheme used when building URLs.
- buildScheme string
-
- buildVarsFunc BuildVarsFunc
-}
-
-// returns an effective deep copy of `routeConf`
-func copyRouteConf(r routeConf) routeConf {
- c := r
-
- if r.regexp.path != nil {
- c.regexp.path = copyRouteRegexp(r.regexp.path)
- }
-
- if r.regexp.host != nil {
- c.regexp.host = copyRouteRegexp(r.regexp.host)
- }
-
- c.regexp.queries = make([]*routeRegexp, 0, len(r.regexp.queries))
- for _, q := range r.regexp.queries {
- c.regexp.queries = append(c.regexp.queries, copyRouteRegexp(q))
- }
-
- c.matchers = make([]matcher, len(r.matchers))
- copy(c.matchers, r.matchers)
-
- return c
-}
-
-func copyRouteRegexp(r *routeRegexp) *routeRegexp {
- c := *r
- return &c
-}
-
-// Match attempts to match the given request against the router's registered routes.
-//
-// If the request matches a route of this router or one of its subrouters the Route,
-// Handler, and Vars fields of the the match argument are filled and this function
-// returns true.
-//
-// If the request does not match any of this router's or its subrouters' routes
-// then this function returns false. If available, a reason for the match failure
-// will be filled in the match argument's MatchErr field. If the match failure type
-// (eg: not found) has a registered handler, the handler is assigned to the Handler
-// field of the match argument.
-func (r *Router) Match(req *http.Request, match *RouteMatch) bool {
- for _, route := range r.routes {
- if route.Match(req, match) {
- // Build middleware chain if no error was found
- if match.MatchErr == nil {
- for i := len(r.middlewares) - 1; i >= 0; i-- {
- match.Handler = r.middlewares[i].Middleware(match.Handler)
- }
- }
- return true
- }
- }
-
- if match.MatchErr == ErrMethodMismatch {
- if r.MethodNotAllowedHandler != nil {
- match.Handler = r.MethodNotAllowedHandler
- return true
- }
-
- return false
- }
-
- // Closest match for a router (includes sub-routers)
- if r.NotFoundHandler != nil {
- match.Handler = r.NotFoundHandler
- match.MatchErr = ErrNotFound
- return true
- }
-
- match.MatchErr = ErrNotFound
- return false
-}
-
-// ServeHTTP dispatches the handler registered in the matched route.
-//
-// When there is a match, the route variables can be retrieved calling
-// mux.Vars(request).
-func (r *Router) ServeHTTP(w http.ResponseWriter, req *http.Request) {
- if !r.skipClean {
- path := req.URL.Path
- if r.useEncodedPath {
- path = req.URL.EscapedPath()
- }
- // Clean path to canonical form and redirect.
- if p := cleanPath(path); p != path {
-
- // Added 3 lines (Philip Schlump) - It was dropping the query string and #whatever from query.
- // This matches with fix in go 1.2 r.c. 4 for same problem. Go Issue:
- // http://code.google.com/p/go/issues/detail?id=5252
- url := *req.URL
- url.Path = p
- p = url.String()
-
- w.Header().Set("Location", p)
- w.WriteHeader(http.StatusMovedPermanently)
- return
- }
- }
- var match RouteMatch
- var handler http.Handler
- if r.Match(req, &match) {
- handler = match.Handler
- req = requestWithVars(req, match.Vars)
- req = requestWithRoute(req, match.Route)
- }
-
- if handler == nil && match.MatchErr == ErrMethodMismatch {
- handler = methodNotAllowedHandler()
- }
-
- if handler == nil {
- handler = http.NotFoundHandler()
- }
-
- handler.ServeHTTP(w, req)
-}
-
-// Get returns a route registered with the given name.
-func (r *Router) Get(name string) *Route {
- return r.namedRoutes[name]
-}
-
-// GetRoute returns a route registered with the given name. This method
-// was renamed to Get() and remains here for backwards compatibility.
-func (r *Router) GetRoute(name string) *Route {
- return r.namedRoutes[name]
-}
-
-// StrictSlash defines the trailing slash behavior for new routes. The initial
-// value is false.
-//
-// When true, if the route path is "/path/", accessing "/path" will perform a redirect
-// to the former and vice versa. In other words, your application will always
-// see the path as specified in the route.
-//
-// When false, if the route path is "/path", accessing "/path/" will not match
-// this route and vice versa.
-//
-// The re-direct is a HTTP 301 (Moved Permanently). Note that when this is set for
-// routes with a non-idempotent method (e.g. POST, PUT), the subsequent re-directed
-// request will be made as a GET by most clients. Use middleware or client settings
-// to modify this behaviour as needed.
-//
-// Special case: when a route sets a path prefix using the PathPrefix() method,
-// strict slash is ignored for that route because the redirect behavior can't
-// be determined from a prefix alone. However, any subrouters created from that
-// route inherit the original StrictSlash setting.
-func (r *Router) StrictSlash(value bool) *Router {
- r.strictSlash = value
- return r
-}
-
-// SkipClean defines the path cleaning behaviour for new routes. The initial
-// value is false. Users should be careful about which routes are not cleaned
-//
-// When true, if the route path is "/path//to", it will remain with the double
-// slash. This is helpful if you have a route like: /fetch/http://xkcd.com/534/
-//
-// When false, the path will be cleaned, so /fetch/http://xkcd.com/534/ will
-// become /fetch/http/xkcd.com/534
-func (r *Router) SkipClean(value bool) *Router {
- r.skipClean = value
- return r
-}
-
-// UseEncodedPath tells the router to match the encoded original path
-// to the routes.
-// For eg. "/path/foo%2Fbar/to" will match the path "/path/{var}/to".
-//
-// If not called, the router will match the unencoded path to the routes.
-// For eg. "/path/foo%2Fbar/to" will match the path "/path/foo/bar/to"
-func (r *Router) UseEncodedPath() *Router {
- r.useEncodedPath = true
- return r
-}
-
-// ----------------------------------------------------------------------------
-// Route factories
-// ----------------------------------------------------------------------------
-
-// NewRoute registers an empty route.
-func (r *Router) NewRoute() *Route {
- // initialize a route with a copy of the parent router's configuration
- route := &Route{routeConf: copyRouteConf(r.routeConf), namedRoutes: r.namedRoutes}
- r.routes = append(r.routes, route)
- return route
-}
-
-// Name registers a new route with a name.
-// See Route.Name().
-func (r *Router) Name(name string) *Route {
- return r.NewRoute().Name(name)
-}
-
-// Handle registers a new route with a matcher for the URL path.
-// See Route.Path() and Route.Handler().
-func (r *Router) Handle(path string, handler http.Handler) *Route {
- return r.NewRoute().Path(path).Handler(handler)
-}
-
-// HandleFunc registers a new route with a matcher for the URL path.
-// See Route.Path() and Route.HandlerFunc().
-func (r *Router) HandleFunc(path string, f func(http.ResponseWriter,
- *http.Request)) *Route {
- return r.NewRoute().Path(path).HandlerFunc(f)
-}
-
-// Headers registers a new route with a matcher for request header values.
-// See Route.Headers().
-func (r *Router) Headers(pairs ...string) *Route {
- return r.NewRoute().Headers(pairs...)
-}
-
-// Host registers a new route with a matcher for the URL host.
-// See Route.Host().
-func (r *Router) Host(tpl string) *Route {
- return r.NewRoute().Host(tpl)
-}
-
-// MatcherFunc registers a new route with a custom matcher function.
-// See Route.MatcherFunc().
-func (r *Router) MatcherFunc(f MatcherFunc) *Route {
- return r.NewRoute().MatcherFunc(f)
-}
-
-// Methods registers a new route with a matcher for HTTP methods.
-// See Route.Methods().
-func (r *Router) Methods(methods ...string) *Route {
- return r.NewRoute().Methods(methods...)
-}
-
-// Path registers a new route with a matcher for the URL path.
-// See Route.Path().
-func (r *Router) Path(tpl string) *Route {
- return r.NewRoute().Path(tpl)
-}
-
-// PathPrefix registers a new route with a matcher for the URL path prefix.
-// See Route.PathPrefix().
-func (r *Router) PathPrefix(tpl string) *Route {
- return r.NewRoute().PathPrefix(tpl)
-}
-
-// Queries registers a new route with a matcher for URL query values.
-// See Route.Queries().
-func (r *Router) Queries(pairs ...string) *Route {
- return r.NewRoute().Queries(pairs...)
-}
-
-// Schemes registers a new route with a matcher for URL schemes.
-// See Route.Schemes().
-func (r *Router) Schemes(schemes ...string) *Route {
- return r.NewRoute().Schemes(schemes...)
-}
-
-// BuildVarsFunc registers a new route with a custom function for modifying
-// route variables before building a URL.
-func (r *Router) BuildVarsFunc(f BuildVarsFunc) *Route {
- return r.NewRoute().BuildVarsFunc(f)
-}
-
-// Walk walks the router and all its sub-routers, calling walkFn for each route
-// in the tree. The routes are walked in the order they were added. Sub-routers
-// are explored depth-first.
-func (r *Router) Walk(walkFn WalkFunc) error {
- return r.walk(walkFn, []*Route{})
-}
-
-// SkipRouter is used as a return value from WalkFuncs to indicate that the
-// router that walk is about to descend down to should be skipped.
-var SkipRouter = errors.New("skip this router")
-
-// WalkFunc is the type of the function called for each route visited by Walk.
-// At every invocation, it is given the current route, and the current router,
-// and a list of ancestor routes that lead to the current route.
-type WalkFunc func(route *Route, router *Router, ancestors []*Route) error
-
-func (r *Router) walk(walkFn WalkFunc, ancestors []*Route) error {
- for _, t := range r.routes {
- err := walkFn(t, r, ancestors)
- if err == SkipRouter {
- continue
- }
- if err != nil {
- return err
- }
- for _, sr := range t.matchers {
- if h, ok := sr.(*Router); ok {
- ancestors = append(ancestors, t)
- err := h.walk(walkFn, ancestors)
- if err != nil {
- return err
- }
- ancestors = ancestors[:len(ancestors)-1]
- }
- }
- if h, ok := t.handler.(*Router); ok {
- ancestors = append(ancestors, t)
- err := h.walk(walkFn, ancestors)
- if err != nil {
- return err
- }
- ancestors = ancestors[:len(ancestors)-1]
- }
- }
- return nil
-}
-
-// ----------------------------------------------------------------------------
-// Context
-// ----------------------------------------------------------------------------
-
-// RouteMatch stores information about a matched route.
-type RouteMatch struct {
- Route *Route
- Handler http.Handler
- Vars map[string]string
-
- // MatchErr is set to appropriate matching error
- // It is set to ErrMethodMismatch if there is a mismatch in
- // the request method and route method
- MatchErr error
-}
-
-type contextKey int
-
-const (
- varsKey contextKey = iota
- routeKey
-)
-
-// Vars returns the route variables for the current request, if any.
-func Vars(r *http.Request) map[string]string {
- if rv := r.Context().Value(varsKey); rv != nil {
- return rv.(map[string]string)
- }
- return nil
-}
-
-// CurrentRoute returns the matched route for the current request, if any.
-// This only works when called inside the handler of the matched route
-// because the matched route is stored in the request context which is cleared
-// after the handler returns.
-func CurrentRoute(r *http.Request) *Route {
- if rv := r.Context().Value(routeKey); rv != nil {
- return rv.(*Route)
- }
- return nil
-}
-
-func requestWithVars(r *http.Request, vars map[string]string) *http.Request {
- ctx := context.WithValue(r.Context(), varsKey, vars)
- return r.WithContext(ctx)
-}
-
-func requestWithRoute(r *http.Request, route *Route) *http.Request {
- ctx := context.WithValue(r.Context(), routeKey, route)
- return r.WithContext(ctx)
-}
-
-// ----------------------------------------------------------------------------
-// Helpers
-// ----------------------------------------------------------------------------
-
-// cleanPath returns the canonical path for p, eliminating . and .. elements.
-// Borrowed from the net/http package.
-func cleanPath(p string) string {
- if p == "" {
- return "/"
- }
- if p[0] != '/' {
- p = "/" + p
- }
- np := path.Clean(p)
- // path.Clean removes trailing slash except for root;
- // put the trailing slash back if necessary.
- if p[len(p)-1] == '/' && np != "/" {
- np += "/"
- }
-
- return np
-}
-
-// uniqueVars returns an error if two slices contain duplicated strings.
-func uniqueVars(s1, s2 []string) error {
- for _, v1 := range s1 {
- for _, v2 := range s2 {
- if v1 == v2 {
- return fmt.Errorf("mux: duplicated route variable %q", v2)
- }
- }
- }
- return nil
-}
-
-// checkPairs returns the count of strings passed in, and an error if
-// the count is not an even number.
-func checkPairs(pairs ...string) (int, error) {
- length := len(pairs)
- if length%2 != 0 {
- return length, fmt.Errorf(
- "mux: number of parameters must be multiple of 2, got %v", pairs)
- }
- return length, nil
-}
-
-// mapFromPairsToString converts variadic string parameters to a
-// string to string map.
-func mapFromPairsToString(pairs ...string) (map[string]string, error) {
- length, err := checkPairs(pairs...)
- if err != nil {
- return nil, err
- }
- m := make(map[string]string, length/2)
- for i := 0; i < length; i += 2 {
- m[pairs[i]] = pairs[i+1]
- }
- return m, nil
-}
-
-// mapFromPairsToRegex converts variadic string parameters to a
-// string to regex map.
-func mapFromPairsToRegex(pairs ...string) (map[string]*regexp.Regexp, error) {
- length, err := checkPairs(pairs...)
- if err != nil {
- return nil, err
- }
- m := make(map[string]*regexp.Regexp, length/2)
- for i := 0; i < length; i += 2 {
- regex, err := regexp.Compile(pairs[i+1])
- if err != nil {
- return nil, err
- }
- m[pairs[i]] = regex
- }
- return m, nil
-}
-
-// matchInArray returns true if the given string value is in the array.
-func matchInArray(arr []string, value string) bool {
- for _, v := range arr {
- if v == value {
- return true
- }
- }
- return false
-}
-
-// matchMapWithString returns true if the given key/value pairs exist in a given map.
-func matchMapWithString(toCheck map[string]string, toMatch map[string][]string, canonicalKey bool) bool {
- for k, v := range toCheck {
- // Check if key exists.
- if canonicalKey {
- k = http.CanonicalHeaderKey(k)
- }
- if values := toMatch[k]; values == nil {
- return false
- } else if v != "" {
- // If value was defined as an empty string we only check that the
- // key exists. Otherwise we also check for equality.
- valueExists := false
- for _, value := range values {
- if v == value {
- valueExists = true
- break
- }
- }
- if !valueExists {
- return false
- }
- }
- }
- return true
-}
-
-// matchMapWithRegex returns true if the given key/value pairs exist in a given map compiled against
-// the given regex
-func matchMapWithRegex(toCheck map[string]*regexp.Regexp, toMatch map[string][]string, canonicalKey bool) bool {
- for k, v := range toCheck {
- // Check if key exists.
- if canonicalKey {
- k = http.CanonicalHeaderKey(k)
- }
- if values := toMatch[k]; values == nil {
- return false
- } else if v != nil {
- // If value was defined as an empty string we only check that the
- // key exists. Otherwise we also check for equality.
- valueExists := false
- for _, value := range values {
- if v.MatchString(value) {
- valueExists = true
- break
- }
- }
- if !valueExists {
- return false
- }
- }
- }
- return true
-}
-
-// methodNotAllowed replies to the request with an HTTP status code 405.
-func methodNotAllowed(w http.ResponseWriter, r *http.Request) {
- w.WriteHeader(http.StatusMethodNotAllowed)
-}
-
-// methodNotAllowedHandler returns a simple request handler
-// that replies to each request with a status code 405.
-func methodNotAllowedHandler() http.Handler { return http.HandlerFunc(methodNotAllowed) }
diff --git a/vendor/github.com/gorilla/mux/regexp.go b/vendor/github.com/gorilla/mux/regexp.go
deleted file mode 100644
index 5d05cfa..0000000
--- a/vendor/github.com/gorilla/mux/regexp.go
+++ /dev/null
@@ -1,388 +0,0 @@
-// Copyright 2012 The Gorilla Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package mux
-
-import (
- "bytes"
- "fmt"
- "net/http"
- "net/url"
- "regexp"
- "strconv"
- "strings"
-)
-
-type routeRegexpOptions struct {
- strictSlash bool
- useEncodedPath bool
-}
-
-type regexpType int
-
-const (
- regexpTypePath regexpType = iota
- regexpTypeHost
- regexpTypePrefix
- regexpTypeQuery
-)
-
-// newRouteRegexp parses a route template and returns a routeRegexp,
-// used to match a host, a path or a query string.
-//
-// It will extract named variables, assemble a regexp to be matched, create
-// a "reverse" template to build URLs and compile regexps to validate variable
-// values used in URL building.
-//
-// Previously we accepted only Python-like identifiers for variable
-// names ([a-zA-Z_][a-zA-Z0-9_]*), but currently the only restriction is that
-// name and pattern can't be empty, and names can't contain a colon.
-func newRouteRegexp(tpl string, typ regexpType, options routeRegexpOptions) (*routeRegexp, error) {
- // Check if it is well-formed.
- idxs, errBraces := braceIndices(tpl)
- if errBraces != nil {
- return nil, errBraces
- }
- // Backup the original.
- template := tpl
- // Now let's parse it.
- defaultPattern := "[^/]+"
- if typ == regexpTypeQuery {
- defaultPattern = ".*"
- } else if typ == regexpTypeHost {
- defaultPattern = "[^.]+"
- }
- // Only match strict slash if not matching
- if typ != regexpTypePath {
- options.strictSlash = false
- }
- // Set a flag for strictSlash.
- endSlash := false
- if options.strictSlash && strings.HasSuffix(tpl, "/") {
- tpl = tpl[:len(tpl)-1]
- endSlash = true
- }
- varsN := make([]string, len(idxs)/2)
- varsR := make([]*regexp.Regexp, len(idxs)/2)
- pattern := bytes.NewBufferString("")
- pattern.WriteByte('^')
- reverse := bytes.NewBufferString("")
- var end int
- var err error
- for i := 0; i < len(idxs); i += 2 {
- // Set all values we are interested in.
- raw := tpl[end:idxs[i]]
- end = idxs[i+1]
- parts := strings.SplitN(tpl[idxs[i]+1:end-1], ":", 2)
- name := parts[0]
- patt := defaultPattern
- if len(parts) == 2 {
- patt = parts[1]
- }
- // Name or pattern can't be empty.
- if name == "" || patt == "" {
- return nil, fmt.Errorf("mux: missing name or pattern in %q",
- tpl[idxs[i]:end])
- }
- // Build the regexp pattern.
- fmt.Fprintf(pattern, "%s(?P<%s>%s)", regexp.QuoteMeta(raw), varGroupName(i/2), patt)
-
- // Build the reverse template.
- fmt.Fprintf(reverse, "%s%%s", raw)
-
- // Append variable name and compiled pattern.
- varsN[i/2] = name
- varsR[i/2], err = regexp.Compile(fmt.Sprintf("^%s$", patt))
- if err != nil {
- return nil, err
- }
- }
- // Add the remaining.
- raw := tpl[end:]
- pattern.WriteString(regexp.QuoteMeta(raw))
- if options.strictSlash {
- pattern.WriteString("[/]?")
- }
- if typ == regexpTypeQuery {
- // Add the default pattern if the query value is empty
- if queryVal := strings.SplitN(template, "=", 2)[1]; queryVal == "" {
- pattern.WriteString(defaultPattern)
- }
- }
- if typ != regexpTypePrefix {
- pattern.WriteByte('$')
- }
-
- var wildcardHostPort bool
- if typ == regexpTypeHost {
- if !strings.Contains(pattern.String(), ":") {
- wildcardHostPort = true
- }
- }
- reverse.WriteString(raw)
- if endSlash {
- reverse.WriteByte('/')
- }
- // Compile full regexp.
- reg, errCompile := regexp.Compile(pattern.String())
- if errCompile != nil {
- return nil, errCompile
- }
-
- // Check for capturing groups which used to work in older versions
- if reg.NumSubexp() != len(idxs)/2 {
- panic(fmt.Sprintf("route %s contains capture groups in its regexp. ", template) +
- "Only non-capturing groups are accepted: e.g. (?:pattern) instead of (pattern)")
- }
-
- // Done!
- return &routeRegexp{
- template: template,
- regexpType: typ,
- options: options,
- regexp: reg,
- reverse: reverse.String(),
- varsN: varsN,
- varsR: varsR,
- wildcardHostPort: wildcardHostPort,
- }, nil
-}
-
-// routeRegexp stores a regexp to match a host or path and information to
-// collect and validate route variables.
-type routeRegexp struct {
- // The unmodified template.
- template string
- // The type of match
- regexpType regexpType
- // Options for matching
- options routeRegexpOptions
- // Expanded regexp.
- regexp *regexp.Regexp
- // Reverse template.
- reverse string
- // Variable names.
- varsN []string
- // Variable regexps (validators).
- varsR []*regexp.Regexp
- // Wildcard host-port (no strict port match in hostname)
- wildcardHostPort bool
-}
-
-// Match matches the regexp against the URL host or path.
-func (r *routeRegexp) Match(req *http.Request, match *RouteMatch) bool {
- if r.regexpType == regexpTypeHost {
- host := getHost(req)
- if r.wildcardHostPort {
- // Don't be strict on the port match
- if i := strings.Index(host, ":"); i != -1 {
- host = host[:i]
- }
- }
- return r.regexp.MatchString(host)
- }
-
- if r.regexpType == regexpTypeQuery {
- return r.matchQueryString(req)
- }
- path := req.URL.Path
- if r.options.useEncodedPath {
- path = req.URL.EscapedPath()
- }
- return r.regexp.MatchString(path)
-}
-
-// url builds a URL part using the given values.
-func (r *routeRegexp) url(values map[string]string) (string, error) {
- urlValues := make([]interface{}, len(r.varsN))
- for k, v := range r.varsN {
- value, ok := values[v]
- if !ok {
- return "", fmt.Errorf("mux: missing route variable %q", v)
- }
- if r.regexpType == regexpTypeQuery {
- value = url.QueryEscape(value)
- }
- urlValues[k] = value
- }
- rv := fmt.Sprintf(r.reverse, urlValues...)
- if !r.regexp.MatchString(rv) {
- // The URL is checked against the full regexp, instead of checking
- // individual variables. This is faster but to provide a good error
- // message, we check individual regexps if the URL doesn't match.
- for k, v := range r.varsN {
- if !r.varsR[k].MatchString(values[v]) {
- return "", fmt.Errorf(
- "mux: variable %q doesn't match, expected %q", values[v],
- r.varsR[k].String())
- }
- }
- }
- return rv, nil
-}
-
-// getURLQuery returns a single query parameter from a request URL.
-// For a URL with foo=bar&baz=ding, we return only the relevant key
-// value pair for the routeRegexp.
-func (r *routeRegexp) getURLQuery(req *http.Request) string {
- if r.regexpType != regexpTypeQuery {
- return ""
- }
- templateKey := strings.SplitN(r.template, "=", 2)[0]
- val, ok := findFirstQueryKey(req.URL.RawQuery, templateKey)
- if ok {
- return templateKey + "=" + val
- }
- return ""
-}
-
-// findFirstQueryKey returns the same result as (*url.URL).Query()[key][0].
-// If key was not found, empty string and false is returned.
-func findFirstQueryKey(rawQuery, key string) (value string, ok bool) {
- query := []byte(rawQuery)
- for len(query) > 0 {
- foundKey := query
- if i := bytes.IndexAny(foundKey, "&;"); i >= 0 {
- foundKey, query = foundKey[:i], foundKey[i+1:]
- } else {
- query = query[:0]
- }
- if len(foundKey) == 0 {
- continue
- }
- var value []byte
- if i := bytes.IndexByte(foundKey, '='); i >= 0 {
- foundKey, value = foundKey[:i], foundKey[i+1:]
- }
- if len(foundKey) < len(key) {
- // Cannot possibly be key.
- continue
- }
- keyString, err := url.QueryUnescape(string(foundKey))
- if err != nil {
- continue
- }
- if keyString != key {
- continue
- }
- valueString, err := url.QueryUnescape(string(value))
- if err != nil {
- continue
- }
- return valueString, true
- }
- return "", false
-}
-
-func (r *routeRegexp) matchQueryString(req *http.Request) bool {
- return r.regexp.MatchString(r.getURLQuery(req))
-}
-
-// braceIndices returns the first level curly brace indices from a string.
-// It returns an error in case of unbalanced braces.
-func braceIndices(s string) ([]int, error) {
- var level, idx int
- var idxs []int
- for i := 0; i < len(s); i++ {
- switch s[i] {
- case '{':
- if level++; level == 1 {
- idx = i
- }
- case '}':
- if level--; level == 0 {
- idxs = append(idxs, idx, i+1)
- } else if level < 0 {
- return nil, fmt.Errorf("mux: unbalanced braces in %q", s)
- }
- }
- }
- if level != 0 {
- return nil, fmt.Errorf("mux: unbalanced braces in %q", s)
- }
- return idxs, nil
-}
-
-// varGroupName builds a capturing group name for the indexed variable.
-func varGroupName(idx int) string {
- return "v" + strconv.Itoa(idx)
-}
-
-// ----------------------------------------------------------------------------
-// routeRegexpGroup
-// ----------------------------------------------------------------------------
-
-// routeRegexpGroup groups the route matchers that carry variables.
-type routeRegexpGroup struct {
- host *routeRegexp
- path *routeRegexp
- queries []*routeRegexp
-}
-
-// setMatch extracts the variables from the URL once a route matches.
-func (v routeRegexpGroup) setMatch(req *http.Request, m *RouteMatch, r *Route) {
- // Store host variables.
- if v.host != nil {
- host := getHost(req)
- if v.host.wildcardHostPort {
- // Don't be strict on the port match
- if i := strings.Index(host, ":"); i != -1 {
- host = host[:i]
- }
- }
- matches := v.host.regexp.FindStringSubmatchIndex(host)
- if len(matches) > 0 {
- extractVars(host, matches, v.host.varsN, m.Vars)
- }
- }
- path := req.URL.Path
- if r.useEncodedPath {
- path = req.URL.EscapedPath()
- }
- // Store path variables.
- if v.path != nil {
- matches := v.path.regexp.FindStringSubmatchIndex(path)
- if len(matches) > 0 {
- extractVars(path, matches, v.path.varsN, m.Vars)
- // Check if we should redirect.
- if v.path.options.strictSlash {
- p1 := strings.HasSuffix(path, "/")
- p2 := strings.HasSuffix(v.path.template, "/")
- if p1 != p2 {
- u, _ := url.Parse(req.URL.String())
- if p1 {
- u.Path = u.Path[:len(u.Path)-1]
- } else {
- u.Path += "/"
- }
- m.Handler = http.RedirectHandler(u.String(), http.StatusMovedPermanently)
- }
- }
- }
- }
- // Store query string variables.
- for _, q := range v.queries {
- queryURL := q.getURLQuery(req)
- matches := q.regexp.FindStringSubmatchIndex(queryURL)
- if len(matches) > 0 {
- extractVars(queryURL, matches, q.varsN, m.Vars)
- }
- }
-}
-
-// getHost tries its best to return the request host.
-// According to section 14.23 of RFC 2616 the Host header
-// can include the port number if the default value of 80 is not used.
-func getHost(r *http.Request) string {
- if r.URL.IsAbs() {
- return r.URL.Host
- }
- return r.Host
-}
-
-func extractVars(input string, matches []int, names []string, output map[string]string) {
- for i, name := range names {
- output[name] = input[matches[2*i+2]:matches[2*i+3]]
- }
-}
diff --git a/vendor/github.com/gorilla/mux/route.go b/vendor/github.com/gorilla/mux/route.go
deleted file mode 100644
index e8f11df..0000000
--- a/vendor/github.com/gorilla/mux/route.go
+++ /dev/null
@@ -1,765 +0,0 @@
-// Copyright 2012 The Gorilla Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package mux
-
-import (
- "errors"
- "fmt"
- "net/http"
- "net/url"
- "regexp"
- "strings"
-)
-
-// Route stores information to match a request and build URLs.
-type Route struct {
- // Request handler for the route.
- handler http.Handler
- // If true, this route never matches: it is only used to build URLs.
- buildOnly bool
- // The name used to build URLs.
- name string
- // Error resulted from building a route.
- err error
-
- // "global" reference to all named routes
- namedRoutes map[string]*Route
-
- // config possibly passed in from `Router`
- routeConf
-}
-
-// SkipClean reports whether path cleaning is enabled for this route via
-// Router.SkipClean.
-func (r *Route) SkipClean() bool {
- return r.skipClean
-}
-
-// Match matches the route against the request.
-func (r *Route) Match(req *http.Request, match *RouteMatch) bool {
- if r.buildOnly || r.err != nil {
- return false
- }
-
- var matchErr error
-
- // Match everything.
- for _, m := range r.matchers {
- if matched := m.Match(req, match); !matched {
- if _, ok := m.(methodMatcher); ok {
- matchErr = ErrMethodMismatch
- continue
- }
-
- // Ignore ErrNotFound errors. These errors arise from match call
- // to Subrouters.
- //
- // This prevents subsequent matching subrouters from failing to
- // run middleware. If not ignored, the middleware would see a
- // non-nil MatchErr and be skipped, even when there was a
- // matching route.
- if match.MatchErr == ErrNotFound {
- match.MatchErr = nil
- }
-
- matchErr = nil // nolint:ineffassign
- return false
- } else {
- // Multiple routes may share the same path but use different HTTP methods. For instance:
- // Route 1: POST "/users/{id}".
- // Route 2: GET "/users/{id}", parameters: "id": "[0-9]+".
- //
- // The router must handle these cases correctly. For a GET request to "/users/abc" with "id" as "-2",
- // The router should return a "Not Found" error as no route fully matches this request.
- if match.MatchErr == ErrMethodMismatch {
- match.MatchErr = nil
- }
- }
- }
-
- if matchErr != nil {
- match.MatchErr = matchErr
- return false
- }
-
- if match.MatchErr == ErrMethodMismatch && r.handler != nil {
- // We found a route which matches request method, clear MatchErr
- match.MatchErr = nil
- // Then override the mis-matched handler
- match.Handler = r.handler
- }
-
- // Yay, we have a match. Let's collect some info about it.
- if match.Route == nil {
- match.Route = r
- }
- if match.Handler == nil {
- match.Handler = r.handler
- }
- if match.Vars == nil {
- match.Vars = make(map[string]string)
- }
-
- // Set variables.
- r.regexp.setMatch(req, match, r)
- return true
-}
-
-// ----------------------------------------------------------------------------
-// Route attributes
-// ----------------------------------------------------------------------------
-
-// GetError returns an error resulted from building the route, if any.
-func (r *Route) GetError() error {
- return r.err
-}
-
-// BuildOnly sets the route to never match: it is only used to build URLs.
-func (r *Route) BuildOnly() *Route {
- r.buildOnly = true
- return r
-}
-
-// Handler --------------------------------------------------------------------
-
-// Handler sets a handler for the route.
-func (r *Route) Handler(handler http.Handler) *Route {
- if r.err == nil {
- r.handler = handler
- }
- return r
-}
-
-// HandlerFunc sets a handler function for the route.
-func (r *Route) HandlerFunc(f func(http.ResponseWriter, *http.Request)) *Route {
- return r.Handler(http.HandlerFunc(f))
-}
-
-// GetHandler returns the handler for the route, if any.
-func (r *Route) GetHandler() http.Handler {
- return r.handler
-}
-
-// Name -----------------------------------------------------------------------
-
-// Name sets the name for the route, used to build URLs.
-// It is an error to call Name more than once on a route.
-func (r *Route) Name(name string) *Route {
- if r.name != "" {
- r.err = fmt.Errorf("mux: route already has name %q, can't set %q",
- r.name, name)
- }
- if r.err == nil {
- r.name = name
- r.namedRoutes[name] = r
- }
- return r
-}
-
-// GetName returns the name for the route, if any.
-func (r *Route) GetName() string {
- return r.name
-}
-
-// ----------------------------------------------------------------------------
-// Matchers
-// ----------------------------------------------------------------------------
-
-// matcher types try to match a request.
-type matcher interface {
- Match(*http.Request, *RouteMatch) bool
-}
-
-// addMatcher adds a matcher to the route.
-func (r *Route) addMatcher(m matcher) *Route {
- if r.err == nil {
- r.matchers = append(r.matchers, m)
- }
- return r
-}
-
-// addRegexpMatcher adds a host or path matcher and builder to a route.
-func (r *Route) addRegexpMatcher(tpl string, typ regexpType) error {
- if r.err != nil {
- return r.err
- }
- if typ == regexpTypePath || typ == regexpTypePrefix {
- if len(tpl) > 0 && tpl[0] != '/' {
- return fmt.Errorf("mux: path must start with a slash, got %q", tpl)
- }
- if r.regexp.path != nil {
- tpl = strings.TrimRight(r.regexp.path.template, "/") + tpl
- }
- }
- rr, err := newRouteRegexp(tpl, typ, routeRegexpOptions{
- strictSlash: r.strictSlash,
- useEncodedPath: r.useEncodedPath,
- })
- if err != nil {
- return err
- }
- for _, q := range r.regexp.queries {
- if err = uniqueVars(rr.varsN, q.varsN); err != nil {
- return err
- }
- }
- if typ == regexpTypeHost {
- if r.regexp.path != nil {
- if err = uniqueVars(rr.varsN, r.regexp.path.varsN); err != nil {
- return err
- }
- }
- r.regexp.host = rr
- } else {
- if r.regexp.host != nil {
- if err = uniqueVars(rr.varsN, r.regexp.host.varsN); err != nil {
- return err
- }
- }
- if typ == regexpTypeQuery {
- r.regexp.queries = append(r.regexp.queries, rr)
- } else {
- r.regexp.path = rr
- }
- }
- r.addMatcher(rr)
- return nil
-}
-
-// Headers --------------------------------------------------------------------
-
-// headerMatcher matches the request against header values.
-type headerMatcher map[string]string
-
-func (m headerMatcher) Match(r *http.Request, match *RouteMatch) bool {
- return matchMapWithString(m, r.Header, true)
-}
-
-// Headers adds a matcher for request header values.
-// It accepts a sequence of key/value pairs to be matched. For example:
-//
-// r := mux.NewRouter().NewRoute()
-// r.Headers("Content-Type", "application/json",
-// "X-Requested-With", "XMLHttpRequest")
-//
-// The above route will only match if both request header values match.
-// If the value is an empty string, it will match any value if the key is set.
-func (r *Route) Headers(pairs ...string) *Route {
- if r.err == nil {
- var headers map[string]string
- headers, r.err = mapFromPairsToString(pairs...)
- return r.addMatcher(headerMatcher(headers))
- }
- return r
-}
-
-// headerRegexMatcher matches the request against the route given a regex for the header
-type headerRegexMatcher map[string]*regexp.Regexp
-
-func (m headerRegexMatcher) Match(r *http.Request, match *RouteMatch) bool {
- return matchMapWithRegex(m, r.Header, true)
-}
-
-// HeadersRegexp accepts a sequence of key/value pairs, where the value has regex
-// support. For example:
-//
-// r := mux.NewRouter().NewRoute()
-// r.HeadersRegexp("Content-Type", "application/(text|json)",
-// "X-Requested-With", "XMLHttpRequest")
-//
-// The above route will only match if both the request header matches both regular expressions.
-// If the value is an empty string, it will match any value if the key is set.
-// Use the start and end of string anchors (^ and $) to match an exact value.
-func (r *Route) HeadersRegexp(pairs ...string) *Route {
- if r.err == nil {
- var headers map[string]*regexp.Regexp
- headers, r.err = mapFromPairsToRegex(pairs...)
- return r.addMatcher(headerRegexMatcher(headers))
- }
- return r
-}
-
-// Host -----------------------------------------------------------------------
-
-// Host adds a matcher for the URL host.
-// It accepts a template with zero or more URL variables enclosed by {}.
-// Variables can define an optional regexp pattern to be matched:
-//
-// - {name} matches anything until the next dot.
-//
-// - {name:pattern} matches the given regexp pattern.
-//
-// For example:
-//
-// r := mux.NewRouter().NewRoute()
-// r.Host("www.example.com")
-// r.Host("{subdomain}.domain.com")
-// r.Host("{subdomain:[a-z]+}.domain.com")
-//
-// Variable names must be unique in a given route. They can be retrieved
-// calling mux.Vars(request).
-func (r *Route) Host(tpl string) *Route {
- r.err = r.addRegexpMatcher(tpl, regexpTypeHost)
- return r
-}
-
-// MatcherFunc ----------------------------------------------------------------
-
-// MatcherFunc is the function signature used by custom matchers.
-type MatcherFunc func(*http.Request, *RouteMatch) bool
-
-// Match returns the match for a given request.
-func (m MatcherFunc) Match(r *http.Request, match *RouteMatch) bool {
- return m(r, match)
-}
-
-// MatcherFunc adds a custom function to be used as request matcher.
-func (r *Route) MatcherFunc(f MatcherFunc) *Route {
- return r.addMatcher(f)
-}
-
-// Methods --------------------------------------------------------------------
-
-// methodMatcher matches the request against HTTP methods.
-type methodMatcher []string
-
-func (m methodMatcher) Match(r *http.Request, match *RouteMatch) bool {
- return matchInArray(m, r.Method)
-}
-
-// Methods adds a matcher for HTTP methods.
-// It accepts a sequence of one or more methods to be matched, e.g.:
-// "GET", "POST", "PUT".
-func (r *Route) Methods(methods ...string) *Route {
- for k, v := range methods {
- methods[k] = strings.ToUpper(v)
- }
- return r.addMatcher(methodMatcher(methods))
-}
-
-// Path -----------------------------------------------------------------------
-
-// Path adds a matcher for the URL path.
-// It accepts a template with zero or more URL variables enclosed by {}. The
-// template must start with a "/".
-// Variables can define an optional regexp pattern to be matched:
-//
-// - {name} matches anything until the next slash.
-//
-// - {name:pattern} matches the given regexp pattern.
-//
-// For example:
-//
-// r := mux.NewRouter().NewRoute()
-// r.Path("/products/").Handler(ProductsHandler)
-// r.Path("/products/{key}").Handler(ProductsHandler)
-// r.Path("/articles/{category}/{id:[0-9]+}").
-// Handler(ArticleHandler)
-//
-// Variable names must be unique in a given route. They can be retrieved
-// calling mux.Vars(request).
-func (r *Route) Path(tpl string) *Route {
- r.err = r.addRegexpMatcher(tpl, regexpTypePath)
- return r
-}
-
-// PathPrefix -----------------------------------------------------------------
-
-// PathPrefix adds a matcher for the URL path prefix. This matches if the given
-// template is a prefix of the full URL path. See Route.Path() for details on
-// the tpl argument.
-//
-// Note that it does not treat slashes specially ("/foobar/" will be matched by
-// the prefix "/foo") so you may want to use a trailing slash here.
-//
-// Also note that the setting of Router.StrictSlash() has no effect on routes
-// with a PathPrefix matcher.
-func (r *Route) PathPrefix(tpl string) *Route {
- r.err = r.addRegexpMatcher(tpl, regexpTypePrefix)
- return r
-}
-
-// Query ----------------------------------------------------------------------
-
-// Queries adds a matcher for URL query values.
-// It accepts a sequence of key/value pairs. Values may define variables.
-// For example:
-//
-// r := mux.NewRouter().NewRoute()
-// r.Queries("foo", "bar", "id", "{id:[0-9]+}")
-//
-// The above route will only match if the URL contains the defined queries
-// values, e.g.: ?foo=bar&id=42.
-//
-// If the value is an empty string, it will match any value if the key is set.
-//
-// Variables can define an optional regexp pattern to be matched:
-//
-// - {name} matches anything until the next slash.
-//
-// - {name:pattern} matches the given regexp pattern.
-func (r *Route) Queries(pairs ...string) *Route {
- length := len(pairs)
- if length%2 != 0 {
- r.err = fmt.Errorf(
- "mux: number of parameters must be multiple of 2, got %v", pairs)
- return nil
- }
- for i := 0; i < length; i += 2 {
- if r.err = r.addRegexpMatcher(pairs[i]+"="+pairs[i+1], regexpTypeQuery); r.err != nil {
- return r
- }
- }
-
- return r
-}
-
-// Schemes --------------------------------------------------------------------
-
-// schemeMatcher matches the request against URL schemes.
-type schemeMatcher []string
-
-func (m schemeMatcher) Match(r *http.Request, match *RouteMatch) bool {
- scheme := r.URL.Scheme
- // https://golang.org/pkg/net/http/#Request
- // "For [most] server requests, fields other than Path and RawQuery will be
- // empty."
- // Since we're an http muxer, the scheme is either going to be http or https
- // though, so we can just set it based on the tls termination state.
- if scheme == "" {
- if r.TLS == nil {
- scheme = "http"
- } else {
- scheme = "https"
- }
- }
- return matchInArray(m, scheme)
-}
-
-// Schemes adds a matcher for URL schemes.
-// It accepts a sequence of schemes to be matched, e.g.: "http", "https".
-// If the request's URL has a scheme set, it will be matched against.
-// Generally, the URL scheme will only be set if a previous handler set it,
-// such as the ProxyHeaders handler from gorilla/handlers.
-// If unset, the scheme will be determined based on the request's TLS
-// termination state.
-// The first argument to Schemes will be used when constructing a route URL.
-func (r *Route) Schemes(schemes ...string) *Route {
- for k, v := range schemes {
- schemes[k] = strings.ToLower(v)
- }
- if len(schemes) > 0 {
- r.buildScheme = schemes[0]
- }
- return r.addMatcher(schemeMatcher(schemes))
-}
-
-// BuildVarsFunc --------------------------------------------------------------
-
-// BuildVarsFunc is the function signature used by custom build variable
-// functions (which can modify route variables before a route's URL is built).
-type BuildVarsFunc func(map[string]string) map[string]string
-
-// BuildVarsFunc adds a custom function to be used to modify build variables
-// before a route's URL is built.
-func (r *Route) BuildVarsFunc(f BuildVarsFunc) *Route {
- if r.buildVarsFunc != nil {
- // compose the old and new functions
- old := r.buildVarsFunc
- r.buildVarsFunc = func(m map[string]string) map[string]string {
- return f(old(m))
- }
- } else {
- r.buildVarsFunc = f
- }
- return r
-}
-
-// Subrouter ------------------------------------------------------------------
-
-// Subrouter creates a subrouter for the route.
-//
-// It will test the inner routes only if the parent route matched. For example:
-//
-// r := mux.NewRouter().NewRoute()
-// s := r.Host("www.example.com").Subrouter()
-// s.HandleFunc("/products/", ProductsHandler)
-// s.HandleFunc("/products/{key}", ProductHandler)
-// s.HandleFunc("/articles/{category}/{id:[0-9]+}"), ArticleHandler)
-//
-// Here, the routes registered in the subrouter won't be tested if the host
-// doesn't match.
-func (r *Route) Subrouter() *Router {
- // initialize a subrouter with a copy of the parent route's configuration
- router := &Router{routeConf: copyRouteConf(r.routeConf), namedRoutes: r.namedRoutes}
- r.addMatcher(router)
- return router
-}
-
-// ----------------------------------------------------------------------------
-// URL building
-// ----------------------------------------------------------------------------
-
-// URL builds a URL for the route.
-//
-// It accepts a sequence of key/value pairs for the route variables. For
-// example, given this route:
-//
-// r := mux.NewRouter()
-// r.HandleFunc("/articles/{category}/{id:[0-9]+}", ArticleHandler).
-// Name("article")
-//
-// ...a URL for it can be built using:
-//
-// url, err := r.Get("article").URL("category", "technology", "id", "42")
-//
-// ...which will return an url.URL with the following path:
-//
-// "/articles/technology/42"
-//
-// This also works for host variables:
-//
-// r := mux.NewRouter()
-// r.HandleFunc("/articles/{category}/{id:[0-9]+}", ArticleHandler).
-// Host("{subdomain}.domain.com").
-// Name("article")
-//
-// // url.String() will be "http://news.domain.com/articles/technology/42"
-// url, err := r.Get("article").URL("subdomain", "news",
-// "category", "technology",
-// "id", "42")
-//
-// The scheme of the resulting url will be the first argument that was passed to Schemes:
-//
-// // url.String() will be "https://example.com"
-// r := mux.NewRouter().NewRoute()
-// url, err := r.Host("example.com")
-// .Schemes("https", "http").URL()
-//
-// All variables defined in the route are required, and their values must
-// conform to the corresponding patterns.
-func (r *Route) URL(pairs ...string) (*url.URL, error) {
- if r.err != nil {
- return nil, r.err
- }
- values, err := r.prepareVars(pairs...)
- if err != nil {
- return nil, err
- }
- var scheme, host, path string
- queries := make([]string, 0, len(r.regexp.queries))
- if r.regexp.host != nil {
- if host, err = r.regexp.host.url(values); err != nil {
- return nil, err
- }
- scheme = "http"
- if r.buildScheme != "" {
- scheme = r.buildScheme
- }
- }
- if r.regexp.path != nil {
- if path, err = r.regexp.path.url(values); err != nil {
- return nil, err
- }
- }
- for _, q := range r.regexp.queries {
- var query string
- if query, err = q.url(values); err != nil {
- return nil, err
- }
- queries = append(queries, query)
- }
- return &url.URL{
- Scheme: scheme,
- Host: host,
- Path: path,
- RawQuery: strings.Join(queries, "&"),
- }, nil
-}
-
-// URLHost builds the host part of the URL for a route. See Route.URL().
-//
-// The route must have a host defined.
-func (r *Route) URLHost(pairs ...string) (*url.URL, error) {
- if r.err != nil {
- return nil, r.err
- }
- if r.regexp.host == nil {
- return nil, errors.New("mux: route doesn't have a host")
- }
- values, err := r.prepareVars(pairs...)
- if err != nil {
- return nil, err
- }
- host, err := r.regexp.host.url(values)
- if err != nil {
- return nil, err
- }
- u := &url.URL{
- Scheme: "http",
- Host: host,
- }
- if r.buildScheme != "" {
- u.Scheme = r.buildScheme
- }
- return u, nil
-}
-
-// URLPath builds the path part of the URL for a route. See Route.URL().
-//
-// The route must have a path defined.
-func (r *Route) URLPath(pairs ...string) (*url.URL, error) {
- if r.err != nil {
- return nil, r.err
- }
- if r.regexp.path == nil {
- return nil, errors.New("mux: route doesn't have a path")
- }
- values, err := r.prepareVars(pairs...)
- if err != nil {
- return nil, err
- }
- path, err := r.regexp.path.url(values)
- if err != nil {
- return nil, err
- }
- return &url.URL{
- Path: path,
- }, nil
-}
-
-// GetPathTemplate returns the template used to build the
-// route match.
-// This is useful for building simple REST API documentation and for instrumentation
-// against third-party services.
-// An error will be returned if the route does not define a path.
-func (r *Route) GetPathTemplate() (string, error) {
- if r.err != nil {
- return "", r.err
- }
- if r.regexp.path == nil {
- return "", errors.New("mux: route doesn't have a path")
- }
- return r.regexp.path.template, nil
-}
-
-// GetPathRegexp returns the expanded regular expression used to match route path.
-// This is useful for building simple REST API documentation and for instrumentation
-// against third-party services.
-// An error will be returned if the route does not define a path.
-func (r *Route) GetPathRegexp() (string, error) {
- if r.err != nil {
- return "", r.err
- }
- if r.regexp.path == nil {
- return "", errors.New("mux: route does not have a path")
- }
- return r.regexp.path.regexp.String(), nil
-}
-
-// GetQueriesRegexp returns the expanded regular expressions used to match the
-// route queries.
-// This is useful for building simple REST API documentation and for instrumentation
-// against third-party services.
-// An error will be returned if the route does not have queries.
-func (r *Route) GetQueriesRegexp() ([]string, error) {
- if r.err != nil {
- return nil, r.err
- }
- if r.regexp.queries == nil {
- return nil, errors.New("mux: route doesn't have queries")
- }
- queries := make([]string, 0, len(r.regexp.queries))
- for _, query := range r.regexp.queries {
- queries = append(queries, query.regexp.String())
- }
- return queries, nil
-}
-
-// GetQueriesTemplates returns the templates used to build the
-// query matching.
-// This is useful for building simple REST API documentation and for instrumentation
-// against third-party services.
-// An error will be returned if the route does not define queries.
-func (r *Route) GetQueriesTemplates() ([]string, error) {
- if r.err != nil {
- return nil, r.err
- }
- if r.regexp.queries == nil {
- return nil, errors.New("mux: route doesn't have queries")
- }
- queries := make([]string, 0, len(r.regexp.queries))
- for _, query := range r.regexp.queries {
- queries = append(queries, query.template)
- }
- return queries, nil
-}
-
-// GetMethods returns the methods the route matches against
-// This is useful for building simple REST API documentation and for instrumentation
-// against third-party services.
-// An error will be returned if route does not have methods.
-func (r *Route) GetMethods() ([]string, error) {
- if r.err != nil {
- return nil, r.err
- }
- for _, m := range r.matchers {
- if methods, ok := m.(methodMatcher); ok {
- return []string(methods), nil
- }
- }
- return nil, errors.New("mux: route doesn't have methods")
-}
-
-// GetHostTemplate returns the template used to build the
-// route match.
-// This is useful for building simple REST API documentation and for instrumentation
-// against third-party services.
-// An error will be returned if the route does not define a host.
-func (r *Route) GetHostTemplate() (string, error) {
- if r.err != nil {
- return "", r.err
- }
- if r.regexp.host == nil {
- return "", errors.New("mux: route doesn't have a host")
- }
- return r.regexp.host.template, nil
-}
-
-// GetVarNames returns the names of all variables added by regexp matchers
-// These can be used to know which route variables should be passed into r.URL()
-func (r *Route) GetVarNames() ([]string, error) {
- if r.err != nil {
- return nil, r.err
- }
- var varNames []string
- if r.regexp.host != nil {
- varNames = append(varNames, r.regexp.host.varsN...)
- }
- if r.regexp.path != nil {
- varNames = append(varNames, r.regexp.path.varsN...)
- }
- for _, regx := range r.regexp.queries {
- varNames = append(varNames, regx.varsN...)
- }
- return varNames, nil
-}
-
-// prepareVars converts the route variable pairs into a map. If the route has a
-// BuildVarsFunc, it is invoked.
-func (r *Route) prepareVars(pairs ...string) (map[string]string, error) {
- m, err := mapFromPairsToString(pairs...)
- if err != nil {
- return nil, err
- }
- return r.buildVars(m), nil
-}
-
-func (r *Route) buildVars(m map[string]string) map[string]string {
- if r.buildVarsFunc != nil {
- m = r.buildVarsFunc(m)
- }
- return m
-}
diff --git a/vendor/github.com/gorilla/mux/test_helpers.go b/vendor/github.com/gorilla/mux/test_helpers.go
deleted file mode 100644
index 5f5c496..0000000
--- a/vendor/github.com/gorilla/mux/test_helpers.go
+++ /dev/null
@@ -1,19 +0,0 @@
-// Copyright 2012 The Gorilla Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package mux
-
-import "net/http"
-
-// SetURLVars sets the URL variables for the given request, to be accessed via
-// mux.Vars for testing route behaviour. Arguments are not modified, a shallow
-// copy is returned.
-//
-// This API should only be used for testing purposes; it provides a way to
-// inject variables into the request context. Alternatively, URL variables
-// can be set by making a route that captures the required variables,
-// starting a server and sending the request to that server.
-func SetURLVars(r *http.Request, val map[string]string) *http.Request {
- return requestWithVars(r, val)
-}
diff --git a/vendor/golang.org/x/sys/LICENSE b/vendor/golang.org/x/sys/LICENSE
deleted file mode 100644
index 6a66aea..0000000
--- a/vendor/golang.org/x/sys/LICENSE
+++ /dev/null
@@ -1,27 +0,0 @@
-Copyright (c) 2009 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.
diff --git a/vendor/golang.org/x/sys/PATENTS b/vendor/golang.org/x/sys/PATENTS
deleted file mode 100644
index 7330990..0000000
--- a/vendor/golang.org/x/sys/PATENTS
+++ /dev/null
@@ -1,22 +0,0 @@
-Additional IP Rights Grant (Patents)
-
-"This implementation" means the copyrightable works distributed by
-Google as part of the Go project.
-
-Google hereby grants to You a perpetual, worldwide, non-exclusive,
-no-charge, royalty-free, irrevocable (except as stated in this section)
-patent license to make, have made, use, offer to sell, sell, import,
-transfer and otherwise run, modify and propagate the contents of this
-implementation of Go, where such license applies only to those patent
-claims, both currently owned or controlled by Google and acquired in
-the future, licensable by Google that are necessarily infringed by this
-implementation of Go. This grant does not include claims that would be
-infringed only as a consequence of further modification of this
-implementation. If you or your agent or exclusive licensee institute or
-order or agree to the institution of patent litigation against any
-entity (including a cross-claim or counterclaim in a lawsuit) alleging
-that this implementation of Go or any code incorporated within this
-implementation of Go constitutes direct or contributory patent
-infringement, or inducement of patent infringement, then any patent
-rights granted to you under this License for this implementation of Go
-shall terminate as of the date such litigation is filed.
diff --git a/vendor/golang.org/x/sys/unix/.gitignore b/vendor/golang.org/x/sys/unix/.gitignore
deleted file mode 100644
index e3e0fc6..0000000
--- a/vendor/golang.org/x/sys/unix/.gitignore
+++ /dev/null
@@ -1,2 +0,0 @@
-_obj/
-unix.test
diff --git a/vendor/golang.org/x/sys/unix/README.md b/vendor/golang.org/x/sys/unix/README.md
deleted file mode 100644
index 7d3c060..0000000
--- a/vendor/golang.org/x/sys/unix/README.md
+++ /dev/null
@@ -1,184 +0,0 @@
-# Building `sys/unix`
-
-The sys/unix package provides access to the raw system call interface of the
-underlying operating system. See: https://godoc.org/golang.org/x/sys/unix
-
-Porting Go to a new architecture/OS combination or adding syscalls, types, or
-constants to an existing architecture/OS pair requires some manual effort;
-however, there are tools that automate much of the process.
-
-## Build Systems
-
-There are currently two ways we generate the necessary files. We are currently
-migrating the build system to use containers so the builds are reproducible.
-This is being done on an OS-by-OS basis. Please update this documentation as
-components of the build system change.
-
-### Old Build System (currently for `GOOS != "linux"`)
-
-The old build system generates the Go files based on the C header files
-present on your system. This means that files
-for a given GOOS/GOARCH pair must be generated on a system with that OS and
-architecture. This also means that the generated code can differ from system
-to system, based on differences in the header files.
-
-To avoid this, if you are using the old build system, only generate the Go
-files on an installation with unmodified header files. It is also important to
-keep track of which version of the OS the files were generated from (ex.
-Darwin 14 vs Darwin 15). This makes it easier to track the progress of changes
-and have each OS upgrade correspond to a single change.
-
-To build the files for your current OS and architecture, make sure GOOS and
-GOARCH are set correctly and run `mkall.sh`. This will generate the files for
-your specific system. Running `mkall.sh -n` shows the commands that will be run.
-
-Requirements: bash, go
-
-### New Build System (currently for `GOOS == "linux"`)
-
-The new build system uses a Docker container to generate the go files directly
-from source checkouts of the kernel and various system libraries. This means
-that on any platform that supports Docker, all the files using the new build
-system can be generated at once, and generated files will not change based on
-what the person running the scripts has installed on their computer.
-
-The OS specific files for the new build system are located in the `${GOOS}`
-directory, and the build is coordinated by the `${GOOS}/mkall.go` program. When
-the kernel or system library updates, modify the Dockerfile at
-`${GOOS}/Dockerfile` to checkout the new release of the source.
-
-To build all the files under the new build system, you must be on an amd64/Linux
-system and have your GOOS and GOARCH set accordingly. Running `mkall.sh` will
-then generate all of the files for all of the GOOS/GOARCH pairs in the new build
-system. Running `mkall.sh -n` shows the commands that will be run.
-
-Requirements: bash, go, docker
-
-## Component files
-
-This section describes the various files used in the code generation process.
-It also contains instructions on how to modify these files to add a new
-architecture/OS or to add additional syscalls, types, or constants. Note that
-if you are using the new build system, the scripts/programs cannot be called normally.
-They must be called from within the docker container.
-
-### asm files
-
-The hand-written assembly file at `asm_${GOOS}_${GOARCH}.s` implements system
-call dispatch. There are three entry points:
-```
- func Syscall(trap, a1, a2, a3 uintptr) (r1, r2, err uintptr)
- func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2, err uintptr)
- func RawSyscall(trap, a1, a2, a3 uintptr) (r1, r2, err uintptr)
-```
-The first and second are the standard ones; they differ only in how many
-arguments can be passed to the kernel. The third is for low-level use by the
-ForkExec wrapper. Unlike the first two, it does not call into the scheduler to
-let it know that a system call is running.
-
-When porting Go to a new architecture/OS, this file must be implemented for
-each GOOS/GOARCH pair.
-
-### mksysnum
-
-Mksysnum is a Go program located at `${GOOS}/mksysnum.go` (or `mksysnum_${GOOS}.go`
-for the old system). This program takes in a list of header files containing the
-syscall number declarations and parses them to produce the corresponding list of
-Go numeric constants. See `zsysnum_${GOOS}_${GOARCH}.go` for the generated
-constants.
-
-Adding new syscall numbers is mostly done by running the build on a sufficiently
-new installation of the target OS (or updating the source checkouts for the
-new build system). However, depending on the OS, you may need to update the
-parsing in mksysnum.
-
-### mksyscall.go
-
-The `syscall.go`, `syscall_${GOOS}.go`, `syscall_${GOOS}_${GOARCH}.go` are
-hand-written Go files which implement system calls (for unix, the specific OS,
-or the specific OS/Architecture pair respectively) that need special handling
-and list `//sys` comments giving prototypes for ones that can be generated.
-
-The mksyscall.go program takes the `//sys` and `//sysnb` comments and converts
-them into syscalls. This requires the name of the prototype in the comment to
-match a syscall number in the `zsysnum_${GOOS}_${GOARCH}.go` file. The function
-prototype can be exported (capitalized) or not.
-
-Adding a new syscall often just requires adding a new `//sys` function prototype
-with the desired arguments and a capitalized name so it is exported. However, if
-you want the interface to the syscall to be different, often one will make an
-unexported `//sys` prototype, and then write a custom wrapper in
-`syscall_${GOOS}.go`.
-
-### types files
-
-For each OS, there is a hand-written Go file at `${GOOS}/types.go` (or
-`types_${GOOS}.go` on the old system). This file includes standard C headers and
-creates Go type aliases to the corresponding C types. The file is then fed
-through godef to get the Go compatible definitions. Finally, the generated code
-is fed though mkpost.go to format the code correctly and remove any hidden or
-private identifiers. This cleaned-up code is written to
-`ztypes_${GOOS}_${GOARCH}.go`.
-
-The hardest part about preparing this file is figuring out which headers to
-include and which symbols need to be `#define`d to get the actual data
-structures that pass through to the kernel system calls. Some C libraries
-preset alternate versions for binary compatibility and translate them on the
-way in and out of system calls, but there is almost always a `#define` that can
-get the real ones.
-See `types_darwin.go` and `linux/types.go` for examples.
-
-To add a new type, add in the necessary include statement at the top of the
-file (if it is not already there) and add in a type alias line. Note that if
-your type is significantly different on different architectures, you may need
-some `#if/#elif` macros in your include statements.
-
-### mkerrors.sh
-
-This script is used to generate the system's various constants. This doesn't
-just include the error numbers and error strings, but also the signal numbers
-and a wide variety of miscellaneous constants. The constants come from the list
-of include files in the `includes_${uname}` variable. A regex then picks out
-the desired `#define` statements, and generates the corresponding Go constants.
-The error numbers and strings are generated from `#include `, and the
-signal numbers and strings are generated from `#include `. All of
-these constants are written to `zerrors_${GOOS}_${GOARCH}.go` via a C program,
-`_errors.c`, which prints out all the constants.
-
-To add a constant, add the header that includes it to the appropriate variable.
-Then, edit the regex (if necessary) to match the desired constant. Avoid making
-the regex too broad to avoid matching unintended constants.
-
-### internal/mkmerge
-
-This program is used to extract duplicate const, func, and type declarations
-from the generated architecture-specific files listed below, and merge these
-into a common file for each OS.
-
-The merge is performed in the following steps:
-1. Construct the set of common code that is idential in all architecture-specific files.
-2. Write this common code to the merged file.
-3. Remove the common code from all architecture-specific files.
-
-
-## Generated files
-
-### `zerrors_${GOOS}_${GOARCH}.go`
-
-A file containing all of the system's generated error numbers, error strings,
-signal numbers, and constants. Generated by `mkerrors.sh` (see above).
-
-### `zsyscall_${GOOS}_${GOARCH}.go`
-
-A file containing all the generated syscalls for a specific GOOS and GOARCH.
-Generated by `mksyscall.go` (see above).
-
-### `zsysnum_${GOOS}_${GOARCH}.go`
-
-A list of numeric constants for all the syscall number of the specific GOOS
-and GOARCH. Generated by mksysnum (see above).
-
-### `ztypes_${GOOS}_${GOARCH}.go`
-
-A file containing Go types for passing into (or returning from) syscalls.
-Generated by godefs and the types file (see above).
diff --git a/vendor/golang.org/x/sys/unix/affinity_linux.go b/vendor/golang.org/x/sys/unix/affinity_linux.go
deleted file mode 100644
index 6e5c81a..0000000
--- a/vendor/golang.org/x/sys/unix/affinity_linux.go
+++ /dev/null
@@ -1,86 +0,0 @@
-// Copyright 2018 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-// CPU affinity functions
-
-package unix
-
-import (
- "math/bits"
- "unsafe"
-)
-
-const cpuSetSize = _CPU_SETSIZE / _NCPUBITS
-
-// CPUSet represents a CPU affinity mask.
-type CPUSet [cpuSetSize]cpuMask
-
-func schedAffinity(trap uintptr, pid int, set *CPUSet) error {
- _, _, e := RawSyscall(trap, uintptr(pid), uintptr(unsafe.Sizeof(*set)), uintptr(unsafe.Pointer(set)))
- if e != 0 {
- return errnoErr(e)
- }
- return nil
-}
-
-// SchedGetaffinity gets the CPU affinity mask of the thread specified by pid.
-// If pid is 0 the calling thread is used.
-func SchedGetaffinity(pid int, set *CPUSet) error {
- return schedAffinity(SYS_SCHED_GETAFFINITY, pid, set)
-}
-
-// SchedSetaffinity sets the CPU affinity mask of the thread specified by pid.
-// If pid is 0 the calling thread is used.
-func SchedSetaffinity(pid int, set *CPUSet) error {
- return schedAffinity(SYS_SCHED_SETAFFINITY, pid, set)
-}
-
-// Zero clears the set s, so that it contains no CPUs.
-func (s *CPUSet) Zero() {
- for i := range s {
- s[i] = 0
- }
-}
-
-func cpuBitsIndex(cpu int) int {
- return cpu / _NCPUBITS
-}
-
-func cpuBitsMask(cpu int) cpuMask {
- return cpuMask(1 << (uint(cpu) % _NCPUBITS))
-}
-
-// Set adds cpu to the set s.
-func (s *CPUSet) Set(cpu int) {
- i := cpuBitsIndex(cpu)
- if i < len(s) {
- s[i] |= cpuBitsMask(cpu)
- }
-}
-
-// Clear removes cpu from the set s.
-func (s *CPUSet) Clear(cpu int) {
- i := cpuBitsIndex(cpu)
- if i < len(s) {
- s[i] &^= cpuBitsMask(cpu)
- }
-}
-
-// IsSet reports whether cpu is in the set s.
-func (s *CPUSet) IsSet(cpu int) bool {
- i := cpuBitsIndex(cpu)
- if i < len(s) {
- return s[i]&cpuBitsMask(cpu) != 0
- }
- return false
-}
-
-// Count returns the number of CPUs in the set s.
-func (s *CPUSet) Count() int {
- c := 0
- for _, b := range s {
- c += bits.OnesCount64(uint64(b))
- }
- return c
-}
diff --git a/vendor/golang.org/x/sys/unix/aliases.go b/vendor/golang.org/x/sys/unix/aliases.go
deleted file mode 100644
index b0e4198..0000000
--- a/vendor/golang.org/x/sys/unix/aliases.go
+++ /dev/null
@@ -1,13 +0,0 @@
-// Copyright 2018 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-//go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris || zos
-
-package unix
-
-import "syscall"
-
-type Signal = syscall.Signal
-type Errno = syscall.Errno
-type SysProcAttr = syscall.SysProcAttr
diff --git a/vendor/golang.org/x/sys/unix/asm_aix_ppc64.s b/vendor/golang.org/x/sys/unix/asm_aix_ppc64.s
deleted file mode 100644
index 269e173..0000000
--- a/vendor/golang.org/x/sys/unix/asm_aix_ppc64.s
+++ /dev/null
@@ -1,17 +0,0 @@
-// Copyright 2018 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-//go:build gc
-
-#include "textflag.h"
-
-//
-// System calls for ppc64, AIX are implemented in runtime/syscall_aix.go
-//
-
-TEXT ·syscall6(SB),NOSPLIT,$0-88
- JMP syscall·syscall6(SB)
-
-TEXT ·rawSyscall6(SB),NOSPLIT,$0-88
- JMP syscall·rawSyscall6(SB)
diff --git a/vendor/golang.org/x/sys/unix/asm_bsd_386.s b/vendor/golang.org/x/sys/unix/asm_bsd_386.s
deleted file mode 100644
index a4fcef0..0000000
--- a/vendor/golang.org/x/sys/unix/asm_bsd_386.s
+++ /dev/null
@@ -1,27 +0,0 @@
-// Copyright 2021 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-//go:build (freebsd || netbsd || openbsd) && gc
-
-#include "textflag.h"
-
-// System call support for 386 BSD
-
-// Just jump to package syscall's implementation for all these functions.
-// The runtime may know about them.
-
-TEXT ·Syscall(SB),NOSPLIT,$0-28
- JMP syscall·Syscall(SB)
-
-TEXT ·Syscall6(SB),NOSPLIT,$0-40
- JMP syscall·Syscall6(SB)
-
-TEXT ·Syscall9(SB),NOSPLIT,$0-52
- JMP syscall·Syscall9(SB)
-
-TEXT ·RawSyscall(SB),NOSPLIT,$0-28
- JMP syscall·RawSyscall(SB)
-
-TEXT ·RawSyscall6(SB),NOSPLIT,$0-40
- JMP syscall·RawSyscall6(SB)
diff --git a/vendor/golang.org/x/sys/unix/asm_bsd_amd64.s b/vendor/golang.org/x/sys/unix/asm_bsd_amd64.s
deleted file mode 100644
index 1e63615..0000000
--- a/vendor/golang.org/x/sys/unix/asm_bsd_amd64.s
+++ /dev/null
@@ -1,27 +0,0 @@
-// Copyright 2021 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-//go:build (darwin || dragonfly || freebsd || netbsd || openbsd) && gc
-
-#include "textflag.h"
-
-// System call support for AMD64 BSD
-
-// Just jump to package syscall's implementation for all these functions.
-// The runtime may know about them.
-
-TEXT ·Syscall(SB),NOSPLIT,$0-56
- JMP syscall·Syscall(SB)
-
-TEXT ·Syscall6(SB),NOSPLIT,$0-80
- JMP syscall·Syscall6(SB)
-
-TEXT ·Syscall9(SB),NOSPLIT,$0-104
- JMP syscall·Syscall9(SB)
-
-TEXT ·RawSyscall(SB),NOSPLIT,$0-56
- JMP syscall·RawSyscall(SB)
-
-TEXT ·RawSyscall6(SB),NOSPLIT,$0-80
- JMP syscall·RawSyscall6(SB)
diff --git a/vendor/golang.org/x/sys/unix/asm_bsd_arm.s b/vendor/golang.org/x/sys/unix/asm_bsd_arm.s
deleted file mode 100644
index 6496c31..0000000
--- a/vendor/golang.org/x/sys/unix/asm_bsd_arm.s
+++ /dev/null
@@ -1,27 +0,0 @@
-// Copyright 2021 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-//go:build (freebsd || netbsd || openbsd) && gc
-
-#include "textflag.h"
-
-// System call support for ARM BSD
-
-// Just jump to package syscall's implementation for all these functions.
-// The runtime may know about them.
-
-TEXT ·Syscall(SB),NOSPLIT,$0-28
- B syscall·Syscall(SB)
-
-TEXT ·Syscall6(SB),NOSPLIT,$0-40
- B syscall·Syscall6(SB)
-
-TEXT ·Syscall9(SB),NOSPLIT,$0-52
- B syscall·Syscall9(SB)
-
-TEXT ·RawSyscall(SB),NOSPLIT,$0-28
- B syscall·RawSyscall(SB)
-
-TEXT ·RawSyscall6(SB),NOSPLIT,$0-40
- B syscall·RawSyscall6(SB)
diff --git a/vendor/golang.org/x/sys/unix/asm_bsd_arm64.s b/vendor/golang.org/x/sys/unix/asm_bsd_arm64.s
deleted file mode 100644
index 4fd1f54..0000000
--- a/vendor/golang.org/x/sys/unix/asm_bsd_arm64.s
+++ /dev/null
@@ -1,27 +0,0 @@
-// Copyright 2021 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-//go:build (darwin || freebsd || netbsd || openbsd) && gc
-
-#include "textflag.h"
-
-// System call support for ARM64 BSD
-
-// Just jump to package syscall's implementation for all these functions.
-// The runtime may know about them.
-
-TEXT ·Syscall(SB),NOSPLIT,$0-56
- JMP syscall·Syscall(SB)
-
-TEXT ·Syscall6(SB),NOSPLIT,$0-80
- JMP syscall·Syscall6(SB)
-
-TEXT ·Syscall9(SB),NOSPLIT,$0-104
- JMP syscall·Syscall9(SB)
-
-TEXT ·RawSyscall(SB),NOSPLIT,$0-56
- JMP syscall·RawSyscall(SB)
-
-TEXT ·RawSyscall6(SB),NOSPLIT,$0-80
- JMP syscall·RawSyscall6(SB)
diff --git a/vendor/golang.org/x/sys/unix/asm_bsd_ppc64.s b/vendor/golang.org/x/sys/unix/asm_bsd_ppc64.s
deleted file mode 100644
index 42f7eb9..0000000
--- a/vendor/golang.org/x/sys/unix/asm_bsd_ppc64.s
+++ /dev/null
@@ -1,29 +0,0 @@
-// Copyright 2022 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-//go:build (darwin || freebsd || netbsd || openbsd) && gc
-
-#include "textflag.h"
-
-//
-// System call support for ppc64, BSD
-//
-
-// Just jump to package syscall's implementation for all these functions.
-// The runtime may know about them.
-
-TEXT ·Syscall(SB),NOSPLIT,$0-56
- JMP syscall·Syscall(SB)
-
-TEXT ·Syscall6(SB),NOSPLIT,$0-80
- JMP syscall·Syscall6(SB)
-
-TEXT ·Syscall9(SB),NOSPLIT,$0-104
- JMP syscall·Syscall9(SB)
-
-TEXT ·RawSyscall(SB),NOSPLIT,$0-56
- JMP syscall·RawSyscall(SB)
-
-TEXT ·RawSyscall6(SB),NOSPLIT,$0-80
- JMP syscall·RawSyscall6(SB)
diff --git a/vendor/golang.org/x/sys/unix/asm_bsd_riscv64.s b/vendor/golang.org/x/sys/unix/asm_bsd_riscv64.s
deleted file mode 100644
index f890266..0000000
--- a/vendor/golang.org/x/sys/unix/asm_bsd_riscv64.s
+++ /dev/null
@@ -1,27 +0,0 @@
-// Copyright 2021 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-//go:build (darwin || freebsd || netbsd || openbsd) && gc
-
-#include "textflag.h"
-
-// System call support for RISCV64 BSD
-
-// Just jump to package syscall's implementation for all these functions.
-// The runtime may know about them.
-
-TEXT ·Syscall(SB),NOSPLIT,$0-56
- JMP syscall·Syscall(SB)
-
-TEXT ·Syscall6(SB),NOSPLIT,$0-80
- JMP syscall·Syscall6(SB)
-
-TEXT ·Syscall9(SB),NOSPLIT,$0-104
- JMP syscall·Syscall9(SB)
-
-TEXT ·RawSyscall(SB),NOSPLIT,$0-56
- JMP syscall·RawSyscall(SB)
-
-TEXT ·RawSyscall6(SB),NOSPLIT,$0-80
- JMP syscall·RawSyscall6(SB)
diff --git a/vendor/golang.org/x/sys/unix/asm_linux_386.s b/vendor/golang.org/x/sys/unix/asm_linux_386.s
deleted file mode 100644
index 3b47348..0000000
--- a/vendor/golang.org/x/sys/unix/asm_linux_386.s
+++ /dev/null
@@ -1,65 +0,0 @@
-// Copyright 2009 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-//go:build gc
-
-#include "textflag.h"
-
-//
-// System calls for 386, Linux
-//
-
-// See ../runtime/sys_linux_386.s for the reason why we always use int 0x80
-// instead of the glibc-specific "CALL 0x10(GS)".
-#define INVOKE_SYSCALL INT $0x80
-
-// Just jump to package syscall's implementation for all these functions.
-// The runtime may know about them.
-
-TEXT ·Syscall(SB),NOSPLIT,$0-28
- JMP syscall·Syscall(SB)
-
-TEXT ·Syscall6(SB),NOSPLIT,$0-40
- JMP syscall·Syscall6(SB)
-
-TEXT ·SyscallNoError(SB),NOSPLIT,$0-24
- CALL runtime·entersyscall(SB)
- MOVL trap+0(FP), AX // syscall entry
- MOVL a1+4(FP), BX
- MOVL a2+8(FP), CX
- MOVL a3+12(FP), DX
- MOVL $0, SI
- MOVL $0, DI
- INVOKE_SYSCALL
- MOVL AX, r1+16(FP)
- MOVL DX, r2+20(FP)
- CALL runtime·exitsyscall(SB)
- RET
-
-TEXT ·RawSyscall(SB),NOSPLIT,$0-28
- JMP syscall·RawSyscall(SB)
-
-TEXT ·RawSyscall6(SB),NOSPLIT,$0-40
- JMP syscall·RawSyscall6(SB)
-
-TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-24
- MOVL trap+0(FP), AX // syscall entry
- MOVL a1+4(FP), BX
- MOVL a2+8(FP), CX
- MOVL a3+12(FP), DX
- MOVL $0, SI
- MOVL $0, DI
- INVOKE_SYSCALL
- MOVL AX, r1+16(FP)
- MOVL DX, r2+20(FP)
- RET
-
-TEXT ·socketcall(SB),NOSPLIT,$0-36
- JMP syscall·socketcall(SB)
-
-TEXT ·rawsocketcall(SB),NOSPLIT,$0-36
- JMP syscall·rawsocketcall(SB)
-
-TEXT ·seek(SB),NOSPLIT,$0-28
- JMP syscall·seek(SB)
diff --git a/vendor/golang.org/x/sys/unix/asm_linux_amd64.s b/vendor/golang.org/x/sys/unix/asm_linux_amd64.s
deleted file mode 100644
index 67e29f3..0000000
--- a/vendor/golang.org/x/sys/unix/asm_linux_amd64.s
+++ /dev/null
@@ -1,57 +0,0 @@
-// Copyright 2009 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-//go:build gc
-
-#include "textflag.h"
-
-//
-// System calls for AMD64, Linux
-//
-
-// Just jump to package syscall's implementation for all these functions.
-// The runtime may know about them.
-
-TEXT ·Syscall(SB),NOSPLIT,$0-56
- JMP syscall·Syscall(SB)
-
-TEXT ·Syscall6(SB),NOSPLIT,$0-80
- JMP syscall·Syscall6(SB)
-
-TEXT ·SyscallNoError(SB),NOSPLIT,$0-48
- CALL runtime·entersyscall(SB)
- MOVQ a1+8(FP), DI
- MOVQ a2+16(FP), SI
- MOVQ a3+24(FP), DX
- MOVQ $0, R10
- MOVQ $0, R8
- MOVQ $0, R9
- MOVQ trap+0(FP), AX // syscall entry
- SYSCALL
- MOVQ AX, r1+32(FP)
- MOVQ DX, r2+40(FP)
- CALL runtime·exitsyscall(SB)
- RET
-
-TEXT ·RawSyscall(SB),NOSPLIT,$0-56
- JMP syscall·RawSyscall(SB)
-
-TEXT ·RawSyscall6(SB),NOSPLIT,$0-80
- JMP syscall·RawSyscall6(SB)
-
-TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-48
- MOVQ a1+8(FP), DI
- MOVQ a2+16(FP), SI
- MOVQ a3+24(FP), DX
- MOVQ $0, R10
- MOVQ $0, R8
- MOVQ $0, R9
- MOVQ trap+0(FP), AX // syscall entry
- SYSCALL
- MOVQ AX, r1+32(FP)
- MOVQ DX, r2+40(FP)
- RET
-
-TEXT ·gettimeofday(SB),NOSPLIT,$0-16
- JMP syscall·gettimeofday(SB)
diff --git a/vendor/golang.org/x/sys/unix/asm_linux_arm.s b/vendor/golang.org/x/sys/unix/asm_linux_arm.s
deleted file mode 100644
index d6ae269..0000000
--- a/vendor/golang.org/x/sys/unix/asm_linux_arm.s
+++ /dev/null
@@ -1,56 +0,0 @@
-// Copyright 2009 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-//go:build gc
-
-#include "textflag.h"
-
-//
-// System calls for arm, Linux
-//
-
-// Just jump to package syscall's implementation for all these functions.
-// The runtime may know about them.
-
-TEXT ·Syscall(SB),NOSPLIT,$0-28
- B syscall·Syscall(SB)
-
-TEXT ·Syscall6(SB),NOSPLIT,$0-40
- B syscall·Syscall6(SB)
-
-TEXT ·SyscallNoError(SB),NOSPLIT,$0-24
- BL runtime·entersyscall(SB)
- MOVW trap+0(FP), R7
- MOVW a1+4(FP), R0
- MOVW a2+8(FP), R1
- MOVW a3+12(FP), R2
- MOVW $0, R3
- MOVW $0, R4
- MOVW $0, R5
- SWI $0
- MOVW R0, r1+16(FP)
- MOVW $0, R0
- MOVW R0, r2+20(FP)
- BL runtime·exitsyscall(SB)
- RET
-
-TEXT ·RawSyscall(SB),NOSPLIT,$0-28
- B syscall·RawSyscall(SB)
-
-TEXT ·RawSyscall6(SB),NOSPLIT,$0-40
- B syscall·RawSyscall6(SB)
-
-TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-24
- MOVW trap+0(FP), R7 // syscall entry
- MOVW a1+4(FP), R0
- MOVW a2+8(FP), R1
- MOVW a3+12(FP), R2
- SWI $0
- MOVW R0, r1+16(FP)
- MOVW $0, R0
- MOVW R0, r2+20(FP)
- RET
-
-TEXT ·seek(SB),NOSPLIT,$0-28
- B syscall·seek(SB)
diff --git a/vendor/golang.org/x/sys/unix/asm_linux_arm64.s b/vendor/golang.org/x/sys/unix/asm_linux_arm64.s
deleted file mode 100644
index 01e5e25..0000000
--- a/vendor/golang.org/x/sys/unix/asm_linux_arm64.s
+++ /dev/null
@@ -1,50 +0,0 @@
-// Copyright 2015 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-//go:build linux && arm64 && gc
-
-#include "textflag.h"
-
-// Just jump to package syscall's implementation for all these functions.
-// The runtime may know about them.
-
-TEXT ·Syscall(SB),NOSPLIT,$0-56
- B syscall·Syscall(SB)
-
-TEXT ·Syscall6(SB),NOSPLIT,$0-80
- B syscall·Syscall6(SB)
-
-TEXT ·SyscallNoError(SB),NOSPLIT,$0-48
- BL runtime·entersyscall(SB)
- MOVD a1+8(FP), R0
- MOVD a2+16(FP), R1
- MOVD a3+24(FP), R2
- MOVD $0, R3
- MOVD $0, R4
- MOVD $0, R5
- MOVD trap+0(FP), R8 // syscall entry
- SVC
- MOVD R0, r1+32(FP) // r1
- MOVD R1, r2+40(FP) // r2
- BL runtime·exitsyscall(SB)
- RET
-
-TEXT ·RawSyscall(SB),NOSPLIT,$0-56
- B syscall·RawSyscall(SB)
-
-TEXT ·RawSyscall6(SB),NOSPLIT,$0-80
- B syscall·RawSyscall6(SB)
-
-TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-48
- MOVD a1+8(FP), R0
- MOVD a2+16(FP), R1
- MOVD a3+24(FP), R2
- MOVD $0, R3
- MOVD $0, R4
- MOVD $0, R5
- MOVD trap+0(FP), R8 // syscall entry
- SVC
- MOVD R0, r1+32(FP)
- MOVD R1, r2+40(FP)
- RET
diff --git a/vendor/golang.org/x/sys/unix/asm_linux_loong64.s b/vendor/golang.org/x/sys/unix/asm_linux_loong64.s
deleted file mode 100644
index 2abf12f..0000000
--- a/vendor/golang.org/x/sys/unix/asm_linux_loong64.s
+++ /dev/null
@@ -1,51 +0,0 @@
-// Copyright 2022 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-//go:build linux && loong64 && gc
-
-#include "textflag.h"
-
-
-// Just jump to package syscall's implementation for all these functions.
-// The runtime may know about them.
-
-TEXT ·Syscall(SB),NOSPLIT,$0-56
- JMP syscall·Syscall(SB)
-
-TEXT ·Syscall6(SB),NOSPLIT,$0-80
- JMP syscall·Syscall6(SB)
-
-TEXT ·SyscallNoError(SB),NOSPLIT,$0-48
- JAL runtime·entersyscall(SB)
- MOVV a1+8(FP), R4
- MOVV a2+16(FP), R5
- MOVV a3+24(FP), R6
- MOVV R0, R7
- MOVV R0, R8
- MOVV R0, R9
- MOVV trap+0(FP), R11 // syscall entry
- SYSCALL
- MOVV R4, r1+32(FP)
- MOVV R0, r2+40(FP) // r2 is not used. Always set to 0
- JAL runtime·exitsyscall(SB)
- RET
-
-TEXT ·RawSyscall(SB),NOSPLIT,$0-56
- JMP syscall·RawSyscall(SB)
-
-TEXT ·RawSyscall6(SB),NOSPLIT,$0-80
- JMP syscall·RawSyscall6(SB)
-
-TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-48
- MOVV a1+8(FP), R4
- MOVV a2+16(FP), R5
- MOVV a3+24(FP), R6
- MOVV R0, R7
- MOVV R0, R8
- MOVV R0, R9
- MOVV trap+0(FP), R11 // syscall entry
- SYSCALL
- MOVV R4, r1+32(FP)
- MOVV R0, r2+40(FP) // r2 is not used. Always set to 0
- RET
diff --git a/vendor/golang.org/x/sys/unix/asm_linux_mips64x.s b/vendor/golang.org/x/sys/unix/asm_linux_mips64x.s
deleted file mode 100644
index f84bae7..0000000
--- a/vendor/golang.org/x/sys/unix/asm_linux_mips64x.s
+++ /dev/null
@@ -1,54 +0,0 @@
-// Copyright 2015 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-//go:build linux && (mips64 || mips64le) && gc
-
-#include "textflag.h"
-
-//
-// System calls for mips64, Linux
-//
-
-// Just jump to package syscall's implementation for all these functions.
-// The runtime may know about them.
-
-TEXT ·Syscall(SB),NOSPLIT,$0-56
- JMP syscall·Syscall(SB)
-
-TEXT ·Syscall6(SB),NOSPLIT,$0-80
- JMP syscall·Syscall6(SB)
-
-TEXT ·SyscallNoError(SB),NOSPLIT,$0-48
- JAL runtime·entersyscall(SB)
- MOVV a1+8(FP), R4
- MOVV a2+16(FP), R5
- MOVV a3+24(FP), R6
- MOVV R0, R7
- MOVV R0, R8
- MOVV R0, R9
- MOVV trap+0(FP), R2 // syscall entry
- SYSCALL
- MOVV R2, r1+32(FP)
- MOVV R3, r2+40(FP)
- JAL runtime·exitsyscall(SB)
- RET
-
-TEXT ·RawSyscall(SB),NOSPLIT,$0-56
- JMP syscall·RawSyscall(SB)
-
-TEXT ·RawSyscall6(SB),NOSPLIT,$0-80
- JMP syscall·RawSyscall6(SB)
-
-TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-48
- MOVV a1+8(FP), R4
- MOVV a2+16(FP), R5
- MOVV a3+24(FP), R6
- MOVV R0, R7
- MOVV R0, R8
- MOVV R0, R9
- MOVV trap+0(FP), R2 // syscall entry
- SYSCALL
- MOVV R2, r1+32(FP)
- MOVV R3, r2+40(FP)
- RET
diff --git a/vendor/golang.org/x/sys/unix/asm_linux_mipsx.s b/vendor/golang.org/x/sys/unix/asm_linux_mipsx.s
deleted file mode 100644
index f08f628..0000000
--- a/vendor/golang.org/x/sys/unix/asm_linux_mipsx.s
+++ /dev/null
@@ -1,52 +0,0 @@
-// Copyright 2016 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-//go:build linux && (mips || mipsle) && gc
-
-#include "textflag.h"
-
-//
-// System calls for mips, Linux
-//
-
-// Just jump to package syscall's implementation for all these functions.
-// The runtime may know about them.
-
-TEXT ·Syscall(SB),NOSPLIT,$0-28
- JMP syscall·Syscall(SB)
-
-TEXT ·Syscall6(SB),NOSPLIT,$0-40
- JMP syscall·Syscall6(SB)
-
-TEXT ·Syscall9(SB),NOSPLIT,$0-52
- JMP syscall·Syscall9(SB)
-
-TEXT ·SyscallNoError(SB),NOSPLIT,$0-24
- JAL runtime·entersyscall(SB)
- MOVW a1+4(FP), R4
- MOVW a2+8(FP), R5
- MOVW a3+12(FP), R6
- MOVW R0, R7
- MOVW trap+0(FP), R2 // syscall entry
- SYSCALL
- MOVW R2, r1+16(FP) // r1
- MOVW R3, r2+20(FP) // r2
- JAL runtime·exitsyscall(SB)
- RET
-
-TEXT ·RawSyscall(SB),NOSPLIT,$0-28
- JMP syscall·RawSyscall(SB)
-
-TEXT ·RawSyscall6(SB),NOSPLIT,$0-40
- JMP syscall·RawSyscall6(SB)
-
-TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-24
- MOVW a1+4(FP), R4
- MOVW a2+8(FP), R5
- MOVW a3+12(FP), R6
- MOVW trap+0(FP), R2 // syscall entry
- SYSCALL
- MOVW R2, r1+16(FP)
- MOVW R3, r2+20(FP)
- RET
diff --git a/vendor/golang.org/x/sys/unix/asm_linux_ppc64x.s b/vendor/golang.org/x/sys/unix/asm_linux_ppc64x.s
deleted file mode 100644
index bdfc024..0000000
--- a/vendor/golang.org/x/sys/unix/asm_linux_ppc64x.s
+++ /dev/null
@@ -1,42 +0,0 @@
-// Copyright 2014 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-//go:build linux && (ppc64 || ppc64le) && gc
-
-#include "textflag.h"
-
-//
-// System calls for ppc64, Linux
-//
-
-// Just jump to package syscall's implementation for all these functions.
-// The runtime may know about them.
-
-TEXT ·SyscallNoError(SB),NOSPLIT,$0-48
- BL runtime·entersyscall(SB)
- MOVD a1+8(FP), R3
- MOVD a2+16(FP), R4
- MOVD a3+24(FP), R5
- MOVD R0, R6
- MOVD R0, R7
- MOVD R0, R8
- MOVD trap+0(FP), R9 // syscall entry
- SYSCALL R9
- MOVD R3, r1+32(FP)
- MOVD R4, r2+40(FP)
- BL runtime·exitsyscall(SB)
- RET
-
-TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-48
- MOVD a1+8(FP), R3
- MOVD a2+16(FP), R4
- MOVD a3+24(FP), R5
- MOVD R0, R6
- MOVD R0, R7
- MOVD R0, R8
- MOVD trap+0(FP), R9 // syscall entry
- SYSCALL R9
- MOVD R3, r1+32(FP)
- MOVD R4, r2+40(FP)
- RET
diff --git a/vendor/golang.org/x/sys/unix/asm_linux_riscv64.s b/vendor/golang.org/x/sys/unix/asm_linux_riscv64.s
deleted file mode 100644
index 2e8c996..0000000
--- a/vendor/golang.org/x/sys/unix/asm_linux_riscv64.s
+++ /dev/null
@@ -1,47 +0,0 @@
-// Copyright 2019 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-//go:build riscv64 && gc
-
-#include "textflag.h"
-
-//
-// System calls for linux/riscv64.
-//
-// Where available, just jump to package syscall's implementation of
-// these functions.
-
-TEXT ·Syscall(SB),NOSPLIT,$0-56
- JMP syscall·Syscall(SB)
-
-TEXT ·Syscall6(SB),NOSPLIT,$0-80
- JMP syscall·Syscall6(SB)
-
-TEXT ·SyscallNoError(SB),NOSPLIT,$0-48
- CALL runtime·entersyscall(SB)
- MOV a1+8(FP), A0
- MOV a2+16(FP), A1
- MOV a3+24(FP), A2
- MOV trap+0(FP), A7 // syscall entry
- ECALL
- MOV A0, r1+32(FP) // r1
- MOV A1, r2+40(FP) // r2
- CALL runtime·exitsyscall(SB)
- RET
-
-TEXT ·RawSyscall(SB),NOSPLIT,$0-56
- JMP syscall·RawSyscall(SB)
-
-TEXT ·RawSyscall6(SB),NOSPLIT,$0-80
- JMP syscall·RawSyscall6(SB)
-
-TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-48
- MOV a1+8(FP), A0
- MOV a2+16(FP), A1
- MOV a3+24(FP), A2
- MOV trap+0(FP), A7 // syscall entry
- ECALL
- MOV A0, r1+32(FP)
- MOV A1, r2+40(FP)
- RET
diff --git a/vendor/golang.org/x/sys/unix/asm_linux_s390x.s b/vendor/golang.org/x/sys/unix/asm_linux_s390x.s
deleted file mode 100644
index 2c394b1..0000000
--- a/vendor/golang.org/x/sys/unix/asm_linux_s390x.s
+++ /dev/null
@@ -1,54 +0,0 @@
-// Copyright 2016 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-//go:build linux && s390x && gc
-
-#include "textflag.h"
-
-//
-// System calls for s390x, Linux
-//
-
-// Just jump to package syscall's implementation for all these functions.
-// The runtime may know about them.
-
-TEXT ·Syscall(SB),NOSPLIT,$0-56
- BR syscall·Syscall(SB)
-
-TEXT ·Syscall6(SB),NOSPLIT,$0-80
- BR syscall·Syscall6(SB)
-
-TEXT ·SyscallNoError(SB),NOSPLIT,$0-48
- BL runtime·entersyscall(SB)
- MOVD a1+8(FP), R2
- MOVD a2+16(FP), R3
- MOVD a3+24(FP), R4
- MOVD $0, R5
- MOVD $0, R6
- MOVD $0, R7
- MOVD trap+0(FP), R1 // syscall entry
- SYSCALL
- MOVD R2, r1+32(FP)
- MOVD R3, r2+40(FP)
- BL runtime·exitsyscall(SB)
- RET
-
-TEXT ·RawSyscall(SB),NOSPLIT,$0-56
- BR syscall·RawSyscall(SB)
-
-TEXT ·RawSyscall6(SB),NOSPLIT,$0-80
- BR syscall·RawSyscall6(SB)
-
-TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-48
- MOVD a1+8(FP), R2
- MOVD a2+16(FP), R3
- MOVD a3+24(FP), R4
- MOVD $0, R5
- MOVD $0, R6
- MOVD $0, R7
- MOVD trap+0(FP), R1 // syscall entry
- SYSCALL
- MOVD R2, r1+32(FP)
- MOVD R3, r2+40(FP)
- RET
diff --git a/vendor/golang.org/x/sys/unix/asm_openbsd_mips64.s b/vendor/golang.org/x/sys/unix/asm_openbsd_mips64.s
deleted file mode 100644
index fab586a..0000000
--- a/vendor/golang.org/x/sys/unix/asm_openbsd_mips64.s
+++ /dev/null
@@ -1,29 +0,0 @@
-// Copyright 2019 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-//go:build gc
-
-#include "textflag.h"
-
-//
-// System call support for mips64, OpenBSD
-//
-
-// Just jump to package syscall's implementation for all these functions.
-// The runtime may know about them.
-
-TEXT ·Syscall(SB),NOSPLIT,$0-56
- JMP syscall·Syscall(SB)
-
-TEXT ·Syscall6(SB),NOSPLIT,$0-80
- JMP syscall·Syscall6(SB)
-
-TEXT ·Syscall9(SB),NOSPLIT,$0-104
- JMP syscall·Syscall9(SB)
-
-TEXT ·RawSyscall(SB),NOSPLIT,$0-56
- JMP syscall·RawSyscall(SB)
-
-TEXT ·RawSyscall6(SB),NOSPLIT,$0-80
- JMP syscall·RawSyscall6(SB)
diff --git a/vendor/golang.org/x/sys/unix/asm_solaris_amd64.s b/vendor/golang.org/x/sys/unix/asm_solaris_amd64.s
deleted file mode 100644
index f949ec5..0000000
--- a/vendor/golang.org/x/sys/unix/asm_solaris_amd64.s
+++ /dev/null
@@ -1,17 +0,0 @@
-// Copyright 2014 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-//go:build gc
-
-#include "textflag.h"
-
-//
-// System calls for amd64, Solaris are implemented in runtime/syscall_solaris.go
-//
-
-TEXT ·sysvicall6(SB),NOSPLIT,$0-88
- JMP syscall·sysvicall6(SB)
-
-TEXT ·rawSysvicall6(SB),NOSPLIT,$0-88
- JMP syscall·rawSysvicall6(SB)
diff --git a/vendor/golang.org/x/sys/unix/asm_zos_s390x.s b/vendor/golang.org/x/sys/unix/asm_zos_s390x.s
deleted file mode 100644
index 2f67ba8..0000000
--- a/vendor/golang.org/x/sys/unix/asm_zos_s390x.s
+++ /dev/null
@@ -1,423 +0,0 @@
-// Copyright 2020 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-//go:build zos && s390x && gc
-
-#include "textflag.h"
-
-#define PSALAA 1208(R0)
-#define GTAB64(x) 80(x)
-#define LCA64(x) 88(x)
-#define CAA(x) 8(x)
-#define EDCHPXV(x) 1016(x) // in the CAA
-#define SAVSTACK_ASYNC(x) 336(x) // in the LCA
-
-// SS_*, where x=SAVSTACK_ASYNC
-#define SS_LE(x) 0(x)
-#define SS_GO(x) 8(x)
-#define SS_ERRNO(x) 16(x)
-#define SS_ERRNOJR(x) 20(x)
-
-#define LE_CALL BYTE $0x0D; BYTE $0x76; // BL R7, R6
-
-TEXT ·clearErrno(SB),NOSPLIT,$0-0
- BL addrerrno<>(SB)
- MOVD $0, 0(R3)
- RET
-
-// Returns the address of errno in R3.
-TEXT addrerrno<>(SB),NOSPLIT|NOFRAME,$0-0
- // Get library control area (LCA).
- MOVW PSALAA, R8
- MOVD LCA64(R8), R8
-
- // Get __errno FuncDesc.
- MOVD CAA(R8), R9
- MOVD EDCHPXV(R9), R9
- ADD $(0x156*16), R9
- LMG 0(R9), R5, R6
-
- // Switch to saved LE stack.
- MOVD SAVSTACK_ASYNC(R8), R9
- MOVD 0(R9), R4
- MOVD $0, 0(R9)
-
- // Call __errno function.
- LE_CALL
- NOPH
-
- // Switch back to Go stack.
- XOR R0, R0 // Restore R0 to $0.
- MOVD R4, 0(R9) // Save stack pointer.
- RET
-
-TEXT ·syscall_syscall(SB),NOSPLIT,$0-56
- BL runtime·entersyscall(SB)
- MOVD a1+8(FP), R1
- MOVD a2+16(FP), R2
- MOVD a3+24(FP), R3
-
- // Get library control area (LCA).
- MOVW PSALAA, R8
- MOVD LCA64(R8), R8
-
- // Get function.
- MOVD CAA(R8), R9
- MOVD EDCHPXV(R9), R9
- MOVD trap+0(FP), R5
- SLD $4, R5
- ADD R5, R9
- LMG 0(R9), R5, R6
-
- // Restore LE stack.
- MOVD SAVSTACK_ASYNC(R8), R9
- MOVD 0(R9), R4
- MOVD $0, 0(R9)
-
- // Call function.
- LE_CALL
- NOPH
- XOR R0, R0 // Restore R0 to $0.
- MOVD R4, 0(R9) // Save stack pointer.
-
- MOVD R3, r1+32(FP)
- MOVD R0, r2+40(FP)
- MOVD R0, err+48(FP)
- MOVW R3, R4
- CMP R4, $-1
- BNE done
- BL addrerrno<>(SB)
- MOVWZ 0(R3), R3
- MOVD R3, err+48(FP)
-done:
- BL runtime·exitsyscall(SB)
- RET
-
-TEXT ·syscall_rawsyscall(SB),NOSPLIT,$0-56
- MOVD a1+8(FP), R1
- MOVD a2+16(FP), R2
- MOVD a3+24(FP), R3
-
- // Get library control area (LCA).
- MOVW PSALAA, R8
- MOVD LCA64(R8), R8
-
- // Get function.
- MOVD CAA(R8), R9
- MOVD EDCHPXV(R9), R9
- MOVD trap+0(FP), R5
- SLD $4, R5
- ADD R5, R9
- LMG 0(R9), R5, R6
-
- // Restore LE stack.
- MOVD SAVSTACK_ASYNC(R8), R9
- MOVD 0(R9), R4
- MOVD $0, 0(R9)
-
- // Call function.
- LE_CALL
- NOPH
- XOR R0, R0 // Restore R0 to $0.
- MOVD R4, 0(R9) // Save stack pointer.
-
- MOVD R3, r1+32(FP)
- MOVD R0, r2+40(FP)
- MOVD R0, err+48(FP)
- MOVW R3, R4
- CMP R4, $-1
- BNE done
- BL addrerrno<>(SB)
- MOVWZ 0(R3), R3
- MOVD R3, err+48(FP)
-done:
- RET
-
-TEXT ·syscall_syscall6(SB),NOSPLIT,$0-80
- BL runtime·entersyscall(SB)
- MOVD a1+8(FP), R1
- MOVD a2+16(FP), R2
- MOVD a3+24(FP), R3
-
- // Get library control area (LCA).
- MOVW PSALAA, R8
- MOVD LCA64(R8), R8
-
- // Get function.
- MOVD CAA(R8), R9
- MOVD EDCHPXV(R9), R9
- MOVD trap+0(FP), R5
- SLD $4, R5
- ADD R5, R9
- LMG 0(R9), R5, R6
-
- // Restore LE stack.
- MOVD SAVSTACK_ASYNC(R8), R9
- MOVD 0(R9), R4
- MOVD $0, 0(R9)
-
- // Fill in parameter list.
- MOVD a4+32(FP), R12
- MOVD R12, (2176+24)(R4)
- MOVD a5+40(FP), R12
- MOVD R12, (2176+32)(R4)
- MOVD a6+48(FP), R12
- MOVD R12, (2176+40)(R4)
-
- // Call function.
- LE_CALL
- NOPH
- XOR R0, R0 // Restore R0 to $0.
- MOVD R4, 0(R9) // Save stack pointer.
-
- MOVD R3, r1+56(FP)
- MOVD R0, r2+64(FP)
- MOVD R0, err+72(FP)
- MOVW R3, R4
- CMP R4, $-1
- BNE done
- BL addrerrno<>(SB)
- MOVWZ 0(R3), R3
- MOVD R3, err+72(FP)
-done:
- BL runtime·exitsyscall(SB)
- RET
-
-TEXT ·syscall_rawsyscall6(SB),NOSPLIT,$0-80
- MOVD a1+8(FP), R1
- MOVD a2+16(FP), R2
- MOVD a3+24(FP), R3
-
- // Get library control area (LCA).
- MOVW PSALAA, R8
- MOVD LCA64(R8), R8
-
- // Get function.
- MOVD CAA(R8), R9
- MOVD EDCHPXV(R9), R9
- MOVD trap+0(FP), R5
- SLD $4, R5
- ADD R5, R9
- LMG 0(R9), R5, R6
-
- // Restore LE stack.
- MOVD SAVSTACK_ASYNC(R8), R9
- MOVD 0(R9), R4
- MOVD $0, 0(R9)
-
- // Fill in parameter list.
- MOVD a4+32(FP), R12
- MOVD R12, (2176+24)(R4)
- MOVD a5+40(FP), R12
- MOVD R12, (2176+32)(R4)
- MOVD a6+48(FP), R12
- MOVD R12, (2176+40)(R4)
-
- // Call function.
- LE_CALL
- NOPH
- XOR R0, R0 // Restore R0 to $0.
- MOVD R4, 0(R9) // Save stack pointer.
-
- MOVD R3, r1+56(FP)
- MOVD R0, r2+64(FP)
- MOVD R0, err+72(FP)
- MOVW R3, R4
- CMP R4, $-1
- BNE done
- BL ·rrno<>(SB)
- MOVWZ 0(R3), R3
- MOVD R3, err+72(FP)
-done:
- RET
-
-TEXT ·syscall_syscall9(SB),NOSPLIT,$0
- BL runtime·entersyscall(SB)
- MOVD a1+8(FP), R1
- MOVD a2+16(FP), R2
- MOVD a3+24(FP), R3
-
- // Get library control area (LCA).
- MOVW PSALAA, R8
- MOVD LCA64(R8), R8
-
- // Get function.
- MOVD CAA(R8), R9
- MOVD EDCHPXV(R9), R9
- MOVD trap+0(FP), R5
- SLD $4, R5
- ADD R5, R9
- LMG 0(R9), R5, R6
-
- // Restore LE stack.
- MOVD SAVSTACK_ASYNC(R8), R9
- MOVD 0(R9), R4
- MOVD $0, 0(R9)
-
- // Fill in parameter list.
- MOVD a4+32(FP), R12
- MOVD R12, (2176+24)(R4)
- MOVD a5+40(FP), R12
- MOVD R12, (2176+32)(R4)
- MOVD a6+48(FP), R12
- MOVD R12, (2176+40)(R4)
- MOVD a7+56(FP), R12
- MOVD R12, (2176+48)(R4)
- MOVD a8+64(FP), R12
- MOVD R12, (2176+56)(R4)
- MOVD a9+72(FP), R12
- MOVD R12, (2176+64)(R4)
-
- // Call function.
- LE_CALL
- NOPH
- XOR R0, R0 // Restore R0 to $0.
- MOVD R4, 0(R9) // Save stack pointer.
-
- MOVD R3, r1+80(FP)
- MOVD R0, r2+88(FP)
- MOVD R0, err+96(FP)
- MOVW R3, R4
- CMP R4, $-1
- BNE done
- BL addrerrno<>(SB)
- MOVWZ 0(R3), R3
- MOVD R3, err+96(FP)
-done:
- BL runtime·exitsyscall(SB)
- RET
-
-TEXT ·syscall_rawsyscall9(SB),NOSPLIT,$0
- MOVD a1+8(FP), R1
- MOVD a2+16(FP), R2
- MOVD a3+24(FP), R3
-
- // Get library control area (LCA).
- MOVW PSALAA, R8
- MOVD LCA64(R8), R8
-
- // Get function.
- MOVD CAA(R8), R9
- MOVD EDCHPXV(R9), R9
- MOVD trap+0(FP), R5
- SLD $4, R5
- ADD R5, R9
- LMG 0(R9), R5, R6
-
- // Restore LE stack.
- MOVD SAVSTACK_ASYNC(R8), R9
- MOVD 0(R9), R4
- MOVD $0, 0(R9)
-
- // Fill in parameter list.
- MOVD a4+32(FP), R12
- MOVD R12, (2176+24)(R4)
- MOVD a5+40(FP), R12
- MOVD R12, (2176+32)(R4)
- MOVD a6+48(FP), R12
- MOVD R12, (2176+40)(R4)
- MOVD a7+56(FP), R12
- MOVD R12, (2176+48)(R4)
- MOVD a8+64(FP), R12
- MOVD R12, (2176+56)(R4)
- MOVD a9+72(FP), R12
- MOVD R12, (2176+64)(R4)
-
- // Call function.
- LE_CALL
- NOPH
- XOR R0, R0 // Restore R0 to $0.
- MOVD R4, 0(R9) // Save stack pointer.
-
- MOVD R3, r1+80(FP)
- MOVD R0, r2+88(FP)
- MOVD R0, err+96(FP)
- MOVW R3, R4
- CMP R4, $-1
- BNE done
- BL addrerrno<>(SB)
- MOVWZ 0(R3), R3
- MOVD R3, err+96(FP)
-done:
- RET
-
-// func svcCall(fnptr unsafe.Pointer, argv *unsafe.Pointer, dsa *uint64)
-TEXT ·svcCall(SB),NOSPLIT,$0
- BL runtime·save_g(SB) // Save g and stack pointer
- MOVW PSALAA, R8
- MOVD LCA64(R8), R8
- MOVD SAVSTACK_ASYNC(R8), R9
- MOVD R15, 0(R9)
-
- MOVD argv+8(FP), R1 // Move function arguments into registers
- MOVD dsa+16(FP), g
- MOVD fnptr+0(FP), R15
-
- BYTE $0x0D // Branch to function
- BYTE $0xEF
-
- BL runtime·load_g(SB) // Restore g and stack pointer
- MOVW PSALAA, R8
- MOVD LCA64(R8), R8
- MOVD SAVSTACK_ASYNC(R8), R9
- MOVD 0(R9), R15
-
- RET
-
-// func svcLoad(name *byte) unsafe.Pointer
-TEXT ·svcLoad(SB),NOSPLIT,$0
- MOVD R15, R2 // Save go stack pointer
- MOVD name+0(FP), R0 // Move SVC args into registers
- MOVD $0x80000000, R1
- MOVD $0, R15
- BYTE $0x0A // SVC 08 LOAD
- BYTE $0x08
- MOVW R15, R3 // Save return code from SVC
- MOVD R2, R15 // Restore go stack pointer
- CMP R3, $0 // Check SVC return code
- BNE error
-
- MOVD $-2, R3 // Reset last bit of entry point to zero
- AND R0, R3
- MOVD R3, addr+8(FP) // Return entry point returned by SVC
- CMP R0, R3 // Check if last bit of entry point was set
- BNE done
-
- MOVD R15, R2 // Save go stack pointer
- MOVD $0, R15 // Move SVC args into registers (entry point still in r0 from SVC 08)
- BYTE $0x0A // SVC 09 DELETE
- BYTE $0x09
- MOVD R2, R15 // Restore go stack pointer
-
-error:
- MOVD $0, addr+8(FP) // Return 0 on failure
-done:
- XOR R0, R0 // Reset r0 to 0
- RET
-
-// func svcUnload(name *byte, fnptr unsafe.Pointer) int64
-TEXT ·svcUnload(SB),NOSPLIT,$0
- MOVD R15, R2 // Save go stack pointer
- MOVD name+0(FP), R0 // Move SVC args into registers
- MOVD addr+8(FP), R15
- BYTE $0x0A // SVC 09
- BYTE $0x09
- XOR R0, R0 // Reset r0 to 0
- MOVD R15, R1 // Save SVC return code
- MOVD R2, R15 // Restore go stack pointer
- MOVD R1, rc+0(FP) // Return SVC return code
- RET
-
-// func gettid() uint64
-TEXT ·gettid(SB), NOSPLIT, $0
- // Get library control area (LCA).
- MOVW PSALAA, R8
- MOVD LCA64(R8), R8
-
- // Get CEECAATHDID
- MOVD CAA(R8), R9
- MOVD 0x3D0(R9), R9
- MOVD R9, ret+0(FP)
-
- RET
diff --git a/vendor/golang.org/x/sys/unix/bluetooth_linux.go b/vendor/golang.org/x/sys/unix/bluetooth_linux.go
deleted file mode 100644
index a178a61..0000000
--- a/vendor/golang.org/x/sys/unix/bluetooth_linux.go
+++ /dev/null
@@ -1,36 +0,0 @@
-// Copyright 2016 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-// Bluetooth sockets and messages
-
-package unix
-
-// Bluetooth Protocols
-const (
- BTPROTO_L2CAP = 0
- BTPROTO_HCI = 1
- BTPROTO_SCO = 2
- BTPROTO_RFCOMM = 3
- BTPROTO_BNEP = 4
- BTPROTO_CMTP = 5
- BTPROTO_HIDP = 6
- BTPROTO_AVDTP = 7
-)
-
-const (
- HCI_CHANNEL_RAW = 0
- HCI_CHANNEL_USER = 1
- HCI_CHANNEL_MONITOR = 2
- HCI_CHANNEL_CONTROL = 3
- HCI_CHANNEL_LOGGING = 4
-)
-
-// Socketoption Level
-const (
- SOL_BLUETOOTH = 0x112
- SOL_HCI = 0x0
- SOL_L2CAP = 0x6
- SOL_RFCOMM = 0x12
- SOL_SCO = 0x11
-)
diff --git a/vendor/golang.org/x/sys/unix/cap_freebsd.go b/vendor/golang.org/x/sys/unix/cap_freebsd.go
deleted file mode 100644
index a086578..0000000
--- a/vendor/golang.org/x/sys/unix/cap_freebsd.go
+++ /dev/null
@@ -1,195 +0,0 @@
-// Copyright 2017 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-//go:build freebsd
-
-package unix
-
-import (
- "errors"
- "fmt"
-)
-
-// Go implementation of C mostly found in /usr/src/sys/kern/subr_capability.c
-
-const (
- // This is the version of CapRights this package understands. See C implementation for parallels.
- capRightsGoVersion = CAP_RIGHTS_VERSION_00
- capArSizeMin = CAP_RIGHTS_VERSION_00 + 2
- capArSizeMax = capRightsGoVersion + 2
-)
-
-var (
- bit2idx = []int{
- -1, 0, 1, -1, 2, -1, -1, -1, 3, -1, -1, -1, -1, -1, -1, -1,
- 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- }
-)
-
-func capidxbit(right uint64) int {
- return int((right >> 57) & 0x1f)
-}
-
-func rightToIndex(right uint64) (int, error) {
- idx := capidxbit(right)
- if idx < 0 || idx >= len(bit2idx) {
- return -2, fmt.Errorf("index for right 0x%x out of range", right)
- }
- return bit2idx[idx], nil
-}
-
-func caprver(right uint64) int {
- return int(right >> 62)
-}
-
-func capver(rights *CapRights) int {
- return caprver(rights.Rights[0])
-}
-
-func caparsize(rights *CapRights) int {
- return capver(rights) + 2
-}
-
-// CapRightsSet sets the permissions in setrights in rights.
-func CapRightsSet(rights *CapRights, setrights []uint64) error {
- // This is essentially a copy of cap_rights_vset()
- if capver(rights) != CAP_RIGHTS_VERSION_00 {
- return fmt.Errorf("bad rights version %d", capver(rights))
- }
-
- n := caparsize(rights)
- if n < capArSizeMin || n > capArSizeMax {
- return errors.New("bad rights size")
- }
-
- for _, right := range setrights {
- if caprver(right) != CAP_RIGHTS_VERSION_00 {
- return errors.New("bad right version")
- }
- i, err := rightToIndex(right)
- if err != nil {
- return err
- }
- if i >= n {
- return errors.New("index overflow")
- }
- if capidxbit(rights.Rights[i]) != capidxbit(right) {
- return errors.New("index mismatch")
- }
- rights.Rights[i] |= right
- if capidxbit(rights.Rights[i]) != capidxbit(right) {
- return errors.New("index mismatch (after assign)")
- }
- }
-
- return nil
-}
-
-// CapRightsClear clears the permissions in clearrights from rights.
-func CapRightsClear(rights *CapRights, clearrights []uint64) error {
- // This is essentially a copy of cap_rights_vclear()
- if capver(rights) != CAP_RIGHTS_VERSION_00 {
- return fmt.Errorf("bad rights version %d", capver(rights))
- }
-
- n := caparsize(rights)
- if n < capArSizeMin || n > capArSizeMax {
- return errors.New("bad rights size")
- }
-
- for _, right := range clearrights {
- if caprver(right) != CAP_RIGHTS_VERSION_00 {
- return errors.New("bad right version")
- }
- i, err := rightToIndex(right)
- if err != nil {
- return err
- }
- if i >= n {
- return errors.New("index overflow")
- }
- if capidxbit(rights.Rights[i]) != capidxbit(right) {
- return errors.New("index mismatch")
- }
- rights.Rights[i] &= ^(right & 0x01FFFFFFFFFFFFFF)
- if capidxbit(rights.Rights[i]) != capidxbit(right) {
- return errors.New("index mismatch (after assign)")
- }
- }
-
- return nil
-}
-
-// CapRightsIsSet checks whether all the permissions in setrights are present in rights.
-func CapRightsIsSet(rights *CapRights, setrights []uint64) (bool, error) {
- // This is essentially a copy of cap_rights_is_vset()
- if capver(rights) != CAP_RIGHTS_VERSION_00 {
- return false, fmt.Errorf("bad rights version %d", capver(rights))
- }
-
- n := caparsize(rights)
- if n < capArSizeMin || n > capArSizeMax {
- return false, errors.New("bad rights size")
- }
-
- for _, right := range setrights {
- if caprver(right) != CAP_RIGHTS_VERSION_00 {
- return false, errors.New("bad right version")
- }
- i, err := rightToIndex(right)
- if err != nil {
- return false, err
- }
- if i >= n {
- return false, errors.New("index overflow")
- }
- if capidxbit(rights.Rights[i]) != capidxbit(right) {
- return false, errors.New("index mismatch")
- }
- if (rights.Rights[i] & right) != right {
- return false, nil
- }
- }
-
- return true, nil
-}
-
-func capright(idx uint64, bit uint64) uint64 {
- return ((1 << (57 + idx)) | bit)
-}
-
-// CapRightsInit returns a pointer to an initialised CapRights structure filled with rights.
-// See man cap_rights_init(3) and rights(4).
-func CapRightsInit(rights []uint64) (*CapRights, error) {
- var r CapRights
- r.Rights[0] = (capRightsGoVersion << 62) | capright(0, 0)
- r.Rights[1] = capright(1, 0)
-
- err := CapRightsSet(&r, rights)
- if err != nil {
- return nil, err
- }
- return &r, nil
-}
-
-// CapRightsLimit reduces the operations permitted on fd to at most those contained in rights.
-// The capability rights on fd can never be increased by CapRightsLimit.
-// See man cap_rights_limit(2) and rights(4).
-func CapRightsLimit(fd uintptr, rights *CapRights) error {
- return capRightsLimit(int(fd), rights)
-}
-
-// CapRightsGet returns a CapRights structure containing the operations permitted on fd.
-// See man cap_rights_get(3) and rights(4).
-func CapRightsGet(fd uintptr) (*CapRights, error) {
- r, err := CapRightsInit(nil)
- if err != nil {
- return nil, err
- }
- err = capRightsGet(capRightsGoVersion, int(fd), r)
- if err != nil {
- return nil, err
- }
- return r, nil
-}
diff --git a/vendor/golang.org/x/sys/unix/constants.go b/vendor/golang.org/x/sys/unix/constants.go
deleted file mode 100644
index 6fb7cb7..0000000
--- a/vendor/golang.org/x/sys/unix/constants.go
+++ /dev/null
@@ -1,13 +0,0 @@
-// Copyright 2015 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-//go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris || zos
-
-package unix
-
-const (
- R_OK = 0x4
- W_OK = 0x2
- X_OK = 0x1
-)
diff --git a/vendor/golang.org/x/sys/unix/dev_aix_ppc.go b/vendor/golang.org/x/sys/unix/dev_aix_ppc.go
deleted file mode 100644
index d785134..0000000
--- a/vendor/golang.org/x/sys/unix/dev_aix_ppc.go
+++ /dev/null
@@ -1,26 +0,0 @@
-// Copyright 2018 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-//go:build aix && ppc
-
-// Functions to access/create device major and minor numbers matching the
-// encoding used by AIX.
-
-package unix
-
-// Major returns the major component of a Linux device number.
-func Major(dev uint64) uint32 {
- return uint32((dev >> 16) & 0xffff)
-}
-
-// Minor returns the minor component of a Linux device number.
-func Minor(dev uint64) uint32 {
- return uint32(dev & 0xffff)
-}
-
-// Mkdev returns a Linux device number generated from the given major and minor
-// components.
-func Mkdev(major, minor uint32) uint64 {
- return uint64(((major) << 16) | (minor))
-}
diff --git a/vendor/golang.org/x/sys/unix/dev_aix_ppc64.go b/vendor/golang.org/x/sys/unix/dev_aix_ppc64.go
deleted file mode 100644
index 623a5e6..0000000
--- a/vendor/golang.org/x/sys/unix/dev_aix_ppc64.go
+++ /dev/null
@@ -1,28 +0,0 @@
-// Copyright 2018 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-//go:build aix && ppc64
-
-// Functions to access/create device major and minor numbers matching the
-// encoding used AIX.
-
-package unix
-
-// Major returns the major component of a Linux device number.
-func Major(dev uint64) uint32 {
- return uint32((dev & 0x3fffffff00000000) >> 32)
-}
-
-// Minor returns the minor component of a Linux device number.
-func Minor(dev uint64) uint32 {
- return uint32((dev & 0x00000000ffffffff) >> 0)
-}
-
-// Mkdev returns a Linux device number generated from the given major and minor
-// components.
-func Mkdev(major, minor uint32) uint64 {
- var DEVNO64 uint64
- DEVNO64 = 0x8000000000000000
- return ((uint64(major) << 32) | (uint64(minor) & 0x00000000FFFFFFFF) | DEVNO64)
-}
diff --git a/vendor/golang.org/x/sys/unix/dev_darwin.go b/vendor/golang.org/x/sys/unix/dev_darwin.go
deleted file mode 100644
index 8d1dc0f..0000000
--- a/vendor/golang.org/x/sys/unix/dev_darwin.go
+++ /dev/null
@@ -1,24 +0,0 @@
-// Copyright 2017 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-// Functions to access/create device major and minor numbers matching the
-// encoding used in Darwin's sys/types.h header.
-
-package unix
-
-// Major returns the major component of a Darwin device number.
-func Major(dev uint64) uint32 {
- return uint32((dev >> 24) & 0xff)
-}
-
-// Minor returns the minor component of a Darwin device number.
-func Minor(dev uint64) uint32 {
- return uint32(dev & 0xffffff)
-}
-
-// Mkdev returns a Darwin device number generated from the given major and minor
-// components.
-func Mkdev(major, minor uint32) uint64 {
- return (uint64(major) << 24) | uint64(minor)
-}
diff --git a/vendor/golang.org/x/sys/unix/dev_dragonfly.go b/vendor/golang.org/x/sys/unix/dev_dragonfly.go
deleted file mode 100644
index 8502f20..0000000
--- a/vendor/golang.org/x/sys/unix/dev_dragonfly.go
+++ /dev/null
@@ -1,30 +0,0 @@
-// Copyright 2017 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-// Functions to access/create device major and minor numbers matching the
-// encoding used in Dragonfly's sys/types.h header.
-//
-// The information below is extracted and adapted from sys/types.h:
-//
-// Minor gives a cookie instead of an index since in order to avoid changing the
-// meanings of bits 0-15 or wasting time and space shifting bits 16-31 for
-// devices that don't use them.
-
-package unix
-
-// Major returns the major component of a DragonFlyBSD device number.
-func Major(dev uint64) uint32 {
- return uint32((dev >> 8) & 0xff)
-}
-
-// Minor returns the minor component of a DragonFlyBSD device number.
-func Minor(dev uint64) uint32 {
- return uint32(dev & 0xffff00ff)
-}
-
-// Mkdev returns a DragonFlyBSD device number generated from the given major and
-// minor components.
-func Mkdev(major, minor uint32) uint64 {
- return (uint64(major) << 8) | uint64(minor)
-}
diff --git a/vendor/golang.org/x/sys/unix/dev_freebsd.go b/vendor/golang.org/x/sys/unix/dev_freebsd.go
deleted file mode 100644
index eba3b4b..0000000
--- a/vendor/golang.org/x/sys/unix/dev_freebsd.go
+++ /dev/null
@@ -1,30 +0,0 @@
-// Copyright 2017 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-// Functions to access/create device major and minor numbers matching the
-// encoding used in FreeBSD's sys/types.h header.
-//
-// The information below is extracted and adapted from sys/types.h:
-//
-// Minor gives a cookie instead of an index since in order to avoid changing the
-// meanings of bits 0-15 or wasting time and space shifting bits 16-31 for
-// devices that don't use them.
-
-package unix
-
-// Major returns the major component of a FreeBSD device number.
-func Major(dev uint64) uint32 {
- return uint32((dev >> 8) & 0xff)
-}
-
-// Minor returns the minor component of a FreeBSD device number.
-func Minor(dev uint64) uint32 {
- return uint32(dev & 0xffff00ff)
-}
-
-// Mkdev returns a FreeBSD device number generated from the given major and
-// minor components.
-func Mkdev(major, minor uint32) uint64 {
- return (uint64(major) << 8) | uint64(minor)
-}
diff --git a/vendor/golang.org/x/sys/unix/dev_linux.go b/vendor/golang.org/x/sys/unix/dev_linux.go
deleted file mode 100644
index d165d6f..0000000
--- a/vendor/golang.org/x/sys/unix/dev_linux.go
+++ /dev/null
@@ -1,42 +0,0 @@
-// Copyright 2017 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-// Functions to access/create device major and minor numbers matching the
-// encoding used by the Linux kernel and glibc.
-//
-// The information below is extracted and adapted from bits/sysmacros.h in the
-// glibc sources:
-//
-// dev_t in glibc is 64-bit, with 32-bit major and minor numbers. glibc's
-// default encoding is MMMM Mmmm mmmM MMmm, where M is a hex digit of the major
-// number and m is a hex digit of the minor number. This is backward compatible
-// with legacy systems where dev_t is 16 bits wide, encoded as MMmm. It is also
-// backward compatible with the Linux kernel, which for some architectures uses
-// 32-bit dev_t, encoded as mmmM MMmm.
-
-package unix
-
-// Major returns the major component of a Linux device number.
-func Major(dev uint64) uint32 {
- major := uint32((dev & 0x00000000000fff00) >> 8)
- major |= uint32((dev & 0xfffff00000000000) >> 32)
- return major
-}
-
-// Minor returns the minor component of a Linux device number.
-func Minor(dev uint64) uint32 {
- minor := uint32((dev & 0x00000000000000ff) >> 0)
- minor |= uint32((dev & 0x00000ffffff00000) >> 12)
- return minor
-}
-
-// Mkdev returns a Linux device number generated from the given major and minor
-// components.
-func Mkdev(major, minor uint32) uint64 {
- dev := (uint64(major) & 0x00000fff) << 8
- dev |= (uint64(major) & 0xfffff000) << 32
- dev |= (uint64(minor) & 0x000000ff) << 0
- dev |= (uint64(minor) & 0xffffff00) << 12
- return dev
-}
diff --git a/vendor/golang.org/x/sys/unix/dev_netbsd.go b/vendor/golang.org/x/sys/unix/dev_netbsd.go
deleted file mode 100644
index b4a203d..0000000
--- a/vendor/golang.org/x/sys/unix/dev_netbsd.go
+++ /dev/null
@@ -1,29 +0,0 @@
-// Copyright 2017 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-// Functions to access/create device major and minor numbers matching the
-// encoding used in NetBSD's sys/types.h header.
-
-package unix
-
-// Major returns the major component of a NetBSD device number.
-func Major(dev uint64) uint32 {
- return uint32((dev & 0x000fff00) >> 8)
-}
-
-// Minor returns the minor component of a NetBSD device number.
-func Minor(dev uint64) uint32 {
- minor := uint32((dev & 0x000000ff) >> 0)
- minor |= uint32((dev & 0xfff00000) >> 12)
- return minor
-}
-
-// Mkdev returns a NetBSD device number generated from the given major and minor
-// components.
-func Mkdev(major, minor uint32) uint64 {
- dev := (uint64(major) << 8) & 0x000fff00
- dev |= (uint64(minor) << 12) & 0xfff00000
- dev |= (uint64(minor) << 0) & 0x000000ff
- return dev
-}
diff --git a/vendor/golang.org/x/sys/unix/dev_openbsd.go b/vendor/golang.org/x/sys/unix/dev_openbsd.go
deleted file mode 100644
index f3430c4..0000000
--- a/vendor/golang.org/x/sys/unix/dev_openbsd.go
+++ /dev/null
@@ -1,29 +0,0 @@
-// Copyright 2017 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-// Functions to access/create device major and minor numbers matching the
-// encoding used in OpenBSD's sys/types.h header.
-
-package unix
-
-// Major returns the major component of an OpenBSD device number.
-func Major(dev uint64) uint32 {
- return uint32((dev & 0x0000ff00) >> 8)
-}
-
-// Minor returns the minor component of an OpenBSD device number.
-func Minor(dev uint64) uint32 {
- minor := uint32((dev & 0x000000ff) >> 0)
- minor |= uint32((dev & 0xffff0000) >> 8)
- return minor
-}
-
-// Mkdev returns an OpenBSD device number generated from the given major and minor
-// components.
-func Mkdev(major, minor uint32) uint64 {
- dev := (uint64(major) << 8) & 0x0000ff00
- dev |= (uint64(minor) << 8) & 0xffff0000
- dev |= (uint64(minor) << 0) & 0x000000ff
- return dev
-}
diff --git a/vendor/golang.org/x/sys/unix/dev_zos.go b/vendor/golang.org/x/sys/unix/dev_zos.go
deleted file mode 100644
index bb6a64f..0000000
--- a/vendor/golang.org/x/sys/unix/dev_zos.go
+++ /dev/null
@@ -1,28 +0,0 @@
-// Copyright 2020 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-//go:build zos && s390x
-
-// Functions to access/create device major and minor numbers matching the
-// encoding used by z/OS.
-//
-// The information below is extracted and adapted from macros.
-
-package unix
-
-// Major returns the major component of a z/OS device number.
-func Major(dev uint64) uint32 {
- return uint32((dev >> 16) & 0x0000FFFF)
-}
-
-// Minor returns the minor component of a z/OS device number.
-func Minor(dev uint64) uint32 {
- return uint32(dev & 0x0000FFFF)
-}
-
-// Mkdev returns a z/OS device number generated from the given major and minor
-// components.
-func Mkdev(major, minor uint32) uint64 {
- return (uint64(major) << 16) | uint64(minor)
-}
diff --git a/vendor/golang.org/x/sys/unix/dirent.go b/vendor/golang.org/x/sys/unix/dirent.go
deleted file mode 100644
index 1ebf117..0000000
--- a/vendor/golang.org/x/sys/unix/dirent.go
+++ /dev/null
@@ -1,102 +0,0 @@
-// Copyright 2009 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-//go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris || zos
-
-package unix
-
-import "unsafe"
-
-// readInt returns the size-bytes unsigned integer in native byte order at offset off.
-func readInt(b []byte, off, size uintptr) (u uint64, ok bool) {
- if len(b) < int(off+size) {
- return 0, false
- }
- if isBigEndian {
- return readIntBE(b[off:], size), true
- }
- return readIntLE(b[off:], size), true
-}
-
-func readIntBE(b []byte, size uintptr) uint64 {
- switch size {
- case 1:
- return uint64(b[0])
- case 2:
- _ = b[1] // bounds check hint to compiler; see golang.org/issue/14808
- return uint64(b[1]) | uint64(b[0])<<8
- case 4:
- _ = b[3] // bounds check hint to compiler; see golang.org/issue/14808
- return uint64(b[3]) | uint64(b[2])<<8 | uint64(b[1])<<16 | uint64(b[0])<<24
- case 8:
- _ = b[7] // bounds check hint to compiler; see golang.org/issue/14808
- return uint64(b[7]) | uint64(b[6])<<8 | uint64(b[5])<<16 | uint64(b[4])<<24 |
- uint64(b[3])<<32 | uint64(b[2])<<40 | uint64(b[1])<<48 | uint64(b[0])<<56
- default:
- panic("syscall: readInt with unsupported size")
- }
-}
-
-func readIntLE(b []byte, size uintptr) uint64 {
- switch size {
- case 1:
- return uint64(b[0])
- case 2:
- _ = b[1] // bounds check hint to compiler; see golang.org/issue/14808
- return uint64(b[0]) | uint64(b[1])<<8
- case 4:
- _ = b[3] // bounds check hint to compiler; see golang.org/issue/14808
- return uint64(b[0]) | uint64(b[1])<<8 | uint64(b[2])<<16 | uint64(b[3])<<24
- case 8:
- _ = b[7] // bounds check hint to compiler; see golang.org/issue/14808
- return uint64(b[0]) | uint64(b[1])<<8 | uint64(b[2])<<16 | uint64(b[3])<<24 |
- uint64(b[4])<<32 | uint64(b[5])<<40 | uint64(b[6])<<48 | uint64(b[7])<<56
- default:
- panic("syscall: readInt with unsupported size")
- }
-}
-
-// ParseDirent parses up to max directory entries in buf,
-// appending the names to names. It returns the number of
-// bytes consumed from buf, the number of entries added
-// to names, and the new names slice.
-func ParseDirent(buf []byte, max int, names []string) (consumed int, count int, newnames []string) {
- origlen := len(buf)
- count = 0
- for max != 0 && len(buf) > 0 {
- reclen, ok := direntReclen(buf)
- if !ok || reclen > uint64(len(buf)) {
- return origlen, count, names
- }
- rec := buf[:reclen]
- buf = buf[reclen:]
- ino, ok := direntIno(rec)
- if !ok {
- break
- }
- if ino == 0 { // File absent in directory.
- continue
- }
- const namoff = uint64(unsafe.Offsetof(Dirent{}.Name))
- namlen, ok := direntNamlen(rec)
- if !ok || namoff+namlen > uint64(len(rec)) {
- break
- }
- name := rec[namoff : namoff+namlen]
- for i, c := range name {
- if c == 0 {
- name = name[:i]
- break
- }
- }
- // Check for useless names before allocating a string.
- if string(name) == "." || string(name) == ".." {
- continue
- }
- max--
- count++
- names = append(names, string(name))
- }
- return origlen - len(buf), count, names
-}
diff --git a/vendor/golang.org/x/sys/unix/endian_big.go b/vendor/golang.org/x/sys/unix/endian_big.go
deleted file mode 100644
index 1095fd3..0000000
--- a/vendor/golang.org/x/sys/unix/endian_big.go
+++ /dev/null
@@ -1,9 +0,0 @@
-// Copyright 2016 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-//
-//go:build armbe || arm64be || m68k || mips || mips64 || mips64p32 || ppc || ppc64 || s390 || s390x || shbe || sparc || sparc64
-
-package unix
-
-const isBigEndian = true
diff --git a/vendor/golang.org/x/sys/unix/endian_little.go b/vendor/golang.org/x/sys/unix/endian_little.go
deleted file mode 100644
index b9f0e27..0000000
--- a/vendor/golang.org/x/sys/unix/endian_little.go
+++ /dev/null
@@ -1,9 +0,0 @@
-// Copyright 2016 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-//
-//go:build 386 || amd64 || amd64p32 || alpha || arm || arm64 || loong64 || mipsle || mips64le || mips64p32le || nios2 || ppc64le || riscv || riscv64 || sh
-
-package unix
-
-const isBigEndian = false
diff --git a/vendor/golang.org/x/sys/unix/env_unix.go b/vendor/golang.org/x/sys/unix/env_unix.go
deleted file mode 100644
index a96da71..0000000
--- a/vendor/golang.org/x/sys/unix/env_unix.go
+++ /dev/null
@@ -1,31 +0,0 @@
-// Copyright 2010 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-//go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris || zos
-
-// Unix environment variables.
-
-package unix
-
-import "syscall"
-
-func Getenv(key string) (value string, found bool) {
- return syscall.Getenv(key)
-}
-
-func Setenv(key, value string) error {
- return syscall.Setenv(key, value)
-}
-
-func Clearenv() {
- syscall.Clearenv()
-}
-
-func Environ() []string {
- return syscall.Environ()
-}
-
-func Unsetenv(key string) error {
- return syscall.Unsetenv(key)
-}
diff --git a/vendor/golang.org/x/sys/unix/epoll_zos.go b/vendor/golang.org/x/sys/unix/epoll_zos.go
deleted file mode 100644
index 7753fdd..0000000
--- a/vendor/golang.org/x/sys/unix/epoll_zos.go
+++ /dev/null
@@ -1,220 +0,0 @@
-// Copyright 2020 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-//go:build zos && s390x
-
-package unix
-
-import (
- "sync"
-)
-
-// This file simulates epoll on z/OS using poll.
-
-// Analogous to epoll_event on Linux.
-// TODO(neeilan): Pad is because the Linux kernel expects a 96-bit struct. We never pass this to the kernel; remove?
-type EpollEvent struct {
- Events uint32
- Fd int32
- Pad int32
-}
-
-const (
- EPOLLERR = 0x8
- EPOLLHUP = 0x10
- EPOLLIN = 0x1
- EPOLLMSG = 0x400
- EPOLLOUT = 0x4
- EPOLLPRI = 0x2
- EPOLLRDBAND = 0x80
- EPOLLRDNORM = 0x40
- EPOLLWRBAND = 0x200
- EPOLLWRNORM = 0x100
- EPOLL_CTL_ADD = 0x1
- EPOLL_CTL_DEL = 0x2
- EPOLL_CTL_MOD = 0x3
- // The following constants are part of the epoll API, but represent
- // currently unsupported functionality on z/OS.
- // EPOLL_CLOEXEC = 0x80000
- // EPOLLET = 0x80000000
- // EPOLLONESHOT = 0x40000000
- // EPOLLRDHUP = 0x2000 // Typically used with edge-triggered notis
- // EPOLLEXCLUSIVE = 0x10000000 // Exclusive wake-up mode
- // EPOLLWAKEUP = 0x20000000 // Relies on Linux's BLOCK_SUSPEND capability
-)
-
-// TODO(neeilan): We can eliminate these epToPoll / pToEpoll calls by using identical mask values for POLL/EPOLL
-// constants where possible The lower 16 bits of epoll events (uint32) can fit any system poll event (int16).
-
-// epToPollEvt converts epoll event field to poll equivalent.
-// In epoll, Events is a 32-bit field, while poll uses 16 bits.
-func epToPollEvt(events uint32) int16 {
- var ep2p = map[uint32]int16{
- EPOLLIN: POLLIN,
- EPOLLOUT: POLLOUT,
- EPOLLHUP: POLLHUP,
- EPOLLPRI: POLLPRI,
- EPOLLERR: POLLERR,
- }
-
- var pollEvts int16 = 0
- for epEvt, pEvt := range ep2p {
- if (events & epEvt) != 0 {
- pollEvts |= pEvt
- }
- }
-
- return pollEvts
-}
-
-// pToEpollEvt converts 16 bit poll event bitfields to 32-bit epoll event fields.
-func pToEpollEvt(revents int16) uint32 {
- var p2ep = map[int16]uint32{
- POLLIN: EPOLLIN,
- POLLOUT: EPOLLOUT,
- POLLHUP: EPOLLHUP,
- POLLPRI: EPOLLPRI,
- POLLERR: EPOLLERR,
- }
-
- var epollEvts uint32 = 0
- for pEvt, epEvt := range p2ep {
- if (revents & pEvt) != 0 {
- epollEvts |= epEvt
- }
- }
-
- return epollEvts
-}
-
-// Per-process epoll implementation.
-type epollImpl struct {
- mu sync.Mutex
- epfd2ep map[int]*eventPoll
- nextEpfd int
-}
-
-// eventPoll holds a set of file descriptors being watched by the process. A process can have multiple epoll instances.
-// On Linux, this is an in-kernel data structure accessed through a fd.
-type eventPoll struct {
- mu sync.Mutex
- fds map[int]*EpollEvent
-}
-
-// epoll impl for this process.
-var impl epollImpl = epollImpl{
- epfd2ep: make(map[int]*eventPoll),
- nextEpfd: 0,
-}
-
-func (e *epollImpl) epollcreate(size int) (epfd int, err error) {
- e.mu.Lock()
- defer e.mu.Unlock()
- epfd = e.nextEpfd
- e.nextEpfd++
-
- e.epfd2ep[epfd] = &eventPoll{
- fds: make(map[int]*EpollEvent),
- }
- return epfd, nil
-}
-
-func (e *epollImpl) epollcreate1(flag int) (fd int, err error) {
- return e.epollcreate(4)
-}
-
-func (e *epollImpl) epollctl(epfd int, op int, fd int, event *EpollEvent) (err error) {
- e.mu.Lock()
- defer e.mu.Unlock()
-
- ep, ok := e.epfd2ep[epfd]
- if !ok {
-
- return EBADF
- }
-
- switch op {
- case EPOLL_CTL_ADD:
- // TODO(neeilan): When we make epfds and fds disjoint, detect epoll
- // loops here (instances watching each other) and return ELOOP.
- if _, ok := ep.fds[fd]; ok {
- return EEXIST
- }
- ep.fds[fd] = event
- case EPOLL_CTL_MOD:
- if _, ok := ep.fds[fd]; !ok {
- return ENOENT
- }
- ep.fds[fd] = event
- case EPOLL_CTL_DEL:
- if _, ok := ep.fds[fd]; !ok {
- return ENOENT
- }
- delete(ep.fds, fd)
-
- }
- return nil
-}
-
-// Must be called while holding ep.mu
-func (ep *eventPoll) getFds() []int {
- fds := make([]int, len(ep.fds))
- for fd := range ep.fds {
- fds = append(fds, fd)
- }
- return fds
-}
-
-func (e *epollImpl) epollwait(epfd int, events []EpollEvent, msec int) (n int, err error) {
- e.mu.Lock() // in [rare] case of concurrent epollcreate + epollwait
- ep, ok := e.epfd2ep[epfd]
-
- if !ok {
- e.mu.Unlock()
- return 0, EBADF
- }
-
- pollfds := make([]PollFd, 4)
- for fd, epollevt := range ep.fds {
- pollfds = append(pollfds, PollFd{Fd: int32(fd), Events: epToPollEvt(epollevt.Events)})
- }
- e.mu.Unlock()
-
- n, err = Poll(pollfds, msec)
- if err != nil {
- return n, err
- }
-
- i := 0
- for _, pFd := range pollfds {
- if pFd.Revents != 0 {
- events[i] = EpollEvent{Fd: pFd.Fd, Events: pToEpollEvt(pFd.Revents)}
- i++
- }
-
- if i == n {
- break
- }
- }
-
- return n, nil
-}
-
-func EpollCreate(size int) (fd int, err error) {
- return impl.epollcreate(size)
-}
-
-func EpollCreate1(flag int) (fd int, err error) {
- return impl.epollcreate1(flag)
-}
-
-func EpollCtl(epfd int, op int, fd int, event *EpollEvent) (err error) {
- return impl.epollctl(epfd, op, fd, event)
-}
-
-// Because EpollWait mutates events, the caller is expected to coordinate
-// concurrent access if calling with the same epfd from multiple goroutines.
-func EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) {
- return impl.epollwait(epfd, events, msec)
-}
diff --git a/vendor/golang.org/x/sys/unix/fcntl.go b/vendor/golang.org/x/sys/unix/fcntl.go
deleted file mode 100644
index 6200876..0000000
--- a/vendor/golang.org/x/sys/unix/fcntl.go
+++ /dev/null
@@ -1,36 +0,0 @@
-// Copyright 2014 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-//go:build dragonfly || freebsd || linux || netbsd
-
-package unix
-
-import "unsafe"
-
-// fcntl64Syscall is usually SYS_FCNTL, but is overridden on 32-bit Linux
-// systems by fcntl_linux_32bit.go to be SYS_FCNTL64.
-var fcntl64Syscall uintptr = SYS_FCNTL
-
-func fcntl(fd int, cmd, arg int) (int, error) {
- valptr, _, errno := Syscall(fcntl64Syscall, uintptr(fd), uintptr(cmd), uintptr(arg))
- var err error
- if errno != 0 {
- err = errno
- }
- return int(valptr), err
-}
-
-// FcntlInt performs a fcntl syscall on fd with the provided command and argument.
-func FcntlInt(fd uintptr, cmd, arg int) (int, error) {
- return fcntl(int(fd), cmd, arg)
-}
-
-// FcntlFlock performs a fcntl syscall for the F_GETLK, F_SETLK or F_SETLKW command.
-func FcntlFlock(fd uintptr, cmd int, lk *Flock_t) error {
- _, _, errno := Syscall(fcntl64Syscall, fd, uintptr(cmd), uintptr(unsafe.Pointer(lk)))
- if errno == 0 {
- return nil
- }
- return errno
-}
diff --git a/vendor/golang.org/x/sys/unix/fcntl_darwin.go b/vendor/golang.org/x/sys/unix/fcntl_darwin.go
deleted file mode 100644
index a9911c7..0000000
--- a/vendor/golang.org/x/sys/unix/fcntl_darwin.go
+++ /dev/null
@@ -1,24 +0,0 @@
-// Copyright 2019 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package unix
-
-import "unsafe"
-
-// FcntlInt performs a fcntl syscall on fd with the provided command and argument.
-func FcntlInt(fd uintptr, cmd, arg int) (int, error) {
- return fcntl(int(fd), cmd, arg)
-}
-
-// FcntlFlock performs a fcntl syscall for the F_GETLK, F_SETLK or F_SETLKW command.
-func FcntlFlock(fd uintptr, cmd int, lk *Flock_t) error {
- _, err := fcntl(int(fd), cmd, int(uintptr(unsafe.Pointer(lk))))
- return err
-}
-
-// FcntlFstore performs a fcntl syscall for the F_PREALLOCATE command.
-func FcntlFstore(fd uintptr, cmd int, fstore *Fstore_t) error {
- _, err := fcntl(int(fd), cmd, int(uintptr(unsafe.Pointer(fstore))))
- return err
-}
diff --git a/vendor/golang.org/x/sys/unix/fcntl_linux_32bit.go b/vendor/golang.org/x/sys/unix/fcntl_linux_32bit.go
deleted file mode 100644
index 13b4acd..0000000
--- a/vendor/golang.org/x/sys/unix/fcntl_linux_32bit.go
+++ /dev/null
@@ -1,13 +0,0 @@
-// Copyright 2014 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-//go:build (linux && 386) || (linux && arm) || (linux && mips) || (linux && mipsle) || (linux && ppc)
-
-package unix
-
-func init() {
- // On 32-bit Linux systems, the fcntl syscall that matches Go's
- // Flock_t type is SYS_FCNTL64, not SYS_FCNTL.
- fcntl64Syscall = SYS_FCNTL64
-}
diff --git a/vendor/golang.org/x/sys/unix/fdset.go b/vendor/golang.org/x/sys/unix/fdset.go
deleted file mode 100644
index 9e83d18..0000000
--- a/vendor/golang.org/x/sys/unix/fdset.go
+++ /dev/null
@@ -1,29 +0,0 @@
-// Copyright 2019 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-//go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris || zos
-
-package unix
-
-// Set adds fd to the set fds.
-func (fds *FdSet) Set(fd int) {
- fds.Bits[fd/NFDBITS] |= (1 << (uintptr(fd) % NFDBITS))
-}
-
-// Clear removes fd from the set fds.
-func (fds *FdSet) Clear(fd int) {
- fds.Bits[fd/NFDBITS] &^= (1 << (uintptr(fd) % NFDBITS))
-}
-
-// IsSet returns whether fd is in the set fds.
-func (fds *FdSet) IsSet(fd int) bool {
- return fds.Bits[fd/NFDBITS]&(1<<(uintptr(fd)%NFDBITS)) != 0
-}
-
-// Zero clears the set fds.
-func (fds *FdSet) Zero() {
- for i := range fds.Bits {
- fds.Bits[i] = 0
- }
-}
diff --git a/vendor/golang.org/x/sys/unix/fstatfs_zos.go b/vendor/golang.org/x/sys/unix/fstatfs_zos.go
deleted file mode 100644
index c8bde60..0000000
--- a/vendor/golang.org/x/sys/unix/fstatfs_zos.go
+++ /dev/null
@@ -1,163 +0,0 @@
-// Copyright 2020 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-//go:build zos && s390x
-
-package unix
-
-import (
- "unsafe"
-)
-
-// This file simulates fstatfs on z/OS using fstatvfs and w_getmntent.
-
-func Fstatfs(fd int, stat *Statfs_t) (err error) {
- var stat_v Statvfs_t
- err = Fstatvfs(fd, &stat_v)
- if err == nil {
- // populate stat
- stat.Type = 0
- stat.Bsize = stat_v.Bsize
- stat.Blocks = stat_v.Blocks
- stat.Bfree = stat_v.Bfree
- stat.Bavail = stat_v.Bavail
- stat.Files = stat_v.Files
- stat.Ffree = stat_v.Ffree
- stat.Fsid = stat_v.Fsid
- stat.Namelen = stat_v.Namemax
- stat.Frsize = stat_v.Frsize
- stat.Flags = stat_v.Flag
- for passn := 0; passn < 5; passn++ {
- switch passn {
- case 0:
- err = tryGetmntent64(stat)
- break
- case 1:
- err = tryGetmntent128(stat)
- break
- case 2:
- err = tryGetmntent256(stat)
- break
- case 3:
- err = tryGetmntent512(stat)
- break
- case 4:
- err = tryGetmntent1024(stat)
- break
- default:
- break
- }
- //proceed to return if: err is nil (found), err is nonnil but not ERANGE (another error occurred)
- if err == nil || err != nil && err != ERANGE {
- break
- }
- }
- }
- return err
-}
-
-func tryGetmntent64(stat *Statfs_t) (err error) {
- var mnt_ent_buffer struct {
- header W_Mnth
- filesys_info [64]W_Mntent
- }
- var buffer_size int = int(unsafe.Sizeof(mnt_ent_buffer))
- fs_count, err := W_Getmntent((*byte)(unsafe.Pointer(&mnt_ent_buffer)), buffer_size)
- if err != nil {
- return err
- }
- err = ERANGE //return ERANGE if no match is found in this batch
- for i := 0; i < fs_count; i++ {
- if stat.Fsid == uint64(mnt_ent_buffer.filesys_info[i].Dev) {
- stat.Type = uint32(mnt_ent_buffer.filesys_info[i].Fstname[0])
- err = nil
- break
- }
- }
- return err
-}
-
-func tryGetmntent128(stat *Statfs_t) (err error) {
- var mnt_ent_buffer struct {
- header W_Mnth
- filesys_info [128]W_Mntent
- }
- var buffer_size int = int(unsafe.Sizeof(mnt_ent_buffer))
- fs_count, err := W_Getmntent((*byte)(unsafe.Pointer(&mnt_ent_buffer)), buffer_size)
- if err != nil {
- return err
- }
- err = ERANGE //return ERANGE if no match is found in this batch
- for i := 0; i < fs_count; i++ {
- if stat.Fsid == uint64(mnt_ent_buffer.filesys_info[i].Dev) {
- stat.Type = uint32(mnt_ent_buffer.filesys_info[i].Fstname[0])
- err = nil
- break
- }
- }
- return err
-}
-
-func tryGetmntent256(stat *Statfs_t) (err error) {
- var mnt_ent_buffer struct {
- header W_Mnth
- filesys_info [256]W_Mntent
- }
- var buffer_size int = int(unsafe.Sizeof(mnt_ent_buffer))
- fs_count, err := W_Getmntent((*byte)(unsafe.Pointer(&mnt_ent_buffer)), buffer_size)
- if err != nil {
- return err
- }
- err = ERANGE //return ERANGE if no match is found in this batch
- for i := 0; i < fs_count; i++ {
- if stat.Fsid == uint64(mnt_ent_buffer.filesys_info[i].Dev) {
- stat.Type = uint32(mnt_ent_buffer.filesys_info[i].Fstname[0])
- err = nil
- break
- }
- }
- return err
-}
-
-func tryGetmntent512(stat *Statfs_t) (err error) {
- var mnt_ent_buffer struct {
- header W_Mnth
- filesys_info [512]W_Mntent
- }
- var buffer_size int = int(unsafe.Sizeof(mnt_ent_buffer))
- fs_count, err := W_Getmntent((*byte)(unsafe.Pointer(&mnt_ent_buffer)), buffer_size)
- if err != nil {
- return err
- }
- err = ERANGE //return ERANGE if no match is found in this batch
- for i := 0; i < fs_count; i++ {
- if stat.Fsid == uint64(mnt_ent_buffer.filesys_info[i].Dev) {
- stat.Type = uint32(mnt_ent_buffer.filesys_info[i].Fstname[0])
- err = nil
- break
- }
- }
- return err
-}
-
-func tryGetmntent1024(stat *Statfs_t) (err error) {
- var mnt_ent_buffer struct {
- header W_Mnth
- filesys_info [1024]W_Mntent
- }
- var buffer_size int = int(unsafe.Sizeof(mnt_ent_buffer))
- fs_count, err := W_Getmntent((*byte)(unsafe.Pointer(&mnt_ent_buffer)), buffer_size)
- if err != nil {
- return err
- }
- err = ERANGE //return ERANGE if no match is found in this batch
- for i := 0; i < fs_count; i++ {
- if stat.Fsid == uint64(mnt_ent_buffer.filesys_info[i].Dev) {
- stat.Type = uint32(mnt_ent_buffer.filesys_info[i].Fstname[0])
- err = nil
- break
- }
- }
- return err
-}
diff --git a/vendor/golang.org/x/sys/unix/gccgo.go b/vendor/golang.org/x/sys/unix/gccgo.go
deleted file mode 100644
index aca5721..0000000
--- a/vendor/golang.org/x/sys/unix/gccgo.go
+++ /dev/null
@@ -1,59 +0,0 @@
-// Copyright 2015 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-//go:build gccgo && !aix && !hurd
-
-package unix
-
-import "syscall"
-
-// We can't use the gc-syntax .s files for gccgo. On the plus side
-// much of the functionality can be written directly in Go.
-
-func realSyscallNoError(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r uintptr)
-
-func realSyscall(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r, errno uintptr)
-
-func SyscallNoError(trap, a1, a2, a3 uintptr) (r1, r2 uintptr) {
- syscall.Entersyscall()
- r := realSyscallNoError(trap, a1, a2, a3, 0, 0, 0, 0, 0, 0)
- syscall.Exitsyscall()
- return r, 0
-}
-
-func Syscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) {
- syscall.Entersyscall()
- r, errno := realSyscall(trap, a1, a2, a3, 0, 0, 0, 0, 0, 0)
- syscall.Exitsyscall()
- return r, 0, syscall.Errno(errno)
-}
-
-func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) {
- syscall.Entersyscall()
- r, errno := realSyscall(trap, a1, a2, a3, a4, a5, a6, 0, 0, 0)
- syscall.Exitsyscall()
- return r, 0, syscall.Errno(errno)
-}
-
-func Syscall9(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) {
- syscall.Entersyscall()
- r, errno := realSyscall(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9)
- syscall.Exitsyscall()
- return r, 0, syscall.Errno(errno)
-}
-
-func RawSyscallNoError(trap, a1, a2, a3 uintptr) (r1, r2 uintptr) {
- r := realSyscallNoError(trap, a1, a2, a3, 0, 0, 0, 0, 0, 0)
- return r, 0
-}
-
-func RawSyscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) {
- r, errno := realSyscall(trap, a1, a2, a3, 0, 0, 0, 0, 0, 0)
- return r, 0, syscall.Errno(errno)
-}
-
-func RawSyscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) {
- r, errno := realSyscall(trap, a1, a2, a3, a4, a5, a6, 0, 0, 0)
- return r, 0, syscall.Errno(errno)
-}
diff --git a/vendor/golang.org/x/sys/unix/gccgo_c.c b/vendor/golang.org/x/sys/unix/gccgo_c.c
deleted file mode 100644
index d468b7b..0000000
--- a/vendor/golang.org/x/sys/unix/gccgo_c.c
+++ /dev/null
@@ -1,44 +0,0 @@
-// Copyright 2015 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-//go:build gccgo && !aix && !hurd
-
-#include
-#include
-#include
-
-#define _STRINGIFY2_(x) #x
-#define _STRINGIFY_(x) _STRINGIFY2_(x)
-#define GOSYM_PREFIX _STRINGIFY_(__USER_LABEL_PREFIX__)
-
-// Call syscall from C code because the gccgo support for calling from
-// Go to C does not support varargs functions.
-
-struct ret {
- uintptr_t r;
- uintptr_t err;
-};
-
-struct ret gccgoRealSyscall(uintptr_t trap, uintptr_t a1, uintptr_t a2, uintptr_t a3, uintptr_t a4, uintptr_t a5, uintptr_t a6, uintptr_t a7, uintptr_t a8, uintptr_t a9)
- __asm__(GOSYM_PREFIX GOPKGPATH ".realSyscall");
-
-struct ret
-gccgoRealSyscall(uintptr_t trap, uintptr_t a1, uintptr_t a2, uintptr_t a3, uintptr_t a4, uintptr_t a5, uintptr_t a6, uintptr_t a7, uintptr_t a8, uintptr_t a9)
-{
- struct ret r;
-
- errno = 0;
- r.r = syscall(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9);
- r.err = errno;
- return r;
-}
-
-uintptr_t gccgoRealSyscallNoError(uintptr_t trap, uintptr_t a1, uintptr_t a2, uintptr_t a3, uintptr_t a4, uintptr_t a5, uintptr_t a6, uintptr_t a7, uintptr_t a8, uintptr_t a9)
- __asm__(GOSYM_PREFIX GOPKGPATH ".realSyscallNoError");
-
-uintptr_t
-gccgoRealSyscallNoError(uintptr_t trap, uintptr_t a1, uintptr_t a2, uintptr_t a3, uintptr_t a4, uintptr_t a5, uintptr_t a6, uintptr_t a7, uintptr_t a8, uintptr_t a9)
-{
- return syscall(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9);
-}
diff --git a/vendor/golang.org/x/sys/unix/gccgo_linux_amd64.go b/vendor/golang.org/x/sys/unix/gccgo_linux_amd64.go
deleted file mode 100644
index 972d61b..0000000
--- a/vendor/golang.org/x/sys/unix/gccgo_linux_amd64.go
+++ /dev/null
@@ -1,20 +0,0 @@
-// Copyright 2015 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-//go:build gccgo && linux && amd64
-
-package unix
-
-import "syscall"
-
-//extern gettimeofday
-func realGettimeofday(*Timeval, *byte) int32
-
-func gettimeofday(tv *Timeval) (err syscall.Errno) {
- r := realGettimeofday(tv, nil)
- if r < 0 {
- return syscall.GetErrno()
- }
- return 0
-}
diff --git a/vendor/golang.org/x/sys/unix/ifreq_linux.go b/vendor/golang.org/x/sys/unix/ifreq_linux.go
deleted file mode 100644
index 848840a..0000000
--- a/vendor/golang.org/x/sys/unix/ifreq_linux.go
+++ /dev/null
@@ -1,141 +0,0 @@
-// Copyright 2021 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-//go:build linux
-
-package unix
-
-import (
- "unsafe"
-)
-
-// Helpers for dealing with ifreq since it contains a union and thus requires a
-// lot of unsafe.Pointer casts to use properly.
-
-// An Ifreq is a type-safe wrapper around the raw ifreq struct. An Ifreq
-// contains an interface name and a union of arbitrary data which can be
-// accessed using the Ifreq's methods. To create an Ifreq, use the NewIfreq
-// function.
-//
-// Use the Name method to access the stored interface name. The union data
-// fields can be get and set using the following methods:
-// - Uint16/SetUint16: flags
-// - Uint32/SetUint32: ifindex, metric, mtu
-type Ifreq struct{ raw ifreq }
-
-// NewIfreq creates an Ifreq with the input network interface name after
-// validating the name does not exceed IFNAMSIZ-1 (trailing NULL required)
-// bytes.
-func NewIfreq(name string) (*Ifreq, error) {
- // Leave room for terminating NULL byte.
- if len(name) >= IFNAMSIZ {
- return nil, EINVAL
- }
-
- var ifr ifreq
- copy(ifr.Ifrn[:], name)
-
- return &Ifreq{raw: ifr}, nil
-}
-
-// TODO(mdlayher): get/set methods for hardware address sockaddr, char array, etc.
-
-// Name returns the interface name associated with the Ifreq.
-func (ifr *Ifreq) Name() string {
- return ByteSliceToString(ifr.raw.Ifrn[:])
-}
-
-// According to netdevice(7), only AF_INET addresses are returned for numerous
-// sockaddr ioctls. For convenience, we expose these as Inet4Addr since the Port
-// field and other data is always empty.
-
-// Inet4Addr returns the Ifreq union data from an embedded sockaddr as a C
-// in_addr/Go []byte (4-byte IPv4 address) value. If the sockaddr family is not
-// AF_INET, an error is returned.
-func (ifr *Ifreq) Inet4Addr() ([]byte, error) {
- raw := *(*RawSockaddrInet4)(unsafe.Pointer(&ifr.raw.Ifru[:SizeofSockaddrInet4][0]))
- if raw.Family != AF_INET {
- // Cannot safely interpret raw.Addr bytes as an IPv4 address.
- return nil, EINVAL
- }
-
- return raw.Addr[:], nil
-}
-
-// SetInet4Addr sets a C in_addr/Go []byte (4-byte IPv4 address) value in an
-// embedded sockaddr within the Ifreq's union data. v must be 4 bytes in length
-// or an error will be returned.
-func (ifr *Ifreq) SetInet4Addr(v []byte) error {
- if len(v) != 4 {
- return EINVAL
- }
-
- var addr [4]byte
- copy(addr[:], v)
-
- ifr.clear()
- *(*RawSockaddrInet4)(
- unsafe.Pointer(&ifr.raw.Ifru[:SizeofSockaddrInet4][0]),
- ) = RawSockaddrInet4{
- // Always set IP family as ioctls would require it anyway.
- Family: AF_INET,
- Addr: addr,
- }
-
- return nil
-}
-
-// Uint16 returns the Ifreq union data as a C short/Go uint16 value.
-func (ifr *Ifreq) Uint16() uint16 {
- return *(*uint16)(unsafe.Pointer(&ifr.raw.Ifru[:2][0]))
-}
-
-// SetUint16 sets a C short/Go uint16 value as the Ifreq's union data.
-func (ifr *Ifreq) SetUint16(v uint16) {
- ifr.clear()
- *(*uint16)(unsafe.Pointer(&ifr.raw.Ifru[:2][0])) = v
-}
-
-// Uint32 returns the Ifreq union data as a C int/Go uint32 value.
-func (ifr *Ifreq) Uint32() uint32 {
- return *(*uint32)(unsafe.Pointer(&ifr.raw.Ifru[:4][0]))
-}
-
-// SetUint32 sets a C int/Go uint32 value as the Ifreq's union data.
-func (ifr *Ifreq) SetUint32(v uint32) {
- ifr.clear()
- *(*uint32)(unsafe.Pointer(&ifr.raw.Ifru[:4][0])) = v
-}
-
-// clear zeroes the ifreq's union field to prevent trailing garbage data from
-// being sent to the kernel if an ifreq is reused.
-func (ifr *Ifreq) clear() {
- for i := range ifr.raw.Ifru {
- ifr.raw.Ifru[i] = 0
- }
-}
-
-// TODO(mdlayher): export as IfreqData? For now we can provide helpers such as
-// IoctlGetEthtoolDrvinfo which use these APIs under the hood.
-
-// An ifreqData is an Ifreq which carries pointer data. To produce an ifreqData,
-// use the Ifreq.withData method.
-type ifreqData struct {
- name [IFNAMSIZ]byte
- // A type separate from ifreq is required in order to comply with the
- // unsafe.Pointer rules since the "pointer-ness" of data would not be
- // preserved if it were cast into the byte array of a raw ifreq.
- data unsafe.Pointer
- // Pad to the same size as ifreq.
- _ [len(ifreq{}.Ifru) - SizeofPtr]byte
-}
-
-// withData produces an ifreqData with the pointer p set for ioctls which require
-// arbitrary pointer data.
-func (ifr Ifreq) withData(p unsafe.Pointer) ifreqData {
- return ifreqData{
- name: ifr.raw.Ifrn,
- data: p,
- }
-}
diff --git a/vendor/golang.org/x/sys/unix/ioctl_linux.go b/vendor/golang.org/x/sys/unix/ioctl_linux.go
deleted file mode 100644
index dbe680e..0000000
--- a/vendor/golang.org/x/sys/unix/ioctl_linux.go
+++ /dev/null
@@ -1,238 +0,0 @@
-// Copyright 2021 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package unix
-
-import "unsafe"
-
-// IoctlRetInt performs an ioctl operation specified by req on a device
-// associated with opened file descriptor fd, and returns a non-negative
-// integer that is returned by the ioctl syscall.
-func IoctlRetInt(fd int, req uint) (int, error) {
- ret, _, err := Syscall(SYS_IOCTL, uintptr(fd), uintptr(req), 0)
- if err != 0 {
- return 0, err
- }
- return int(ret), nil
-}
-
-func IoctlGetUint32(fd int, req uint) (uint32, error) {
- var value uint32
- err := ioctlPtr(fd, req, unsafe.Pointer(&value))
- return value, err
-}
-
-func IoctlGetRTCTime(fd int) (*RTCTime, error) {
- var value RTCTime
- err := ioctlPtr(fd, RTC_RD_TIME, unsafe.Pointer(&value))
- return &value, err
-}
-
-func IoctlSetRTCTime(fd int, value *RTCTime) error {
- return ioctlPtr(fd, RTC_SET_TIME, unsafe.Pointer(value))
-}
-
-func IoctlGetRTCWkAlrm(fd int) (*RTCWkAlrm, error) {
- var value RTCWkAlrm
- err := ioctlPtr(fd, RTC_WKALM_RD, unsafe.Pointer(&value))
- return &value, err
-}
-
-func IoctlSetRTCWkAlrm(fd int, value *RTCWkAlrm) error {
- return ioctlPtr(fd, RTC_WKALM_SET, unsafe.Pointer(value))
-}
-
-// IoctlGetEthtoolDrvinfo fetches ethtool driver information for the network
-// device specified by ifname.
-func IoctlGetEthtoolDrvinfo(fd int, ifname string) (*EthtoolDrvinfo, error) {
- ifr, err := NewIfreq(ifname)
- if err != nil {
- return nil, err
- }
-
- value := EthtoolDrvinfo{Cmd: ETHTOOL_GDRVINFO}
- ifrd := ifr.withData(unsafe.Pointer(&value))
-
- err = ioctlIfreqData(fd, SIOCETHTOOL, &ifrd)
- return &value, err
-}
-
-// IoctlGetWatchdogInfo fetches information about a watchdog device from the
-// Linux watchdog API. For more information, see:
-// https://www.kernel.org/doc/html/latest/watchdog/watchdog-api.html.
-func IoctlGetWatchdogInfo(fd int) (*WatchdogInfo, error) {
- var value WatchdogInfo
- err := ioctlPtr(fd, WDIOC_GETSUPPORT, unsafe.Pointer(&value))
- return &value, err
-}
-
-// IoctlWatchdogKeepalive issues a keepalive ioctl to a watchdog device. For
-// more information, see:
-// https://www.kernel.org/doc/html/latest/watchdog/watchdog-api.html.
-func IoctlWatchdogKeepalive(fd int) error {
- // arg is ignored and not a pointer, so ioctl is fine instead of ioctlPtr.
- return ioctl(fd, WDIOC_KEEPALIVE, 0)
-}
-
-// IoctlFileCloneRange performs an FICLONERANGE ioctl operation to clone the
-// range of data conveyed in value to the file associated with the file
-// descriptor destFd. See the ioctl_ficlonerange(2) man page for details.
-func IoctlFileCloneRange(destFd int, value *FileCloneRange) error {
- return ioctlPtr(destFd, FICLONERANGE, unsafe.Pointer(value))
-}
-
-// IoctlFileClone performs an FICLONE ioctl operation to clone the entire file
-// associated with the file description srcFd to the file associated with the
-// file descriptor destFd. See the ioctl_ficlone(2) man page for details.
-func IoctlFileClone(destFd, srcFd int) error {
- return ioctl(destFd, FICLONE, uintptr(srcFd))
-}
-
-type FileDedupeRange struct {
- Src_offset uint64
- Src_length uint64
- Reserved1 uint16
- Reserved2 uint32
- Info []FileDedupeRangeInfo
-}
-
-type FileDedupeRangeInfo struct {
- Dest_fd int64
- Dest_offset uint64
- Bytes_deduped uint64
- Status int32
- Reserved uint32
-}
-
-// IoctlFileDedupeRange performs an FIDEDUPERANGE ioctl operation to share the
-// range of data conveyed in value from the file associated with the file
-// descriptor srcFd to the value.Info destinations. See the
-// ioctl_fideduperange(2) man page for details.
-func IoctlFileDedupeRange(srcFd int, value *FileDedupeRange) error {
- buf := make([]byte, SizeofRawFileDedupeRange+
- len(value.Info)*SizeofRawFileDedupeRangeInfo)
- rawrange := (*RawFileDedupeRange)(unsafe.Pointer(&buf[0]))
- rawrange.Src_offset = value.Src_offset
- rawrange.Src_length = value.Src_length
- rawrange.Dest_count = uint16(len(value.Info))
- rawrange.Reserved1 = value.Reserved1
- rawrange.Reserved2 = value.Reserved2
-
- for i := range value.Info {
- rawinfo := (*RawFileDedupeRangeInfo)(unsafe.Pointer(
- uintptr(unsafe.Pointer(&buf[0])) + uintptr(SizeofRawFileDedupeRange) +
- uintptr(i*SizeofRawFileDedupeRangeInfo)))
- rawinfo.Dest_fd = value.Info[i].Dest_fd
- rawinfo.Dest_offset = value.Info[i].Dest_offset
- rawinfo.Bytes_deduped = value.Info[i].Bytes_deduped
- rawinfo.Status = value.Info[i].Status
- rawinfo.Reserved = value.Info[i].Reserved
- }
-
- err := ioctlPtr(srcFd, FIDEDUPERANGE, unsafe.Pointer(&buf[0]))
-
- // Output
- for i := range value.Info {
- rawinfo := (*RawFileDedupeRangeInfo)(unsafe.Pointer(
- uintptr(unsafe.Pointer(&buf[0])) + uintptr(SizeofRawFileDedupeRange) +
- uintptr(i*SizeofRawFileDedupeRangeInfo)))
- value.Info[i].Dest_fd = rawinfo.Dest_fd
- value.Info[i].Dest_offset = rawinfo.Dest_offset
- value.Info[i].Bytes_deduped = rawinfo.Bytes_deduped
- value.Info[i].Status = rawinfo.Status
- value.Info[i].Reserved = rawinfo.Reserved
- }
-
- return err
-}
-
-func IoctlHIDGetDesc(fd int, value *HIDRawReportDescriptor) error {
- return ioctlPtr(fd, HIDIOCGRDESC, unsafe.Pointer(value))
-}
-
-func IoctlHIDGetRawInfo(fd int) (*HIDRawDevInfo, error) {
- var value HIDRawDevInfo
- err := ioctlPtr(fd, HIDIOCGRAWINFO, unsafe.Pointer(&value))
- return &value, err
-}
-
-func IoctlHIDGetRawName(fd int) (string, error) {
- var value [_HIDIOCGRAWNAME_LEN]byte
- err := ioctlPtr(fd, _HIDIOCGRAWNAME, unsafe.Pointer(&value[0]))
- return ByteSliceToString(value[:]), err
-}
-
-func IoctlHIDGetRawPhys(fd int) (string, error) {
- var value [_HIDIOCGRAWPHYS_LEN]byte
- err := ioctlPtr(fd, _HIDIOCGRAWPHYS, unsafe.Pointer(&value[0]))
- return ByteSliceToString(value[:]), err
-}
-
-func IoctlHIDGetRawUniq(fd int) (string, error) {
- var value [_HIDIOCGRAWUNIQ_LEN]byte
- err := ioctlPtr(fd, _HIDIOCGRAWUNIQ, unsafe.Pointer(&value[0]))
- return ByteSliceToString(value[:]), err
-}
-
-// IoctlIfreq performs an ioctl using an Ifreq structure for input and/or
-// output. See the netdevice(7) man page for details.
-func IoctlIfreq(fd int, req uint, value *Ifreq) error {
- // It is possible we will add more fields to *Ifreq itself later to prevent
- // misuse, so pass the raw *ifreq directly.
- return ioctlPtr(fd, req, unsafe.Pointer(&value.raw))
-}
-
-// TODO(mdlayher): export if and when IfreqData is exported.
-
-// ioctlIfreqData performs an ioctl using an ifreqData structure for input
-// and/or output. See the netdevice(7) man page for details.
-func ioctlIfreqData(fd int, req uint, value *ifreqData) error {
- // The memory layout of IfreqData (type-safe) and ifreq (not type-safe) are
- // identical so pass *IfreqData directly.
- return ioctlPtr(fd, req, unsafe.Pointer(value))
-}
-
-// IoctlKCMClone attaches a new file descriptor to a multiplexor by cloning an
-// existing KCM socket, returning a structure containing the file descriptor of
-// the new socket.
-func IoctlKCMClone(fd int) (*KCMClone, error) {
- var info KCMClone
- if err := ioctlPtr(fd, SIOCKCMCLONE, unsafe.Pointer(&info)); err != nil {
- return nil, err
- }
-
- return &info, nil
-}
-
-// IoctlKCMAttach attaches a TCP socket and associated BPF program file
-// descriptor to a multiplexor.
-func IoctlKCMAttach(fd int, info KCMAttach) error {
- return ioctlPtr(fd, SIOCKCMATTACH, unsafe.Pointer(&info))
-}
-
-// IoctlKCMUnattach unattaches a TCP socket file descriptor from a multiplexor.
-func IoctlKCMUnattach(fd int, info KCMUnattach) error {
- return ioctlPtr(fd, SIOCKCMUNATTACH, unsafe.Pointer(&info))
-}
-
-// IoctlLoopGetStatus64 gets the status of the loop device associated with the
-// file descriptor fd using the LOOP_GET_STATUS64 operation.
-func IoctlLoopGetStatus64(fd int) (*LoopInfo64, error) {
- var value LoopInfo64
- if err := ioctlPtr(fd, LOOP_GET_STATUS64, unsafe.Pointer(&value)); err != nil {
- return nil, err
- }
- return &value, nil
-}
-
-// IoctlLoopSetStatus64 sets the status of the loop device associated with the
-// file descriptor fd using the LOOP_SET_STATUS64 operation.
-func IoctlLoopSetStatus64(fd int, value *LoopInfo64) error {
- return ioctlPtr(fd, LOOP_SET_STATUS64, unsafe.Pointer(value))
-}
-
-// IoctlLoopConfigure configures all loop device parameters in a single step
-func IoctlLoopConfigure(fd int, value *LoopConfig) error {
- return ioctlPtr(fd, LOOP_CONFIGURE, unsafe.Pointer(value))
-}
diff --git a/vendor/golang.org/x/sys/unix/ioctl_signed.go b/vendor/golang.org/x/sys/unix/ioctl_signed.go
deleted file mode 100644
index 5b0759b..0000000
--- a/vendor/golang.org/x/sys/unix/ioctl_signed.go
+++ /dev/null
@@ -1,69 +0,0 @@
-// Copyright 2018 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-//go:build aix || solaris
-
-package unix
-
-import (
- "unsafe"
-)
-
-// ioctl itself should not be exposed directly, but additional get/set
-// functions for specific types are permissible.
-
-// IoctlSetInt performs an ioctl operation which sets an integer value
-// on fd, using the specified request number.
-func IoctlSetInt(fd int, req int, value int) error {
- return ioctl(fd, req, uintptr(value))
-}
-
-// IoctlSetPointerInt performs an ioctl operation which sets an
-// integer value on fd, using the specified request number. The ioctl
-// argument is called with a pointer to the integer value, rather than
-// passing the integer value directly.
-func IoctlSetPointerInt(fd int, req int, value int) error {
- v := int32(value)
- return ioctlPtr(fd, req, unsafe.Pointer(&v))
-}
-
-// IoctlSetWinsize performs an ioctl on fd with a *Winsize argument.
-//
-// To change fd's window size, the req argument should be TIOCSWINSZ.
-func IoctlSetWinsize(fd int, req int, value *Winsize) error {
- // TODO: if we get the chance, remove the req parameter and
- // hardcode TIOCSWINSZ.
- return ioctlPtr(fd, req, unsafe.Pointer(value))
-}
-
-// IoctlSetTermios performs an ioctl on fd with a *Termios.
-//
-// The req value will usually be TCSETA or TIOCSETA.
-func IoctlSetTermios(fd int, req int, value *Termios) error {
- // TODO: if we get the chance, remove the req parameter.
- return ioctlPtr(fd, req, unsafe.Pointer(value))
-}
-
-// IoctlGetInt performs an ioctl operation which gets an integer value
-// from fd, using the specified request number.
-//
-// A few ioctl requests use the return value as an output parameter;
-// for those, IoctlRetInt should be used instead of this function.
-func IoctlGetInt(fd int, req int) (int, error) {
- var value int
- err := ioctlPtr(fd, req, unsafe.Pointer(&value))
- return value, err
-}
-
-func IoctlGetWinsize(fd int, req int) (*Winsize, error) {
- var value Winsize
- err := ioctlPtr(fd, req, unsafe.Pointer(&value))
- return &value, err
-}
-
-func IoctlGetTermios(fd int, req int) (*Termios, error) {
- var value Termios
- err := ioctlPtr(fd, req, unsafe.Pointer(&value))
- return &value, err
-}
diff --git a/vendor/golang.org/x/sys/unix/ioctl_unsigned.go b/vendor/golang.org/x/sys/unix/ioctl_unsigned.go
deleted file mode 100644
index 20f470b..0000000
--- a/vendor/golang.org/x/sys/unix/ioctl_unsigned.go
+++ /dev/null
@@ -1,69 +0,0 @@
-// Copyright 2018 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-//go:build darwin || dragonfly || freebsd || hurd || linux || netbsd || openbsd
-
-package unix
-
-import (
- "unsafe"
-)
-
-// ioctl itself should not be exposed directly, but additional get/set
-// functions for specific types are permissible.
-
-// IoctlSetInt performs an ioctl operation which sets an integer value
-// on fd, using the specified request number.
-func IoctlSetInt(fd int, req uint, value int) error {
- return ioctl(fd, req, uintptr(value))
-}
-
-// IoctlSetPointerInt performs an ioctl operation which sets an
-// integer value on fd, using the specified request number. The ioctl
-// argument is called with a pointer to the integer value, rather than
-// passing the integer value directly.
-func IoctlSetPointerInt(fd int, req uint, value int) error {
- v := int32(value)
- return ioctlPtr(fd, req, unsafe.Pointer(&v))
-}
-
-// IoctlSetWinsize performs an ioctl on fd with a *Winsize argument.
-//
-// To change fd's window size, the req argument should be TIOCSWINSZ.
-func IoctlSetWinsize(fd int, req uint, value *Winsize) error {
- // TODO: if we get the chance, remove the req parameter and
- // hardcode TIOCSWINSZ.
- return ioctlPtr(fd, req, unsafe.Pointer(value))
-}
-
-// IoctlSetTermios performs an ioctl on fd with a *Termios.
-//
-// The req value will usually be TCSETA or TIOCSETA.
-func IoctlSetTermios(fd int, req uint, value *Termios) error {
- // TODO: if we get the chance, remove the req parameter.
- return ioctlPtr(fd, req, unsafe.Pointer(value))
-}
-
-// IoctlGetInt performs an ioctl operation which gets an integer value
-// from fd, using the specified request number.
-//
-// A few ioctl requests use the return value as an output parameter;
-// for those, IoctlRetInt should be used instead of this function.
-func IoctlGetInt(fd int, req uint) (int, error) {
- var value int
- err := ioctlPtr(fd, req, unsafe.Pointer(&value))
- return value, err
-}
-
-func IoctlGetWinsize(fd int, req uint) (*Winsize, error) {
- var value Winsize
- err := ioctlPtr(fd, req, unsafe.Pointer(&value))
- return &value, err
-}
-
-func IoctlGetTermios(fd int, req uint) (*Termios, error) {
- var value Termios
- err := ioctlPtr(fd, req, unsafe.Pointer(&value))
- return &value, err
-}
diff --git a/vendor/golang.org/x/sys/unix/ioctl_zos.go b/vendor/golang.org/x/sys/unix/ioctl_zos.go
deleted file mode 100644
index c8b2a75..0000000
--- a/vendor/golang.org/x/sys/unix/ioctl_zos.go
+++ /dev/null
@@ -1,71 +0,0 @@
-// Copyright 2020 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-//go:build zos && s390x
-
-package unix
-
-import (
- "runtime"
- "unsafe"
-)
-
-// ioctl itself should not be exposed directly, but additional get/set
-// functions for specific types are permissible.
-
-// IoctlSetInt performs an ioctl operation which sets an integer value
-// on fd, using the specified request number.
-func IoctlSetInt(fd int, req int, value int) error {
- return ioctl(fd, req, uintptr(value))
-}
-
-// IoctlSetWinsize performs an ioctl on fd with a *Winsize argument.
-//
-// To change fd's window size, the req argument should be TIOCSWINSZ.
-func IoctlSetWinsize(fd int, req int, value *Winsize) error {
- // TODO: if we get the chance, remove the req parameter and
- // hardcode TIOCSWINSZ.
- return ioctlPtr(fd, req, unsafe.Pointer(value))
-}
-
-// IoctlSetTermios performs an ioctl on fd with a *Termios.
-//
-// The req value is expected to be TCSETS, TCSETSW, or TCSETSF
-func IoctlSetTermios(fd int, req int, value *Termios) error {
- if (req != TCSETS) && (req != TCSETSW) && (req != TCSETSF) {
- return ENOSYS
- }
- err := Tcsetattr(fd, int(req), value)
- runtime.KeepAlive(value)
- return err
-}
-
-// IoctlGetInt performs an ioctl operation which gets an integer value
-// from fd, using the specified request number.
-//
-// A few ioctl requests use the return value as an output parameter;
-// for those, IoctlRetInt should be used instead of this function.
-func IoctlGetInt(fd int, req int) (int, error) {
- var value int
- err := ioctlPtr(fd, req, unsafe.Pointer(&value))
- return value, err
-}
-
-func IoctlGetWinsize(fd int, req int) (*Winsize, error) {
- var value Winsize
- err := ioctlPtr(fd, req, unsafe.Pointer(&value))
- return &value, err
-}
-
-// IoctlGetTermios performs an ioctl on fd with a *Termios.
-//
-// The req value is expected to be TCGETS
-func IoctlGetTermios(fd int, req int) (*Termios, error) {
- var value Termios
- if req != TCGETS {
- return &value, ENOSYS
- }
- err := Tcgetattr(fd, &value)
- return &value, err
-}
diff --git a/vendor/golang.org/x/sys/unix/mkall.sh b/vendor/golang.org/x/sys/unix/mkall.sh
deleted file mode 100644
index e6f31d3..0000000
--- a/vendor/golang.org/x/sys/unix/mkall.sh
+++ /dev/null
@@ -1,249 +0,0 @@
-#!/usr/bin/env bash
-# Copyright 2009 The Go Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style
-# license that can be found in the LICENSE file.
-
-# This script runs or (given -n) prints suggested commands to generate files for
-# the Architecture/OS specified by the GOARCH and GOOS environment variables.
-# See README.md for more information about how the build system works.
-
-GOOSARCH="${GOOS}_${GOARCH}"
-
-# defaults
-mksyscall="go run mksyscall.go"
-mkerrors="./mkerrors.sh"
-zerrors="zerrors_$GOOSARCH.go"
-mksysctl=""
-zsysctl="zsysctl_$GOOSARCH.go"
-mksysnum=
-mktypes=
-mkasm=
-run="sh"
-cmd=""
-
-case "$1" in
--syscalls)
- for i in zsyscall*go
- do
- # Run the command line that appears in the first line
- # of the generated file to regenerate it.
- sed 1q $i | sed 's;^// ;;' | sh > _$i && gofmt < _$i > $i
- rm _$i
- done
- exit 0
- ;;
--n)
- run="cat"
- cmd="echo"
- shift
-esac
-
-case "$#" in
-0)
- ;;
-*)
- echo 'usage: mkall.sh [-n]' 1>&2
- exit 2
-esac
-
-if [[ "$GOOS" = "linux" ]]; then
- # Use the Docker-based build system
- # Files generated through docker (use $cmd so you can Ctl-C the build or run)
- $cmd docker build --tag generate:$GOOS $GOOS
- $cmd docker run --interactive --tty --volume $(cd -- "$(dirname -- "$0")/.." && pwd):/build generate:$GOOS
- exit
-fi
-
-GOOSARCH_in=syscall_$GOOSARCH.go
-case "$GOOSARCH" in
-_* | *_ | _)
- echo 'undefined $GOOS_$GOARCH:' "$GOOSARCH" 1>&2
- exit 1
- ;;
-aix_ppc)
- mkerrors="$mkerrors -maix32"
- mksyscall="go run mksyscall_aix_ppc.go -aix"
- mktypes="GOARCH=$GOARCH go tool cgo -godefs"
- ;;
-aix_ppc64)
- mkerrors="$mkerrors -maix64"
- mksyscall="go run mksyscall_aix_ppc64.go -aix"
- mktypes="GOARCH=$GOARCH go tool cgo -godefs"
- ;;
-darwin_amd64)
- mkerrors="$mkerrors -m64"
- mktypes="GOARCH=$GOARCH go tool cgo -godefs"
- mkasm="go run mkasm.go"
- ;;
-darwin_arm64)
- mkerrors="$mkerrors -m64"
- mktypes="GOARCH=$GOARCH go tool cgo -godefs"
- mkasm="go run mkasm.go"
- ;;
-dragonfly_amd64)
- mkerrors="$mkerrors -m64"
- mksyscall="go run mksyscall.go -dragonfly"
- mksysnum="go run mksysnum.go 'https://gitweb.dragonflybsd.org/dragonfly.git/blob_plain/HEAD:/sys/kern/syscalls.master'"
- mktypes="GOARCH=$GOARCH go tool cgo -godefs"
- ;;
-freebsd_386)
- mkerrors="$mkerrors -m32"
- mksyscall="go run mksyscall.go -l32"
- mksysnum="go run mksysnum.go 'https://cgit.freebsd.org/src/plain/sys/kern/syscalls.master?h=stable/12'"
- mktypes="GOARCH=$GOARCH go tool cgo -godefs"
- ;;
-freebsd_amd64)
- mkerrors="$mkerrors -m64"
- mksysnum="go run mksysnum.go 'https://cgit.freebsd.org/src/plain/sys/kern/syscalls.master?h=stable/12'"
- mktypes="GOARCH=$GOARCH go tool cgo -godefs"
- ;;
-freebsd_arm)
- mkerrors="$mkerrors"
- mksyscall="go run mksyscall.go -l32 -arm"
- mksysnum="go run mksysnum.go 'https://cgit.freebsd.org/src/plain/sys/kern/syscalls.master?h=stable/12'"
- # Let the type of C char be signed for making the bare syscall
- # API consistent across platforms.
- mktypes="GOARCH=$GOARCH go tool cgo -godefs -- -fsigned-char"
- ;;
-freebsd_arm64)
- mkerrors="$mkerrors -m64"
- mksysnum="go run mksysnum.go 'https://cgit.freebsd.org/src/plain/sys/kern/syscalls.master?h=stable/12'"
- mktypes="GOARCH=$GOARCH go tool cgo -godefs -- -fsigned-char"
- ;;
-freebsd_riscv64)
- mkerrors="$mkerrors -m64"
- mksysnum="go run mksysnum.go 'https://cgit.freebsd.org/src/plain/sys/kern/syscalls.master?h=stable/12'"
- mktypes="GOARCH=$GOARCH go tool cgo -godefs -- -fsigned-char"
- ;;
-netbsd_386)
- mkerrors="$mkerrors -m32"
- mksyscall="go run mksyscall.go -l32 -netbsd"
- mksysnum="go run mksysnum.go 'http://cvsweb.netbsd.org/bsdweb.cgi/~checkout~/src/sys/kern/syscalls.master'"
- mktypes="GOARCH=$GOARCH go tool cgo -godefs"
- ;;
-netbsd_amd64)
- mkerrors="$mkerrors -m64"
- mksyscall="go run mksyscall.go -netbsd"
- mksysnum="go run mksysnum.go 'http://cvsweb.netbsd.org/bsdweb.cgi/~checkout~/src/sys/kern/syscalls.master'"
- mktypes="GOARCH=$GOARCH go tool cgo -godefs"
- ;;
-netbsd_arm)
- mkerrors="$mkerrors"
- mksyscall="go run mksyscall.go -l32 -netbsd -arm"
- mksysnum="go run mksysnum.go 'http://cvsweb.netbsd.org/bsdweb.cgi/~checkout~/src/sys/kern/syscalls.master'"
- # Let the type of C char be signed for making the bare syscall
- # API consistent across platforms.
- mktypes="GOARCH=$GOARCH go tool cgo -godefs -- -fsigned-char"
- ;;
-netbsd_arm64)
- mkerrors="$mkerrors -m64"
- mksyscall="go run mksyscall.go -netbsd"
- mksysnum="go run mksysnum.go 'http://cvsweb.netbsd.org/bsdweb.cgi/~checkout~/src/sys/kern/syscalls.master'"
- mktypes="GOARCH=$GOARCH go tool cgo -godefs"
- ;;
-openbsd_386)
- mkasm="go run mkasm.go"
- mkerrors="$mkerrors -m32"
- mksyscall="go run mksyscall.go -l32 -openbsd -libc"
- mksysctl="go run mksysctl_openbsd.go"
- mktypes="GOARCH=$GOARCH go tool cgo -godefs"
- ;;
-openbsd_amd64)
- mkasm="go run mkasm.go"
- mkerrors="$mkerrors -m64"
- mksyscall="go run mksyscall.go -openbsd -libc"
- mksysctl="go run mksysctl_openbsd.go"
- mktypes="GOARCH=$GOARCH go tool cgo -godefs"
- ;;
-openbsd_arm)
- mkasm="go run mkasm.go"
- mkerrors="$mkerrors"
- mksyscall="go run mksyscall.go -l32 -openbsd -arm -libc"
- mksysctl="go run mksysctl_openbsd.go"
- # Let the type of C char be signed for making the bare syscall
- # API consistent across platforms.
- mktypes="GOARCH=$GOARCH go tool cgo -godefs -- -fsigned-char"
- ;;
-openbsd_arm64)
- mkasm="go run mkasm.go"
- mkerrors="$mkerrors -m64"
- mksyscall="go run mksyscall.go -openbsd -libc"
- mksysctl="go run mksysctl_openbsd.go"
- # Let the type of C char be signed for making the bare syscall
- # API consistent across platforms.
- mktypes="GOARCH=$GOARCH go tool cgo -godefs -- -fsigned-char"
- ;;
-openbsd_mips64)
- mkasm="go run mkasm.go"
- mkerrors="$mkerrors -m64"
- mksyscall="go run mksyscall.go -openbsd -libc"
- mksysctl="go run mksysctl_openbsd.go"
- # Let the type of C char be signed for making the bare syscall
- # API consistent across platforms.
- mktypes="GOARCH=$GOARCH go tool cgo -godefs -- -fsigned-char"
- ;;
-openbsd_ppc64)
- mkasm="go run mkasm.go"
- mkerrors="$mkerrors -m64"
- mksyscall="go run mksyscall.go -openbsd -libc"
- mksysctl="go run mksysctl_openbsd.go"
- # Let the type of C char be signed for making the bare syscall
- # API consistent across platforms.
- mktypes="GOARCH=$GOARCH go tool cgo -godefs -- -fsigned-char"
- ;;
-openbsd_riscv64)
- mkasm="go run mkasm.go"
- mkerrors="$mkerrors -m64"
- mksyscall="go run mksyscall.go -openbsd -libc"
- mksysctl="go run mksysctl_openbsd.go"
- # Let the type of C char be signed for making the bare syscall
- # API consistent across platforms.
- mktypes="GOARCH=$GOARCH go tool cgo -godefs -- -fsigned-char"
- ;;
-solaris_amd64)
- mksyscall="go run mksyscall_solaris.go"
- mkerrors="$mkerrors -m64"
- mksysnum=
- mktypes="GOARCH=$GOARCH go tool cgo -godefs"
- ;;
-illumos_amd64)
- mksyscall="go run mksyscall_solaris.go"
- mkerrors=
- mksysnum=
- mktypes="GOARCH=$GOARCH go tool cgo -godefs"
- ;;
-*)
- echo 'unrecognized $GOOS_$GOARCH: ' "$GOOSARCH" 1>&2
- exit 1
- ;;
-esac
-
-(
- if [ -n "$mkerrors" ]; then echo "$mkerrors |gofmt >$zerrors"; fi
- case "$GOOS" in
- *)
- syscall_goos="syscall_$GOOS.go"
- case "$GOOS" in
- darwin | dragonfly | freebsd | netbsd | openbsd)
- syscall_goos="syscall_bsd.go $syscall_goos"
- ;;
- esac
- if [ -n "$mksyscall" ]; then
- if [ "$GOOSARCH" == "aix_ppc64" ]; then
- # aix/ppc64 script generates files instead of writing to stdin.
- echo "$mksyscall -tags $GOOS,$GOARCH $syscall_goos $GOOSARCH_in && gofmt -w zsyscall_$GOOSARCH.go && gofmt -w zsyscall_"$GOOSARCH"_gccgo.go && gofmt -w zsyscall_"$GOOSARCH"_gc.go " ;
- elif [ "$GOOS" == "illumos" ]; then
- # illumos code generation requires a --illumos switch
- echo "$mksyscall -illumos -tags illumos,$GOARCH syscall_illumos.go |gofmt > zsyscall_illumos_$GOARCH.go";
- # illumos implies solaris, so solaris code generation is also required
- echo "$mksyscall -tags solaris,$GOARCH syscall_solaris.go syscall_solaris_$GOARCH.go |gofmt >zsyscall_solaris_$GOARCH.go";
- else
- echo "$mksyscall -tags $GOOS,$GOARCH $syscall_goos $GOOSARCH_in |gofmt >zsyscall_$GOOSARCH.go";
- fi
- fi
- esac
- if [ -n "$mksysctl" ]; then echo "$mksysctl |gofmt >$zsysctl"; fi
- if [ -n "$mksysnum" ]; then echo "$mksysnum |gofmt >zsysnum_$GOOSARCH.go"; fi
- if [ -n "$mktypes" ]; then echo "$mktypes types_$GOOS.go | go run mkpost.go > ztypes_$GOOSARCH.go"; fi
- if [ -n "$mkasm" ]; then echo "$mkasm $GOOS $GOARCH"; fi
-) | $run
diff --git a/vendor/golang.org/x/sys/unix/mkerrors.sh b/vendor/golang.org/x/sys/unix/mkerrors.sh
deleted file mode 100644
index fdcaa97..0000000
--- a/vendor/golang.org/x/sys/unix/mkerrors.sh
+++ /dev/null
@@ -1,789 +0,0 @@
-#!/usr/bin/env bash
-# Copyright 2009 The Go Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style
-# license that can be found in the LICENSE file.
-
-# Generate Go code listing errors and other #defined constant
-# values (ENAMETOOLONG etc.), by asking the preprocessor
-# about the definitions.
-
-unset LANG
-export LC_ALL=C
-export LC_CTYPE=C
-
-if test -z "$GOARCH" -o -z "$GOOS"; then
- echo 1>&2 "GOARCH or GOOS not defined in environment"
- exit 1
-fi
-
-# Check that we are using the new build system if we should
-if [[ "$GOOS" = "linux" ]] && [[ "$GOLANG_SYS_BUILD" != "docker" ]]; then
- echo 1>&2 "In the Docker based build system, mkerrors should not be called directly."
- echo 1>&2 "See README.md"
- exit 1
-fi
-
-if [[ "$GOOS" = "aix" ]]; then
- CC=${CC:-gcc}
-else
- CC=${CC:-cc}
-fi
-
-if [[ "$GOOS" = "solaris" ]]; then
- # Assumes GNU versions of utilities in PATH.
- export PATH=/usr/gnu/bin:$PATH
-fi
-
-uname=$(uname)
-
-includes_AIX='
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-#define AF_LOCAL AF_UNIX
-'
-
-includes_Darwin='
-#define _DARWIN_C_SOURCE
-#define KERNEL 1
-#define _DARWIN_USE_64_BIT_INODE
-#define __APPLE_USE_RFC_3542
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-// for backwards compatibility because moved TIOCREMOTE to Kernel.framework after MacOSX12.0.sdk.
-#define TIOCREMOTE 0x80047469
-'
-
-includes_DragonFly='
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-'
-
-includes_FreeBSD='
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-#if __FreeBSD__ >= 10
-#define IFT_CARP 0xf8 // IFT_CARP is deprecated in FreeBSD 10
-#undef SIOCAIFADDR
-#define SIOCAIFADDR _IOW(105, 26, struct oifaliasreq) // ifaliasreq contains if_data
-#undef SIOCSIFPHYADDR
-#define SIOCSIFPHYADDR _IOW(105, 70, struct oifaliasreq) // ifaliasreq contains if_data
-#endif
-'
-
-includes_Linux='
-#define _LARGEFILE_SOURCE
-#define _LARGEFILE64_SOURCE
-#ifndef __LP64__
-#define _FILE_OFFSET_BITS 64
-#endif
-#define _GNU_SOURCE
-
-// is broken on powerpc64, as it fails to include definitions of
-// these structures. We just include them copied from .
-#if defined(__powerpc__)
-struct sgttyb {
- char sg_ispeed;
- char sg_ospeed;
- char sg_erase;
- char sg_kill;
- short sg_flags;
-};
-
-struct tchars {
- char t_intrc;
- char t_quitc;
- char t_startc;
- char t_stopc;
- char t_eofc;
- char t_brkc;
-};
-
-struct ltchars {
- char t_suspc;
- char t_dsuspc;
- char t_rprntc;
- char t_flushc;
- char t_werasc;
- char t_lnextc;
-};
-#endif
-
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-#include
-#include
-#include
-
-#if defined(__sparc__)
-// On sparc{,64}, the kernel defines struct termios2 itself which clashes with the
-// definition in glibc. As only the error constants are needed here, include the
-// generic termibits.h (which is included by termbits.h on sparc).
-#include
-#else
-#include
-#endif
-
-#ifndef PTRACE_GETREGS
-#define PTRACE_GETREGS 0xc
-#endif
-
-#ifndef PTRACE_SETREGS
-#define PTRACE_SETREGS 0xd
-#endif
-
-#ifdef SOL_BLUETOOTH
-// SPARC includes this in /usr/include/sparc64-linux-gnu/bits/socket.h
-// but it is already in bluetooth_linux.go
-#undef SOL_BLUETOOTH
-#endif
-
-// Certain constants are missing from the fs/crypto UAPI
-#define FS_KEY_DESC_PREFIX "fscrypt:"
-#define FS_KEY_DESC_PREFIX_SIZE 8
-#define FS_MAX_KEY_SIZE 64
-
-// The code generator produces -0x1 for (~0), but an unsigned value is necessary
-// for the tipc_subscr timeout __u32 field.
-#undef TIPC_WAIT_FOREVER
-#define TIPC_WAIT_FOREVER 0xffffffff
-
-// Copied from linux/netfilter/nf_nat.h
-// Including linux/netfilter/nf_nat.h here causes conflicts between linux/in.h
-// and netinet/in.h.
-#define NF_NAT_RANGE_MAP_IPS (1 << 0)
-#define NF_NAT_RANGE_PROTO_SPECIFIED (1 << 1)
-#define NF_NAT_RANGE_PROTO_RANDOM (1 << 2)
-#define NF_NAT_RANGE_PERSISTENT (1 << 3)
-#define NF_NAT_RANGE_PROTO_RANDOM_FULLY (1 << 4)
-#define NF_NAT_RANGE_PROTO_OFFSET (1 << 5)
-#define NF_NAT_RANGE_NETMAP (1 << 6)
-#define NF_NAT_RANGE_PROTO_RANDOM_ALL \
- (NF_NAT_RANGE_PROTO_RANDOM | NF_NAT_RANGE_PROTO_RANDOM_FULLY)
-#define NF_NAT_RANGE_MASK \
- (NF_NAT_RANGE_MAP_IPS | NF_NAT_RANGE_PROTO_SPECIFIED | \
- NF_NAT_RANGE_PROTO_RANDOM | NF_NAT_RANGE_PERSISTENT | \
- NF_NAT_RANGE_PROTO_RANDOM_FULLY | NF_NAT_RANGE_PROTO_OFFSET | \
- NF_NAT_RANGE_NETMAP)
-
-// Copied from linux/hid.h.
-// Keep in sync with the size of the referenced fields.
-#define _HIDIOCGRAWNAME_LEN 128 // sizeof_field(struct hid_device, name)
-#define _HIDIOCGRAWPHYS_LEN 64 // sizeof_field(struct hid_device, phys)
-#define _HIDIOCGRAWUNIQ_LEN 64 // sizeof_field(struct hid_device, uniq)
-
-#define _HIDIOCGRAWNAME HIDIOCGRAWNAME(_HIDIOCGRAWNAME_LEN)
-#define _HIDIOCGRAWPHYS HIDIOCGRAWPHYS(_HIDIOCGRAWPHYS_LEN)
-#define _HIDIOCGRAWUNIQ HIDIOCGRAWUNIQ(_HIDIOCGRAWUNIQ_LEN)
-
-'
-
-includes_NetBSD='
-#include
-#include
-#include
-#include