Merge pull request #9254 from adisky/cri-streaming-from-k8s
Use staging k8s.io/kubelet/cri/streaming package
This commit is contained in:
		
							
								
								
									
										22
									
								
								vendor/github.com/blang/semver/v4/LICENSE
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										22
									
								
								vendor/github.com/blang/semver/v4/LICENSE
									
									
									
										generated
									
									
										vendored
									
									
								
							@@ -1,22 +0,0 @@
 | 
			
		||||
The MIT License
 | 
			
		||||
 | 
			
		||||
Copyright (c) 2014 Benedikt Lang <github at benediktlang.de>
 | 
			
		||||
 | 
			
		||||
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.
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										23
									
								
								vendor/github.com/blang/semver/v4/json.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										23
									
								
								vendor/github.com/blang/semver/v4/json.go
									
									
									
										generated
									
									
										vendored
									
									
								
							@@ -1,23 +0,0 @@
 | 
			
		||||
package semver
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"encoding/json"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// MarshalJSON implements the encoding/json.Marshaler interface.
 | 
			
		||||
func (v Version) MarshalJSON() ([]byte, error) {
 | 
			
		||||
	return json.Marshal(v.String())
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// UnmarshalJSON implements the encoding/json.Unmarshaler interface.
 | 
			
		||||
func (v *Version) UnmarshalJSON(data []byte) (err error) {
 | 
			
		||||
	var versionString string
 | 
			
		||||
 | 
			
		||||
	if err = json.Unmarshal(data, &versionString); err != nil {
 | 
			
		||||
		return
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	*v, err = Parse(versionString)
 | 
			
		||||
 | 
			
		||||
	return
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										416
									
								
								vendor/github.com/blang/semver/v4/range.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										416
									
								
								vendor/github.com/blang/semver/v4/range.go
									
									
									
										generated
									
									
										vendored
									
									
								
							@@ -1,416 +0,0 @@
 | 
			
		||||
package semver
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"strconv"
 | 
			
		||||
	"strings"
 | 
			
		||||
	"unicode"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
type wildcardType int
 | 
			
		||||
 | 
			
		||||
const (
 | 
			
		||||
	noneWildcard  wildcardType = iota
 | 
			
		||||
	majorWildcard wildcardType = 1
 | 
			
		||||
	minorWildcard wildcardType = 2
 | 
			
		||||
	patchWildcard wildcardType = 3
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
func wildcardTypefromInt(i int) wildcardType {
 | 
			
		||||
	switch i {
 | 
			
		||||
	case 1:
 | 
			
		||||
		return majorWildcard
 | 
			
		||||
	case 2:
 | 
			
		||||
		return minorWildcard
 | 
			
		||||
	case 3:
 | 
			
		||||
		return patchWildcard
 | 
			
		||||
	default:
 | 
			
		||||
		return noneWildcard
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type comparator func(Version, Version) bool
 | 
			
		||||
 | 
			
		||||
var (
 | 
			
		||||
	compEQ comparator = func(v1 Version, v2 Version) bool {
 | 
			
		||||
		return v1.Compare(v2) == 0
 | 
			
		||||
	}
 | 
			
		||||
	compNE = func(v1 Version, v2 Version) bool {
 | 
			
		||||
		return v1.Compare(v2) != 0
 | 
			
		||||
	}
 | 
			
		||||
	compGT = func(v1 Version, v2 Version) bool {
 | 
			
		||||
		return v1.Compare(v2) == 1
 | 
			
		||||
	}
 | 
			
		||||
	compGE = func(v1 Version, v2 Version) bool {
 | 
			
		||||
		return v1.Compare(v2) >= 0
 | 
			
		||||
	}
 | 
			
		||||
	compLT = func(v1 Version, v2 Version) bool {
 | 
			
		||||
		return v1.Compare(v2) == -1
 | 
			
		||||
	}
 | 
			
		||||
	compLE = func(v1 Version, v2 Version) bool {
 | 
			
		||||
		return v1.Compare(v2) <= 0
 | 
			
		||||
	}
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
type versionRange struct {
 | 
			
		||||
	v Version
 | 
			
		||||
	c comparator
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// rangeFunc creates a Range from the given versionRange.
 | 
			
		||||
func (vr *versionRange) rangeFunc() Range {
 | 
			
		||||
	return Range(func(v Version) bool {
 | 
			
		||||
		return vr.c(v, vr.v)
 | 
			
		||||
	})
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Range represents a range of versions.
 | 
			
		||||
// A Range can be used to check if a Version satisfies it:
 | 
			
		||||
//
 | 
			
		||||
//     range, err := semver.ParseRange(">1.0.0 <2.0.0")
 | 
			
		||||
//     range(semver.MustParse("1.1.1") // returns true
 | 
			
		||||
type Range func(Version) bool
 | 
			
		||||
 | 
			
		||||
// OR combines the existing Range with another Range using logical OR.
 | 
			
		||||
func (rf Range) OR(f Range) Range {
 | 
			
		||||
	return Range(func(v Version) bool {
 | 
			
		||||
		return rf(v) || f(v)
 | 
			
		||||
	})
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// AND combines the existing Range with another Range using logical AND.
 | 
			
		||||
func (rf Range) AND(f Range) Range {
 | 
			
		||||
	return Range(func(v Version) bool {
 | 
			
		||||
		return rf(v) && f(v)
 | 
			
		||||
	})
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// ParseRange parses a range and returns a Range.
 | 
			
		||||
// If the range could not be parsed an error is returned.
 | 
			
		||||
//
 | 
			
		||||
// Valid ranges are:
 | 
			
		||||
//   - "<1.0.0"
 | 
			
		||||
//   - "<=1.0.0"
 | 
			
		||||
//   - ">1.0.0"
 | 
			
		||||
//   - ">=1.0.0"
 | 
			
		||||
//   - "1.0.0", "=1.0.0", "==1.0.0"
 | 
			
		||||
//   - "!1.0.0", "!=1.0.0"
 | 
			
		||||
//
 | 
			
		||||
// A Range can consist of multiple ranges separated by space:
 | 
			
		||||
// Ranges can be linked by logical AND:
 | 
			
		||||
//   - ">1.0.0 <2.0.0" would match between both ranges, so "1.1.1" and "1.8.7" but not "1.0.0" or "2.0.0"
 | 
			
		||||
//   - ">1.0.0 <3.0.0 !2.0.3-beta.2" would match every version between 1.0.0 and 3.0.0 except 2.0.3-beta.2
 | 
			
		||||
//
 | 
			
		||||
// Ranges can also be linked by logical OR:
 | 
			
		||||
//   - "<2.0.0 || >=3.0.0" would match "1.x.x" and "3.x.x" but not "2.x.x"
 | 
			
		||||
//
 | 
			
		||||
// AND has a higher precedence than OR. It's not possible to use brackets.
 | 
			
		||||
//
 | 
			
		||||
// Ranges can be combined by both AND and OR
 | 
			
		||||
//
 | 
			
		||||
//  - `>1.0.0 <2.0.0 || >3.0.0 !4.2.1` would match `1.2.3`, `1.9.9`, `3.1.1`, but not `4.2.1`, `2.1.1`
 | 
			
		||||
func ParseRange(s string) (Range, error) {
 | 
			
		||||
	parts := splitAndTrim(s)
 | 
			
		||||
	orParts, err := splitORParts(parts)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
	expandedParts, err := expandWildcardVersion(orParts)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
	var orFn Range
 | 
			
		||||
	for _, p := range expandedParts {
 | 
			
		||||
		var andFn Range
 | 
			
		||||
		for _, ap := range p {
 | 
			
		||||
			opStr, vStr, err := splitComparatorVersion(ap)
 | 
			
		||||
			if err != nil {
 | 
			
		||||
				return nil, err
 | 
			
		||||
			}
 | 
			
		||||
			vr, err := buildVersionRange(opStr, vStr)
 | 
			
		||||
			if err != nil {
 | 
			
		||||
				return nil, fmt.Errorf("Could not parse Range %q: %s", ap, err)
 | 
			
		||||
			}
 | 
			
		||||
			rf := vr.rangeFunc()
 | 
			
		||||
 | 
			
		||||
			// Set function
 | 
			
		||||
			if andFn == nil {
 | 
			
		||||
				andFn = rf
 | 
			
		||||
			} else { // Combine with existing function
 | 
			
		||||
				andFn = andFn.AND(rf)
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		if orFn == nil {
 | 
			
		||||
			orFn = andFn
 | 
			
		||||
		} else {
 | 
			
		||||
			orFn = orFn.OR(andFn)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
	}
 | 
			
		||||
	return orFn, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// splitORParts splits the already cleaned parts by '||'.
 | 
			
		||||
// Checks for invalid positions of the operator and returns an
 | 
			
		||||
// error if found.
 | 
			
		||||
func splitORParts(parts []string) ([][]string, error) {
 | 
			
		||||
	var ORparts [][]string
 | 
			
		||||
	last := 0
 | 
			
		||||
	for i, p := range parts {
 | 
			
		||||
		if p == "||" {
 | 
			
		||||
			if i == 0 {
 | 
			
		||||
				return nil, fmt.Errorf("First element in range is '||'")
 | 
			
		||||
			}
 | 
			
		||||
			ORparts = append(ORparts, parts[last:i])
 | 
			
		||||
			last = i + 1
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	if last == len(parts) {
 | 
			
		||||
		return nil, fmt.Errorf("Last element in range is '||'")
 | 
			
		||||
	}
 | 
			
		||||
	ORparts = append(ORparts, parts[last:])
 | 
			
		||||
	return ORparts, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// buildVersionRange takes a slice of 2: operator and version
 | 
			
		||||
// and builds a versionRange, otherwise an error.
 | 
			
		||||
func buildVersionRange(opStr, vStr string) (*versionRange, error) {
 | 
			
		||||
	c := parseComparator(opStr)
 | 
			
		||||
	if c == nil {
 | 
			
		||||
		return nil, fmt.Errorf("Could not parse comparator %q in %q", opStr, strings.Join([]string{opStr, vStr}, ""))
 | 
			
		||||
	}
 | 
			
		||||
	v, err := Parse(vStr)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("Could not parse version %q in %q: %s", vStr, strings.Join([]string{opStr, vStr}, ""), err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return &versionRange{
 | 
			
		||||
		v: v,
 | 
			
		||||
		c: c,
 | 
			
		||||
	}, nil
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// inArray checks if a byte is contained in an array of bytes
 | 
			
		||||
func inArray(s byte, list []byte) bool {
 | 
			
		||||
	for _, el := range list {
 | 
			
		||||
		if el == s {
 | 
			
		||||
			return true
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	return false
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// splitAndTrim splits a range string by spaces and cleans whitespaces
 | 
			
		||||
func splitAndTrim(s string) (result []string) {
 | 
			
		||||
	last := 0
 | 
			
		||||
	var lastChar byte
 | 
			
		||||
	excludeFromSplit := []byte{'>', '<', '='}
 | 
			
		||||
	for i := 0; i < len(s); i++ {
 | 
			
		||||
		if s[i] == ' ' && !inArray(lastChar, excludeFromSplit) {
 | 
			
		||||
			if last < i-1 {
 | 
			
		||||
				result = append(result, s[last:i])
 | 
			
		||||
			}
 | 
			
		||||
			last = i + 1
 | 
			
		||||
		} else if s[i] != ' ' {
 | 
			
		||||
			lastChar = s[i]
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	if last < len(s)-1 {
 | 
			
		||||
		result = append(result, s[last:])
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	for i, v := range result {
 | 
			
		||||
		result[i] = strings.Replace(v, " ", "", -1)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// parts := strings.Split(s, " ")
 | 
			
		||||
	// for _, x := range parts {
 | 
			
		||||
	// 	if s := strings.TrimSpace(x); len(s) != 0 {
 | 
			
		||||
	// 		result = append(result, s)
 | 
			
		||||
	// 	}
 | 
			
		||||
	// }
 | 
			
		||||
	return
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// splitComparatorVersion splits the comparator from the version.
 | 
			
		||||
// Input must be free of leading or trailing spaces.
 | 
			
		||||
func splitComparatorVersion(s string) (string, string, error) {
 | 
			
		||||
	i := strings.IndexFunc(s, unicode.IsDigit)
 | 
			
		||||
	if i == -1 {
 | 
			
		||||
		return "", "", fmt.Errorf("Could not get version from string: %q", s)
 | 
			
		||||
	}
 | 
			
		||||
	return strings.TrimSpace(s[0:i]), s[i:], nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// getWildcardType will return the type of wildcard that the
 | 
			
		||||
// passed version contains
 | 
			
		||||
func getWildcardType(vStr string) wildcardType {
 | 
			
		||||
	parts := strings.Split(vStr, ".")
 | 
			
		||||
	nparts := len(parts)
 | 
			
		||||
	wildcard := parts[nparts-1]
 | 
			
		||||
 | 
			
		||||
	possibleWildcardType := wildcardTypefromInt(nparts)
 | 
			
		||||
	if wildcard == "x" {
 | 
			
		||||
		return possibleWildcardType
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return noneWildcard
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// createVersionFromWildcard will convert a wildcard version
 | 
			
		||||
// into a regular version, replacing 'x's with '0's, handling
 | 
			
		||||
// special cases like '1.x.x' and '1.x'
 | 
			
		||||
func createVersionFromWildcard(vStr string) string {
 | 
			
		||||
	// handle 1.x.x
 | 
			
		||||
	vStr2 := strings.Replace(vStr, ".x.x", ".x", 1)
 | 
			
		||||
	vStr2 = strings.Replace(vStr2, ".x", ".0", 1)
 | 
			
		||||
	parts := strings.Split(vStr2, ".")
 | 
			
		||||
 | 
			
		||||
	// handle 1.x
 | 
			
		||||
	if len(parts) == 2 {
 | 
			
		||||
		return vStr2 + ".0"
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return vStr2
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// incrementMajorVersion will increment the major version
 | 
			
		||||
// of the passed version
 | 
			
		||||
func incrementMajorVersion(vStr string) (string, error) {
 | 
			
		||||
	parts := strings.Split(vStr, ".")
 | 
			
		||||
	i, err := strconv.Atoi(parts[0])
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return "", err
 | 
			
		||||
	}
 | 
			
		||||
	parts[0] = strconv.Itoa(i + 1)
 | 
			
		||||
 | 
			
		||||
	return strings.Join(parts, "."), nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// incrementMajorVersion will increment the minor version
 | 
			
		||||
// of the passed version
 | 
			
		||||
func incrementMinorVersion(vStr string) (string, error) {
 | 
			
		||||
	parts := strings.Split(vStr, ".")
 | 
			
		||||
	i, err := strconv.Atoi(parts[1])
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return "", err
 | 
			
		||||
	}
 | 
			
		||||
	parts[1] = strconv.Itoa(i + 1)
 | 
			
		||||
 | 
			
		||||
	return strings.Join(parts, "."), nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// expandWildcardVersion will expand wildcards inside versions
 | 
			
		||||
// following these rules:
 | 
			
		||||
//
 | 
			
		||||
// * when dealing with patch wildcards:
 | 
			
		||||
// >= 1.2.x    will become    >= 1.2.0
 | 
			
		||||
// <= 1.2.x    will become    <  1.3.0
 | 
			
		||||
// >  1.2.x    will become    >= 1.3.0
 | 
			
		||||
// <  1.2.x    will become    <  1.2.0
 | 
			
		||||
// != 1.2.x    will become    <  1.2.0 >= 1.3.0
 | 
			
		||||
//
 | 
			
		||||
// * when dealing with minor wildcards:
 | 
			
		||||
// >= 1.x      will become    >= 1.0.0
 | 
			
		||||
// <= 1.x      will become    <  2.0.0
 | 
			
		||||
// >  1.x      will become    >= 2.0.0
 | 
			
		||||
// <  1.0      will become    <  1.0.0
 | 
			
		||||
// != 1.x      will become    <  1.0.0 >= 2.0.0
 | 
			
		||||
//
 | 
			
		||||
// * when dealing with wildcards without
 | 
			
		||||
// version operator:
 | 
			
		||||
// 1.2.x       will become    >= 1.2.0 < 1.3.0
 | 
			
		||||
// 1.x         will become    >= 1.0.0 < 2.0.0
 | 
			
		||||
func expandWildcardVersion(parts [][]string) ([][]string, error) {
 | 
			
		||||
	var expandedParts [][]string
 | 
			
		||||
	for _, p := range parts {
 | 
			
		||||
		var newParts []string
 | 
			
		||||
		for _, ap := range p {
 | 
			
		||||
			if strings.Contains(ap, "x") {
 | 
			
		||||
				opStr, vStr, err := splitComparatorVersion(ap)
 | 
			
		||||
				if err != nil {
 | 
			
		||||
					return nil, err
 | 
			
		||||
				}
 | 
			
		||||
 | 
			
		||||
				versionWildcardType := getWildcardType(vStr)
 | 
			
		||||
				flatVersion := createVersionFromWildcard(vStr)
 | 
			
		||||
 | 
			
		||||
				var resultOperator string
 | 
			
		||||
				var shouldIncrementVersion bool
 | 
			
		||||
				switch opStr {
 | 
			
		||||
				case ">":
 | 
			
		||||
					resultOperator = ">="
 | 
			
		||||
					shouldIncrementVersion = true
 | 
			
		||||
				case ">=":
 | 
			
		||||
					resultOperator = ">="
 | 
			
		||||
				case "<":
 | 
			
		||||
					resultOperator = "<"
 | 
			
		||||
				case "<=":
 | 
			
		||||
					resultOperator = "<"
 | 
			
		||||
					shouldIncrementVersion = true
 | 
			
		||||
				case "", "=", "==":
 | 
			
		||||
					newParts = append(newParts, ">="+flatVersion)
 | 
			
		||||
					resultOperator = "<"
 | 
			
		||||
					shouldIncrementVersion = true
 | 
			
		||||
				case "!=", "!":
 | 
			
		||||
					newParts = append(newParts, "<"+flatVersion)
 | 
			
		||||
					resultOperator = ">="
 | 
			
		||||
					shouldIncrementVersion = true
 | 
			
		||||
				}
 | 
			
		||||
 | 
			
		||||
				var resultVersion string
 | 
			
		||||
				if shouldIncrementVersion {
 | 
			
		||||
					switch versionWildcardType {
 | 
			
		||||
					case patchWildcard:
 | 
			
		||||
						resultVersion, _ = incrementMinorVersion(flatVersion)
 | 
			
		||||
					case minorWildcard:
 | 
			
		||||
						resultVersion, _ = incrementMajorVersion(flatVersion)
 | 
			
		||||
					}
 | 
			
		||||
				} else {
 | 
			
		||||
					resultVersion = flatVersion
 | 
			
		||||
				}
 | 
			
		||||
 | 
			
		||||
				ap = resultOperator + resultVersion
 | 
			
		||||
			}
 | 
			
		||||
			newParts = append(newParts, ap)
 | 
			
		||||
		}
 | 
			
		||||
		expandedParts = append(expandedParts, newParts)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return expandedParts, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func parseComparator(s string) comparator {
 | 
			
		||||
	switch s {
 | 
			
		||||
	case "==":
 | 
			
		||||
		fallthrough
 | 
			
		||||
	case "":
 | 
			
		||||
		fallthrough
 | 
			
		||||
	case "=":
 | 
			
		||||
		return compEQ
 | 
			
		||||
	case ">":
 | 
			
		||||
		return compGT
 | 
			
		||||
	case ">=":
 | 
			
		||||
		return compGE
 | 
			
		||||
	case "<":
 | 
			
		||||
		return compLT
 | 
			
		||||
	case "<=":
 | 
			
		||||
		return compLE
 | 
			
		||||
	case "!":
 | 
			
		||||
		fallthrough
 | 
			
		||||
	case "!=":
 | 
			
		||||
		return compNE
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// MustParseRange is like ParseRange but panics if the range cannot be parsed.
 | 
			
		||||
func MustParseRange(s string) Range {
 | 
			
		||||
	r, err := ParseRange(s)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		panic(`semver: ParseRange(` + s + `): ` + err.Error())
 | 
			
		||||
	}
 | 
			
		||||
	return r
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										476
									
								
								vendor/github.com/blang/semver/v4/semver.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										476
									
								
								vendor/github.com/blang/semver/v4/semver.go
									
									
									
										generated
									
									
										vendored
									
									
								
							@@ -1,476 +0,0 @@
 | 
			
		||||
package semver
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"errors"
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"strconv"
 | 
			
		||||
	"strings"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
const (
 | 
			
		||||
	numbers  string = "0123456789"
 | 
			
		||||
	alphas          = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-"
 | 
			
		||||
	alphanum        = alphas + numbers
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// SpecVersion is the latest fully supported spec version of semver
 | 
			
		||||
var SpecVersion = Version{
 | 
			
		||||
	Major: 2,
 | 
			
		||||
	Minor: 0,
 | 
			
		||||
	Patch: 0,
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Version represents a semver compatible version
 | 
			
		||||
type Version struct {
 | 
			
		||||
	Major uint64
 | 
			
		||||
	Minor uint64
 | 
			
		||||
	Patch uint64
 | 
			
		||||
	Pre   []PRVersion
 | 
			
		||||
	Build []string //No Precedence
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Version to string
 | 
			
		||||
func (v Version) String() string {
 | 
			
		||||
	b := make([]byte, 0, 5)
 | 
			
		||||
	b = strconv.AppendUint(b, v.Major, 10)
 | 
			
		||||
	b = append(b, '.')
 | 
			
		||||
	b = strconv.AppendUint(b, v.Minor, 10)
 | 
			
		||||
	b = append(b, '.')
 | 
			
		||||
	b = strconv.AppendUint(b, v.Patch, 10)
 | 
			
		||||
 | 
			
		||||
	if len(v.Pre) > 0 {
 | 
			
		||||
		b = append(b, '-')
 | 
			
		||||
		b = append(b, v.Pre[0].String()...)
 | 
			
		||||
 | 
			
		||||
		for _, pre := range v.Pre[1:] {
 | 
			
		||||
			b = append(b, '.')
 | 
			
		||||
			b = append(b, pre.String()...)
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if len(v.Build) > 0 {
 | 
			
		||||
		b = append(b, '+')
 | 
			
		||||
		b = append(b, v.Build[0]...)
 | 
			
		||||
 | 
			
		||||
		for _, build := range v.Build[1:] {
 | 
			
		||||
			b = append(b, '.')
 | 
			
		||||
			b = append(b, build...)
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return string(b)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// FinalizeVersion discards prerelease and build number and only returns
 | 
			
		||||
// major, minor and patch number.
 | 
			
		||||
func (v Version) FinalizeVersion() string {
 | 
			
		||||
	b := make([]byte, 0, 5)
 | 
			
		||||
	b = strconv.AppendUint(b, v.Major, 10)
 | 
			
		||||
	b = append(b, '.')
 | 
			
		||||
	b = strconv.AppendUint(b, v.Minor, 10)
 | 
			
		||||
	b = append(b, '.')
 | 
			
		||||
	b = strconv.AppendUint(b, v.Patch, 10)
 | 
			
		||||
	return string(b)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Equals checks if v is equal to o.
 | 
			
		||||
func (v Version) Equals(o Version) bool {
 | 
			
		||||
	return (v.Compare(o) == 0)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// EQ checks if v is equal to o.
 | 
			
		||||
func (v Version) EQ(o Version) bool {
 | 
			
		||||
	return (v.Compare(o) == 0)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// NE checks if v is not equal to o.
 | 
			
		||||
func (v Version) NE(o Version) bool {
 | 
			
		||||
	return (v.Compare(o) != 0)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// GT checks if v is greater than o.
 | 
			
		||||
func (v Version) GT(o Version) bool {
 | 
			
		||||
	return (v.Compare(o) == 1)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// GTE checks if v is greater than or equal to o.
 | 
			
		||||
func (v Version) GTE(o Version) bool {
 | 
			
		||||
	return (v.Compare(o) >= 0)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// GE checks if v is greater than or equal to o.
 | 
			
		||||
func (v Version) GE(o Version) bool {
 | 
			
		||||
	return (v.Compare(o) >= 0)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// LT checks if v is less than o.
 | 
			
		||||
func (v Version) LT(o Version) bool {
 | 
			
		||||
	return (v.Compare(o) == -1)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// LTE checks if v is less than or equal to o.
 | 
			
		||||
func (v Version) LTE(o Version) bool {
 | 
			
		||||
	return (v.Compare(o) <= 0)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// LE checks if v is less than or equal to o.
 | 
			
		||||
func (v Version) LE(o Version) bool {
 | 
			
		||||
	return (v.Compare(o) <= 0)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Compare compares Versions v to o:
 | 
			
		||||
// -1 == v is less than o
 | 
			
		||||
// 0 == v is equal to o
 | 
			
		||||
// 1 == v is greater than o
 | 
			
		||||
func (v Version) Compare(o Version) int {
 | 
			
		||||
	if v.Major != o.Major {
 | 
			
		||||
		if v.Major > o.Major {
 | 
			
		||||
			return 1
 | 
			
		||||
		}
 | 
			
		||||
		return -1
 | 
			
		||||
	}
 | 
			
		||||
	if v.Minor != o.Minor {
 | 
			
		||||
		if v.Minor > o.Minor {
 | 
			
		||||
			return 1
 | 
			
		||||
		}
 | 
			
		||||
		return -1
 | 
			
		||||
	}
 | 
			
		||||
	if v.Patch != o.Patch {
 | 
			
		||||
		if v.Patch > o.Patch {
 | 
			
		||||
			return 1
 | 
			
		||||
		}
 | 
			
		||||
		return -1
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// Quick comparison if a version has no prerelease versions
 | 
			
		||||
	if len(v.Pre) == 0 && len(o.Pre) == 0 {
 | 
			
		||||
		return 0
 | 
			
		||||
	} else if len(v.Pre) == 0 && len(o.Pre) > 0 {
 | 
			
		||||
		return 1
 | 
			
		||||
	} else if len(v.Pre) > 0 && len(o.Pre) == 0 {
 | 
			
		||||
		return -1
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	i := 0
 | 
			
		||||
	for ; i < len(v.Pre) && i < len(o.Pre); i++ {
 | 
			
		||||
		if comp := v.Pre[i].Compare(o.Pre[i]); comp == 0 {
 | 
			
		||||
			continue
 | 
			
		||||
		} else if comp == 1 {
 | 
			
		||||
			return 1
 | 
			
		||||
		} else {
 | 
			
		||||
			return -1
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// If all pr versions are the equal but one has further prversion, this one greater
 | 
			
		||||
	if i == len(v.Pre) && i == len(o.Pre) {
 | 
			
		||||
		return 0
 | 
			
		||||
	} else if i == len(v.Pre) && i < len(o.Pre) {
 | 
			
		||||
		return -1
 | 
			
		||||
	} else {
 | 
			
		||||
		return 1
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// IncrementPatch increments the patch version
 | 
			
		||||
func (v *Version) IncrementPatch() error {
 | 
			
		||||
	v.Patch++
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// IncrementMinor increments the minor version
 | 
			
		||||
func (v *Version) IncrementMinor() error {
 | 
			
		||||
	v.Minor++
 | 
			
		||||
	v.Patch = 0
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// IncrementMajor increments the major version
 | 
			
		||||
func (v *Version) IncrementMajor() error {
 | 
			
		||||
	v.Major++
 | 
			
		||||
	v.Minor = 0
 | 
			
		||||
	v.Patch = 0
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Validate validates v and returns error in case
 | 
			
		||||
func (v Version) Validate() error {
 | 
			
		||||
	// Major, Minor, Patch already validated using uint64
 | 
			
		||||
 | 
			
		||||
	for _, pre := range v.Pre {
 | 
			
		||||
		if !pre.IsNum { //Numeric prerelease versions already uint64
 | 
			
		||||
			if len(pre.VersionStr) == 0 {
 | 
			
		||||
				return fmt.Errorf("Prerelease can not be empty %q", pre.VersionStr)
 | 
			
		||||
			}
 | 
			
		||||
			if !containsOnly(pre.VersionStr, alphanum) {
 | 
			
		||||
				return fmt.Errorf("Invalid character(s) found in prerelease %q", pre.VersionStr)
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	for _, build := range v.Build {
 | 
			
		||||
		if len(build) == 0 {
 | 
			
		||||
			return fmt.Errorf("Build meta data can not be empty %q", build)
 | 
			
		||||
		}
 | 
			
		||||
		if !containsOnly(build, alphanum) {
 | 
			
		||||
			return fmt.Errorf("Invalid character(s) found in build meta data %q", build)
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// New is an alias for Parse and returns a pointer, parses version string and returns a validated Version or error
 | 
			
		||||
func New(s string) (*Version, error) {
 | 
			
		||||
	v, err := Parse(s)
 | 
			
		||||
	vp := &v
 | 
			
		||||
	return vp, err
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Make is an alias for Parse, parses version string and returns a validated Version or error
 | 
			
		||||
func Make(s string) (Version, error) {
 | 
			
		||||
	return Parse(s)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// ParseTolerant allows for certain version specifications that do not strictly adhere to semver
 | 
			
		||||
// specs to be parsed by this library. It does so by normalizing versions before passing them to
 | 
			
		||||
// Parse(). It currently trims spaces, removes a "v" prefix, adds a 0 patch number to versions
 | 
			
		||||
// with only major and minor components specified, and removes leading 0s.
 | 
			
		||||
func ParseTolerant(s string) (Version, error) {
 | 
			
		||||
	s = strings.TrimSpace(s)
 | 
			
		||||
	s = strings.TrimPrefix(s, "v")
 | 
			
		||||
 | 
			
		||||
	// Split into major.minor.(patch+pr+meta)
 | 
			
		||||
	parts := strings.SplitN(s, ".", 3)
 | 
			
		||||
	// Remove leading zeros.
 | 
			
		||||
	for i, p := range parts {
 | 
			
		||||
		if len(p) > 1 {
 | 
			
		||||
			p = strings.TrimLeft(p, "0")
 | 
			
		||||
			if len(p) == 0 || !strings.ContainsAny(p[0:1], "0123456789") {
 | 
			
		||||
				p = "0" + p
 | 
			
		||||
			}
 | 
			
		||||
			parts[i] = p
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	// Fill up shortened versions.
 | 
			
		||||
	if len(parts) < 3 {
 | 
			
		||||
		if strings.ContainsAny(parts[len(parts)-1], "+-") {
 | 
			
		||||
			return Version{}, errors.New("Short version cannot contain PreRelease/Build meta data")
 | 
			
		||||
		}
 | 
			
		||||
		for len(parts) < 3 {
 | 
			
		||||
			parts = append(parts, "0")
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	s = strings.Join(parts, ".")
 | 
			
		||||
 | 
			
		||||
	return Parse(s)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Parse parses version string and returns a validated Version or error
 | 
			
		||||
func Parse(s string) (Version, error) {
 | 
			
		||||
	if len(s) == 0 {
 | 
			
		||||
		return Version{}, errors.New("Version string empty")
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// Split into major.minor.(patch+pr+meta)
 | 
			
		||||
	parts := strings.SplitN(s, ".", 3)
 | 
			
		||||
	if len(parts) != 3 {
 | 
			
		||||
		return Version{}, errors.New("No Major.Minor.Patch elements found")
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// Major
 | 
			
		||||
	if !containsOnly(parts[0], numbers) {
 | 
			
		||||
		return Version{}, fmt.Errorf("Invalid character(s) found in major number %q", parts[0])
 | 
			
		||||
	}
 | 
			
		||||
	if hasLeadingZeroes(parts[0]) {
 | 
			
		||||
		return Version{}, fmt.Errorf("Major number must not contain leading zeroes %q", parts[0])
 | 
			
		||||
	}
 | 
			
		||||
	major, err := strconv.ParseUint(parts[0], 10, 64)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return Version{}, err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// Minor
 | 
			
		||||
	if !containsOnly(parts[1], numbers) {
 | 
			
		||||
		return Version{}, fmt.Errorf("Invalid character(s) found in minor number %q", parts[1])
 | 
			
		||||
	}
 | 
			
		||||
	if hasLeadingZeroes(parts[1]) {
 | 
			
		||||
		return Version{}, fmt.Errorf("Minor number must not contain leading zeroes %q", parts[1])
 | 
			
		||||
	}
 | 
			
		||||
	minor, err := strconv.ParseUint(parts[1], 10, 64)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return Version{}, err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	v := Version{}
 | 
			
		||||
	v.Major = major
 | 
			
		||||
	v.Minor = minor
 | 
			
		||||
 | 
			
		||||
	var build, prerelease []string
 | 
			
		||||
	patchStr := parts[2]
 | 
			
		||||
 | 
			
		||||
	if buildIndex := strings.IndexRune(patchStr, '+'); buildIndex != -1 {
 | 
			
		||||
		build = strings.Split(patchStr[buildIndex+1:], ".")
 | 
			
		||||
		patchStr = patchStr[:buildIndex]
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if preIndex := strings.IndexRune(patchStr, '-'); preIndex != -1 {
 | 
			
		||||
		prerelease = strings.Split(patchStr[preIndex+1:], ".")
 | 
			
		||||
		patchStr = patchStr[:preIndex]
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if !containsOnly(patchStr, numbers) {
 | 
			
		||||
		return Version{}, fmt.Errorf("Invalid character(s) found in patch number %q", patchStr)
 | 
			
		||||
	}
 | 
			
		||||
	if hasLeadingZeroes(patchStr) {
 | 
			
		||||
		return Version{}, fmt.Errorf("Patch number must not contain leading zeroes %q", patchStr)
 | 
			
		||||
	}
 | 
			
		||||
	patch, err := strconv.ParseUint(patchStr, 10, 64)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return Version{}, err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	v.Patch = patch
 | 
			
		||||
 | 
			
		||||
	// Prerelease
 | 
			
		||||
	for _, prstr := range prerelease {
 | 
			
		||||
		parsedPR, err := NewPRVersion(prstr)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			return Version{}, err
 | 
			
		||||
		}
 | 
			
		||||
		v.Pre = append(v.Pre, parsedPR)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// Build meta data
 | 
			
		||||
	for _, str := range build {
 | 
			
		||||
		if len(str) == 0 {
 | 
			
		||||
			return Version{}, errors.New("Build meta data is empty")
 | 
			
		||||
		}
 | 
			
		||||
		if !containsOnly(str, alphanum) {
 | 
			
		||||
			return Version{}, fmt.Errorf("Invalid character(s) found in build meta data %q", str)
 | 
			
		||||
		}
 | 
			
		||||
		v.Build = append(v.Build, str)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return v, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// MustParse is like Parse but panics if the version cannot be parsed.
 | 
			
		||||
func MustParse(s string) Version {
 | 
			
		||||
	v, err := Parse(s)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		panic(`semver: Parse(` + s + `): ` + err.Error())
 | 
			
		||||
	}
 | 
			
		||||
	return v
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// PRVersion represents a PreRelease Version
 | 
			
		||||
type PRVersion struct {
 | 
			
		||||
	VersionStr string
 | 
			
		||||
	VersionNum uint64
 | 
			
		||||
	IsNum      bool
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// NewPRVersion creates a new valid prerelease version
 | 
			
		||||
func NewPRVersion(s string) (PRVersion, error) {
 | 
			
		||||
	if len(s) == 0 {
 | 
			
		||||
		return PRVersion{}, errors.New("Prerelease is empty")
 | 
			
		||||
	}
 | 
			
		||||
	v := PRVersion{}
 | 
			
		||||
	if containsOnly(s, numbers) {
 | 
			
		||||
		if hasLeadingZeroes(s) {
 | 
			
		||||
			return PRVersion{}, fmt.Errorf("Numeric PreRelease version must not contain leading zeroes %q", s)
 | 
			
		||||
		}
 | 
			
		||||
		num, err := strconv.ParseUint(s, 10, 64)
 | 
			
		||||
 | 
			
		||||
		// Might never be hit, but just in case
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			return PRVersion{}, err
 | 
			
		||||
		}
 | 
			
		||||
		v.VersionNum = num
 | 
			
		||||
		v.IsNum = true
 | 
			
		||||
	} else if containsOnly(s, alphanum) {
 | 
			
		||||
		v.VersionStr = s
 | 
			
		||||
		v.IsNum = false
 | 
			
		||||
	} else {
 | 
			
		||||
		return PRVersion{}, fmt.Errorf("Invalid character(s) found in prerelease %q", s)
 | 
			
		||||
	}
 | 
			
		||||
	return v, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// IsNumeric checks if prerelease-version is numeric
 | 
			
		||||
func (v PRVersion) IsNumeric() bool {
 | 
			
		||||
	return v.IsNum
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Compare compares two PreRelease Versions v and o:
 | 
			
		||||
// -1 == v is less than o
 | 
			
		||||
// 0 == v is equal to o
 | 
			
		||||
// 1 == v is greater than o
 | 
			
		||||
func (v PRVersion) Compare(o PRVersion) int {
 | 
			
		||||
	if v.IsNum && !o.IsNum {
 | 
			
		||||
		return -1
 | 
			
		||||
	} else if !v.IsNum && o.IsNum {
 | 
			
		||||
		return 1
 | 
			
		||||
	} else if v.IsNum && o.IsNum {
 | 
			
		||||
		if v.VersionNum == o.VersionNum {
 | 
			
		||||
			return 0
 | 
			
		||||
		} else if v.VersionNum > o.VersionNum {
 | 
			
		||||
			return 1
 | 
			
		||||
		} else {
 | 
			
		||||
			return -1
 | 
			
		||||
		}
 | 
			
		||||
	} else { // both are Alphas
 | 
			
		||||
		if v.VersionStr == o.VersionStr {
 | 
			
		||||
			return 0
 | 
			
		||||
		} else if v.VersionStr > o.VersionStr {
 | 
			
		||||
			return 1
 | 
			
		||||
		} else {
 | 
			
		||||
			return -1
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// PreRelease version to string
 | 
			
		||||
func (v PRVersion) String() string {
 | 
			
		||||
	if v.IsNum {
 | 
			
		||||
		return strconv.FormatUint(v.VersionNum, 10)
 | 
			
		||||
	}
 | 
			
		||||
	return v.VersionStr
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func containsOnly(s string, set string) bool {
 | 
			
		||||
	return strings.IndexFunc(s, func(r rune) bool {
 | 
			
		||||
		return !strings.ContainsRune(set, r)
 | 
			
		||||
	}) == -1
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func hasLeadingZeroes(s string) bool {
 | 
			
		||||
	return len(s) > 1 && s[0] == '0'
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// NewBuildVersion creates a new valid build version
 | 
			
		||||
func NewBuildVersion(s string) (string, error) {
 | 
			
		||||
	if len(s) == 0 {
 | 
			
		||||
		return "", errors.New("Buildversion is empty")
 | 
			
		||||
	}
 | 
			
		||||
	if !containsOnly(s, alphanum) {
 | 
			
		||||
		return "", fmt.Errorf("Invalid character(s) found in build meta data %q", s)
 | 
			
		||||
	}
 | 
			
		||||
	return s, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// FinalizeVersion returns the major, minor and patch number only and discards
 | 
			
		||||
// prerelease and build number.
 | 
			
		||||
func FinalizeVersion(s string) (string, error) {
 | 
			
		||||
	v, err := Parse(s)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return "", err
 | 
			
		||||
	}
 | 
			
		||||
	v.Pre = nil
 | 
			
		||||
	v.Build = nil
 | 
			
		||||
 | 
			
		||||
	finalVer := v.String()
 | 
			
		||||
	return finalVer, nil
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										28
									
								
								vendor/github.com/blang/semver/v4/sort.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										28
									
								
								vendor/github.com/blang/semver/v4/sort.go
									
									
									
										generated
									
									
										vendored
									
									
								
							@@ -1,28 +0,0 @@
 | 
			
		||||
package semver
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"sort"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// Versions represents multiple versions.
 | 
			
		||||
type Versions []Version
 | 
			
		||||
 | 
			
		||||
// Len returns length of version collection
 | 
			
		||||
func (s Versions) Len() int {
 | 
			
		||||
	return len(s)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Swap swaps two versions inside the collection by its indices
 | 
			
		||||
func (s Versions) Swap(i, j int) {
 | 
			
		||||
	s[i], s[j] = s[j], s[i]
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Less checks if version at index i is less than version at index j
 | 
			
		||||
func (s Versions) Less(i, j int) bool {
 | 
			
		||||
	return s[i].LT(s[j])
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Sort sorts a slice of versions
 | 
			
		||||
func Sort(versions []Version) {
 | 
			
		||||
	sort.Sort(Versions(versions))
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										30
									
								
								vendor/github.com/blang/semver/v4/sql.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										30
									
								
								vendor/github.com/blang/semver/v4/sql.go
									
									
									
										generated
									
									
										vendored
									
									
								
							@@ -1,30 +0,0 @@
 | 
			
		||||
package semver
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"database/sql/driver"
 | 
			
		||||
	"fmt"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// Scan implements the database/sql.Scanner interface.
 | 
			
		||||
func (v *Version) Scan(src interface{}) (err error) {
 | 
			
		||||
	var str string
 | 
			
		||||
	switch src := src.(type) {
 | 
			
		||||
	case string:
 | 
			
		||||
		str = src
 | 
			
		||||
	case []byte:
 | 
			
		||||
		str = string(src)
 | 
			
		||||
	default:
 | 
			
		||||
		return fmt.Errorf("version.Scan: cannot convert %T to string", src)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if t, err := Parse(str); err == nil {
 | 
			
		||||
		*v = t
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Value implements the database/sql/driver.Valuer interface.
 | 
			
		||||
func (v Version) Value() (driver.Value, error) {
 | 
			
		||||
	return v.String(), nil
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										40
									
								
								vendor/github.com/prometheus/client_golang/prometheus/collectors/collectors.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										40
									
								
								vendor/github.com/prometheus/client_golang/prometheus/collectors/collectors.go
									
									
									
										generated
									
									
										vendored
									
									
								
							@@ -1,40 +0,0 @@
 | 
			
		||||
// Copyright 2021 The Prometheus Authors
 | 
			
		||||
// 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 collectors provides implementations of prometheus.Collector to
 | 
			
		||||
// conveniently collect process and Go-related metrics.
 | 
			
		||||
package collectors
 | 
			
		||||
 | 
			
		||||
import "github.com/prometheus/client_golang/prometheus"
 | 
			
		||||
 | 
			
		||||
// NewBuildInfoCollector returns a collector collecting a single metric
 | 
			
		||||
// "go_build_info" with the constant value 1 and three labels "path", "version",
 | 
			
		||||
// and "checksum". Their label values contain the main module path, version, and
 | 
			
		||||
// checksum, respectively. The labels will only have meaningful values if the
 | 
			
		||||
// binary is built with Go module support and from source code retrieved from
 | 
			
		||||
// the source repository (rather than the local file system). This is usually
 | 
			
		||||
// accomplished by building from outside of GOPATH, specifying the full address
 | 
			
		||||
// of the main package, e.g. "GO111MODULE=on go run
 | 
			
		||||
// github.com/prometheus/client_golang/examples/random". If built without Go
 | 
			
		||||
// module support, all label values will be "unknown". If built with Go module
 | 
			
		||||
// support but using the source code from the local file system, the "path" will
 | 
			
		||||
// be set appropriately, but "checksum" will be empty and "version" will be
 | 
			
		||||
// "(devel)".
 | 
			
		||||
//
 | 
			
		||||
// This collector uses only the build information for the main module. See
 | 
			
		||||
// https://github.com/povilasv/prommod for an example of a collector for the
 | 
			
		||||
// module dependencies.
 | 
			
		||||
func NewBuildInfoCollector() prometheus.Collector {
 | 
			
		||||
	//nolint:staticcheck // Ignore SA1019 until v2.
 | 
			
		||||
	return prometheus.NewBuildInfoCollector()
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										119
									
								
								vendor/github.com/prometheus/client_golang/prometheus/collectors/dbstats_collector.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										119
									
								
								vendor/github.com/prometheus/client_golang/prometheus/collectors/dbstats_collector.go
									
									
									
										generated
									
									
										vendored
									
									
								
							@@ -1,119 +0,0 @@
 | 
			
		||||
// Copyright 2021 The Prometheus Authors
 | 
			
		||||
// 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 collectors
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"database/sql"
 | 
			
		||||
 | 
			
		||||
	"github.com/prometheus/client_golang/prometheus"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
type dbStatsCollector struct {
 | 
			
		||||
	db *sql.DB
 | 
			
		||||
 | 
			
		||||
	maxOpenConnections *prometheus.Desc
 | 
			
		||||
 | 
			
		||||
	openConnections  *prometheus.Desc
 | 
			
		||||
	inUseConnections *prometheus.Desc
 | 
			
		||||
	idleConnections  *prometheus.Desc
 | 
			
		||||
 | 
			
		||||
	waitCount         *prometheus.Desc
 | 
			
		||||
	waitDuration      *prometheus.Desc
 | 
			
		||||
	maxIdleClosed     *prometheus.Desc
 | 
			
		||||
	maxIdleTimeClosed *prometheus.Desc
 | 
			
		||||
	maxLifetimeClosed *prometheus.Desc
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// NewDBStatsCollector returns a collector that exports metrics about the given *sql.DB.
 | 
			
		||||
// See https://golang.org/pkg/database/sql/#DBStats for more information on stats.
 | 
			
		||||
func NewDBStatsCollector(db *sql.DB, dbName string) prometheus.Collector {
 | 
			
		||||
	fqName := func(name string) string {
 | 
			
		||||
		return "go_sql_" + name
 | 
			
		||||
	}
 | 
			
		||||
	return &dbStatsCollector{
 | 
			
		||||
		db: db,
 | 
			
		||||
		maxOpenConnections: prometheus.NewDesc(
 | 
			
		||||
			fqName("max_open_connections"),
 | 
			
		||||
			"Maximum number of open connections to the database.",
 | 
			
		||||
			nil, prometheus.Labels{"db_name": dbName},
 | 
			
		||||
		),
 | 
			
		||||
		openConnections: prometheus.NewDesc(
 | 
			
		||||
			fqName("open_connections"),
 | 
			
		||||
			"The number of established connections both in use and idle.",
 | 
			
		||||
			nil, prometheus.Labels{"db_name": dbName},
 | 
			
		||||
		),
 | 
			
		||||
		inUseConnections: prometheus.NewDesc(
 | 
			
		||||
			fqName("in_use_connections"),
 | 
			
		||||
			"The number of connections currently in use.",
 | 
			
		||||
			nil, prometheus.Labels{"db_name": dbName},
 | 
			
		||||
		),
 | 
			
		||||
		idleConnections: prometheus.NewDesc(
 | 
			
		||||
			fqName("idle_connections"),
 | 
			
		||||
			"The number of idle connections.",
 | 
			
		||||
			nil, prometheus.Labels{"db_name": dbName},
 | 
			
		||||
		),
 | 
			
		||||
		waitCount: prometheus.NewDesc(
 | 
			
		||||
			fqName("wait_count_total"),
 | 
			
		||||
			"The total number of connections waited for.",
 | 
			
		||||
			nil, prometheus.Labels{"db_name": dbName},
 | 
			
		||||
		),
 | 
			
		||||
		waitDuration: prometheus.NewDesc(
 | 
			
		||||
			fqName("wait_duration_seconds_total"),
 | 
			
		||||
			"The total time blocked waiting for a new connection.",
 | 
			
		||||
			nil, prometheus.Labels{"db_name": dbName},
 | 
			
		||||
		),
 | 
			
		||||
		maxIdleClosed: prometheus.NewDesc(
 | 
			
		||||
			fqName("max_idle_closed_total"),
 | 
			
		||||
			"The total number of connections closed due to SetMaxIdleConns.",
 | 
			
		||||
			nil, prometheus.Labels{"db_name": dbName},
 | 
			
		||||
		),
 | 
			
		||||
		maxIdleTimeClosed: prometheus.NewDesc(
 | 
			
		||||
			fqName("max_idle_time_closed_total"),
 | 
			
		||||
			"The total number of connections closed due to SetConnMaxIdleTime.",
 | 
			
		||||
			nil, prometheus.Labels{"db_name": dbName},
 | 
			
		||||
		),
 | 
			
		||||
		maxLifetimeClosed: prometheus.NewDesc(
 | 
			
		||||
			fqName("max_lifetime_closed_total"),
 | 
			
		||||
			"The total number of connections closed due to SetConnMaxLifetime.",
 | 
			
		||||
			nil, prometheus.Labels{"db_name": dbName},
 | 
			
		||||
		),
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Describe implements Collector.
 | 
			
		||||
func (c *dbStatsCollector) Describe(ch chan<- *prometheus.Desc) {
 | 
			
		||||
	ch <- c.maxOpenConnections
 | 
			
		||||
	ch <- c.openConnections
 | 
			
		||||
	ch <- c.inUseConnections
 | 
			
		||||
	ch <- c.idleConnections
 | 
			
		||||
	ch <- c.waitCount
 | 
			
		||||
	ch <- c.waitDuration
 | 
			
		||||
	ch <- c.maxIdleClosed
 | 
			
		||||
	ch <- c.maxLifetimeClosed
 | 
			
		||||
	ch <- c.maxIdleTimeClosed
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Collect implements Collector.
 | 
			
		||||
func (c *dbStatsCollector) Collect(ch chan<- prometheus.Metric) {
 | 
			
		||||
	stats := c.db.Stats()
 | 
			
		||||
	ch <- prometheus.MustNewConstMetric(c.maxOpenConnections, prometheus.GaugeValue, float64(stats.MaxOpenConnections))
 | 
			
		||||
	ch <- prometheus.MustNewConstMetric(c.openConnections, prometheus.GaugeValue, float64(stats.OpenConnections))
 | 
			
		||||
	ch <- prometheus.MustNewConstMetric(c.inUseConnections, prometheus.GaugeValue, float64(stats.InUse))
 | 
			
		||||
	ch <- prometheus.MustNewConstMetric(c.idleConnections, prometheus.GaugeValue, float64(stats.Idle))
 | 
			
		||||
	ch <- prometheus.MustNewConstMetric(c.waitCount, prometheus.CounterValue, float64(stats.WaitCount))
 | 
			
		||||
	ch <- prometheus.MustNewConstMetric(c.waitDuration, prometheus.CounterValue, stats.WaitDuration.Seconds())
 | 
			
		||||
	ch <- prometheus.MustNewConstMetric(c.maxIdleClosed, prometheus.CounterValue, float64(stats.MaxIdleClosed))
 | 
			
		||||
	ch <- prometheus.MustNewConstMetric(c.maxLifetimeClosed, prometheus.CounterValue, float64(stats.MaxLifetimeClosed))
 | 
			
		||||
	ch <- prometheus.MustNewConstMetric(c.maxIdleTimeClosed, prometheus.CounterValue, float64(stats.MaxIdleTimeClosed))
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										57
									
								
								vendor/github.com/prometheus/client_golang/prometheus/collectors/expvar_collector.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										57
									
								
								vendor/github.com/prometheus/client_golang/prometheus/collectors/expvar_collector.go
									
									
									
										generated
									
									
										vendored
									
									
								
							@@ -1,57 +0,0 @@
 | 
			
		||||
// Copyright 2021 The Prometheus Authors
 | 
			
		||||
// 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 collectors
 | 
			
		||||
 | 
			
		||||
import "github.com/prometheus/client_golang/prometheus"
 | 
			
		||||
 | 
			
		||||
// NewExpvarCollector returns a newly allocated expvar Collector.
 | 
			
		||||
//
 | 
			
		||||
// An expvar Collector collects metrics from the expvar interface. It provides a
 | 
			
		||||
// quick way to expose numeric values that are already exported via expvar as
 | 
			
		||||
// Prometheus metrics. Note that the data models of expvar and Prometheus are
 | 
			
		||||
// fundamentally different, and that the expvar Collector is inherently slower
 | 
			
		||||
// than native Prometheus metrics. Thus, the expvar Collector is probably great
 | 
			
		||||
// for experiments and prototying, but you should seriously consider a more
 | 
			
		||||
// direct implementation of Prometheus metrics for monitoring production
 | 
			
		||||
// systems.
 | 
			
		||||
//
 | 
			
		||||
// The exports map has the following meaning:
 | 
			
		||||
//
 | 
			
		||||
// The keys in the map correspond to expvar keys, i.e. for every expvar key you
 | 
			
		||||
// want to export as Prometheus metric, you need an entry in the exports
 | 
			
		||||
// map. The descriptor mapped to each key describes how to export the expvar
 | 
			
		||||
// value. It defines the name and the help string of the Prometheus metric
 | 
			
		||||
// proxying the expvar value. The type will always be Untyped.
 | 
			
		||||
//
 | 
			
		||||
// For descriptors without variable labels, the expvar value must be a number or
 | 
			
		||||
// a bool. The number is then directly exported as the Prometheus sample
 | 
			
		||||
// value. (For a bool, 'false' translates to 0 and 'true' to 1). Expvar values
 | 
			
		||||
// that are not numbers or bools are silently ignored.
 | 
			
		||||
//
 | 
			
		||||
// If the descriptor has one variable label, the expvar value must be an expvar
 | 
			
		||||
// map. The keys in the expvar map become the various values of the one
 | 
			
		||||
// Prometheus label. The values in the expvar map must be numbers or bools again
 | 
			
		||||
// as above.
 | 
			
		||||
//
 | 
			
		||||
// For descriptors with more than one variable label, the expvar must be a
 | 
			
		||||
// nested expvar map, i.e. where the values of the topmost map are maps again
 | 
			
		||||
// etc. until a depth is reached that corresponds to the number of labels. The
 | 
			
		||||
// leaves of that structure must be numbers or bools as above to serve as the
 | 
			
		||||
// sample values.
 | 
			
		||||
//
 | 
			
		||||
// Anything that does not fit into the scheme above is silently ignored.
 | 
			
		||||
func NewExpvarCollector(exports map[string]*prometheus.Desc) prometheus.Collector {
 | 
			
		||||
	//nolint:staticcheck // Ignore SA1019 until v2.
 | 
			
		||||
	return prometheus.NewExpvarCollector(exports)
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										49
									
								
								vendor/github.com/prometheus/client_golang/prometheus/collectors/go_collector_go116.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										49
									
								
								vendor/github.com/prometheus/client_golang/prometheus/collectors/go_collector_go116.go
									
									
									
										generated
									
									
										vendored
									
									
								
							@@ -1,49 +0,0 @@
 | 
			
		||||
// Copyright 2021 The Prometheus Authors
 | 
			
		||||
// 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 !go1.17
 | 
			
		||||
// +build !go1.17
 | 
			
		||||
 | 
			
		||||
package collectors
 | 
			
		||||
 | 
			
		||||
import "github.com/prometheus/client_golang/prometheus"
 | 
			
		||||
 | 
			
		||||
// NewGoCollector returns a collector that exports metrics about the current Go
 | 
			
		||||
// process. This includes memory stats. To collect those, runtime.ReadMemStats
 | 
			
		||||
// is called. This requires to “stop the world”, which usually only happens for
 | 
			
		||||
// garbage collection (GC). Take the following implications into account when
 | 
			
		||||
// deciding whether to use the Go collector:
 | 
			
		||||
//
 | 
			
		||||
// 1. The performance impact of stopping the world is the more relevant the more
 | 
			
		||||
// frequently metrics are collected. However, with Go1.9 or later the
 | 
			
		||||
// stop-the-world time per metrics collection is very short (~25µs) so that the
 | 
			
		||||
// performance impact will only matter in rare cases. However, with older Go
 | 
			
		||||
// versions, the stop-the-world duration depends on the heap size and can be
 | 
			
		||||
// quite significant (~1.7 ms/GiB as per
 | 
			
		||||
// https://go-review.googlesource.com/c/go/+/34937).
 | 
			
		||||
//
 | 
			
		||||
// 2. During an ongoing GC, nothing else can stop the world. Therefore, if the
 | 
			
		||||
// metrics collection happens to coincide with GC, it will only complete after
 | 
			
		||||
// GC has finished. Usually, GC is fast enough to not cause problems. However,
 | 
			
		||||
// with a very large heap, GC might take multiple seconds, which is enough to
 | 
			
		||||
// cause scrape timeouts in common setups. To avoid this problem, the Go
 | 
			
		||||
// collector will use the memstats from a previous collection if
 | 
			
		||||
// runtime.ReadMemStats takes more than 1s. However, if there are no previously
 | 
			
		||||
// collected memstats, or their collection is more than 5m ago, the collection
 | 
			
		||||
// will block until runtime.ReadMemStats succeeds.
 | 
			
		||||
//
 | 
			
		||||
// NOTE: The problem is solved in Go 1.15, see
 | 
			
		||||
// https://github.com/golang/go/issues/19812 for the related Go issue.
 | 
			
		||||
func NewGoCollector() prometheus.Collector {
 | 
			
		||||
	return prometheus.NewGoCollector()
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										162
									
								
								vendor/github.com/prometheus/client_golang/prometheus/collectors/go_collector_latest.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										162
									
								
								vendor/github.com/prometheus/client_golang/prometheus/collectors/go_collector_latest.go
									
									
									
										generated
									
									
										vendored
									
									
								
							@@ -1,162 +0,0 @@
 | 
			
		||||
// Copyright 2021 The Prometheus Authors
 | 
			
		||||
// 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 go1.17
 | 
			
		||||
// +build go1.17
 | 
			
		||||
 | 
			
		||||
package collectors
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"regexp"
 | 
			
		||||
 | 
			
		||||
	"github.com/prometheus/client_golang/prometheus"
 | 
			
		||||
	"github.com/prometheus/client_golang/prometheus/internal"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
var (
 | 
			
		||||
	// MetricsAll allows all the metrics to be collected from Go runtime.
 | 
			
		||||
	MetricsAll = GoRuntimeMetricsRule{regexp.MustCompile("/.*")}
 | 
			
		||||
	// MetricsGC allows only GC metrics to be collected from Go runtime.
 | 
			
		||||
	// e.g. go_gc_cycles_automatic_gc_cycles_total
 | 
			
		||||
	// NOTE: This does not include new class of "/cpu/classes/gc/..." metrics.
 | 
			
		||||
	// Use custom metric rule to access those.
 | 
			
		||||
	MetricsGC = GoRuntimeMetricsRule{regexp.MustCompile(`^/gc/.*`)}
 | 
			
		||||
	// MetricsMemory allows only memory metrics to be collected from Go runtime.
 | 
			
		||||
	// e.g. go_memory_classes_heap_free_bytes
 | 
			
		||||
	MetricsMemory = GoRuntimeMetricsRule{regexp.MustCompile(`^/memory/.*`)}
 | 
			
		||||
	// MetricsScheduler allows only scheduler metrics to be collected from Go runtime.
 | 
			
		||||
	// e.g. go_sched_goroutines_goroutines
 | 
			
		||||
	MetricsScheduler = GoRuntimeMetricsRule{regexp.MustCompile(`^/sched/.*`)}
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// WithGoCollectorMemStatsMetricsDisabled disables metrics that is gathered in runtime.MemStats structure such as:
 | 
			
		||||
//
 | 
			
		||||
// go_memstats_alloc_bytes
 | 
			
		||||
// go_memstats_alloc_bytes_total
 | 
			
		||||
// go_memstats_sys_bytes
 | 
			
		||||
// go_memstats_lookups_total
 | 
			
		||||
// go_memstats_mallocs_total
 | 
			
		||||
// go_memstats_frees_total
 | 
			
		||||
// go_memstats_heap_alloc_bytes
 | 
			
		||||
// go_memstats_heap_sys_bytes
 | 
			
		||||
// go_memstats_heap_idle_bytes
 | 
			
		||||
// go_memstats_heap_inuse_bytes
 | 
			
		||||
// go_memstats_heap_released_bytes
 | 
			
		||||
// go_memstats_heap_objects
 | 
			
		||||
// go_memstats_stack_inuse_bytes
 | 
			
		||||
// go_memstats_stack_sys_bytes
 | 
			
		||||
// go_memstats_mspan_inuse_bytes
 | 
			
		||||
// go_memstats_mspan_sys_bytes
 | 
			
		||||
// go_memstats_mcache_inuse_bytes
 | 
			
		||||
// go_memstats_mcache_sys_bytes
 | 
			
		||||
// go_memstats_buck_hash_sys_bytes
 | 
			
		||||
// go_memstats_gc_sys_bytes
 | 
			
		||||
// go_memstats_other_sys_bytes
 | 
			
		||||
// go_memstats_next_gc_bytes
 | 
			
		||||
//
 | 
			
		||||
// so the metrics known from pre client_golang v1.12.0,
 | 
			
		||||
//
 | 
			
		||||
// NOTE(bwplotka): The above represents runtime.MemStats statistics, but they are
 | 
			
		||||
// actually implemented using new runtime/metrics package. (except skipped go_memstats_gc_cpu_fraction
 | 
			
		||||
// -- see  https://github.com/prometheus/client_golang/issues/842#issuecomment-861812034 for explanation).
 | 
			
		||||
//
 | 
			
		||||
// Some users might want to disable this on collector level (although you can use scrape relabelling on Prometheus),
 | 
			
		||||
// because similar metrics can be now obtained using WithGoCollectorRuntimeMetrics. Note that the semantics of new
 | 
			
		||||
// metrics might be different, plus the names can be change over time with different Go version.
 | 
			
		||||
//
 | 
			
		||||
// NOTE(bwplotka): Changing metric names can be tedious at times as the alerts, recording rules and dashboards have to be adjusted.
 | 
			
		||||
// The old metrics are also very useful, with many guides and books written about how to interpret them.
 | 
			
		||||
//
 | 
			
		||||
// As a result our recommendation would be to stick with MemStats like metrics and enable other runtime/metrics if you are interested
 | 
			
		||||
// in advanced insights Go provides. See ExampleGoCollector_WithAdvancedGoMetrics.
 | 
			
		||||
func WithGoCollectorMemStatsMetricsDisabled() func(options *internal.GoCollectorOptions) {
 | 
			
		||||
	return func(o *internal.GoCollectorOptions) {
 | 
			
		||||
		o.DisableMemStatsLikeMetrics = true
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// GoRuntimeMetricsRule allow enabling and configuring particular group of runtime/metrics.
 | 
			
		||||
// TODO(bwplotka): Consider adding ability to adjust buckets.
 | 
			
		||||
type GoRuntimeMetricsRule struct {
 | 
			
		||||
	// Matcher represents RE2 expression will match the runtime/metrics from https://golang.bg/src/runtime/metrics/description.go
 | 
			
		||||
	// Use `regexp.MustCompile` or `regexp.Compile` to create this field.
 | 
			
		||||
	Matcher *regexp.Regexp
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// WithGoCollectorRuntimeMetrics allows enabling and configuring particular group of runtime/metrics.
 | 
			
		||||
// See the list of metrics https://golang.bg/src/runtime/metrics/description.go (pick the Go version you use there!).
 | 
			
		||||
// You can use this option in repeated manner, which will add new rules. The order of rules is important, the last rule
 | 
			
		||||
// that matches particular metrics is applied.
 | 
			
		||||
func WithGoCollectorRuntimeMetrics(rules ...GoRuntimeMetricsRule) func(options *internal.GoCollectorOptions) {
 | 
			
		||||
	rs := make([]internal.GoCollectorRule, len(rules))
 | 
			
		||||
	for i, r := range rules {
 | 
			
		||||
		rs[i] = internal.GoCollectorRule{
 | 
			
		||||
			Matcher: r.Matcher,
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return func(o *internal.GoCollectorOptions) {
 | 
			
		||||
		o.RuntimeMetricRules = append(o.RuntimeMetricRules, rs...)
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// WithoutGoCollectorRuntimeMetrics allows disabling group of runtime/metrics that you might have added in WithGoCollectorRuntimeMetrics.
 | 
			
		||||
// It behaves similarly to WithGoCollectorRuntimeMetrics just with deny-list semantics.
 | 
			
		||||
func WithoutGoCollectorRuntimeMetrics(matchers ...*regexp.Regexp) func(options *internal.GoCollectorOptions) {
 | 
			
		||||
	rs := make([]internal.GoCollectorRule, len(matchers))
 | 
			
		||||
	for i, m := range matchers {
 | 
			
		||||
		rs[i] = internal.GoCollectorRule{
 | 
			
		||||
			Matcher: m,
 | 
			
		||||
			Deny:    true,
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return func(o *internal.GoCollectorOptions) {
 | 
			
		||||
		o.RuntimeMetricRules = append(o.RuntimeMetricRules, rs...)
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// GoCollectionOption represents Go collection option flag.
 | 
			
		||||
// Deprecated.
 | 
			
		||||
type GoCollectionOption uint32
 | 
			
		||||
 | 
			
		||||
const (
 | 
			
		||||
	// GoRuntimeMemStatsCollection represents the metrics represented by runtime.MemStats structure.
 | 
			
		||||
	// Deprecated. Use WithGoCollectorMemStatsMetricsDisabled() function to disable those metrics in the collector.
 | 
			
		||||
	GoRuntimeMemStatsCollection GoCollectionOption = 1 << iota
 | 
			
		||||
	// GoRuntimeMetricsCollection is the new set of metrics represented by runtime/metrics package.
 | 
			
		||||
	// Deprecated. Use WithGoCollectorRuntimeMetrics(GoRuntimeMetricsRule{Matcher: regexp.MustCompile("/.*")})
 | 
			
		||||
	// function to enable those metrics in the collector.
 | 
			
		||||
	GoRuntimeMetricsCollection
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// WithGoCollections allows enabling different collections for Go collector on top of base metrics.
 | 
			
		||||
// Deprecated. Use WithGoCollectorRuntimeMetrics() and WithGoCollectorMemStatsMetricsDisabled() instead to control metrics.
 | 
			
		||||
func WithGoCollections(flags GoCollectionOption) func(options *internal.GoCollectorOptions) {
 | 
			
		||||
	return func(options *internal.GoCollectorOptions) {
 | 
			
		||||
		if flags&GoRuntimeMemStatsCollection == 0 {
 | 
			
		||||
			WithGoCollectorMemStatsMetricsDisabled()(options)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if flags&GoRuntimeMetricsCollection != 0 {
 | 
			
		||||
			WithGoCollectorRuntimeMetrics(GoRuntimeMetricsRule{Matcher: regexp.MustCompile("/.*")})(options)
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// NewGoCollector returns a collector that exports metrics about the current Go
 | 
			
		||||
// process using debug.GCStats (base metrics) and runtime/metrics (both in MemStats style and new ones).
 | 
			
		||||
func NewGoCollector(opts ...func(o *internal.GoCollectorOptions)) prometheus.Collector {
 | 
			
		||||
	//nolint:staticcheck // Ignore SA1019 until v2.
 | 
			
		||||
	return prometheus.NewGoCollector(opts...)
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										56
									
								
								vendor/github.com/prometheus/client_golang/prometheus/collectors/process_collector.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										56
									
								
								vendor/github.com/prometheus/client_golang/prometheus/collectors/process_collector.go
									
									
									
										generated
									
									
										vendored
									
									
								
							@@ -1,56 +0,0 @@
 | 
			
		||||
// Copyright 2021 The Prometheus Authors
 | 
			
		||||
// 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 collectors
 | 
			
		||||
 | 
			
		||||
import "github.com/prometheus/client_golang/prometheus"
 | 
			
		||||
 | 
			
		||||
// ProcessCollectorOpts defines the behavior of a process metrics collector
 | 
			
		||||
// created with NewProcessCollector.
 | 
			
		||||
type ProcessCollectorOpts struct {
 | 
			
		||||
	// PidFn returns the PID of the process the collector collects metrics
 | 
			
		||||
	// for. It is called upon each collection. By default, the PID of the
 | 
			
		||||
	// current process is used, as determined on construction time by
 | 
			
		||||
	// calling os.Getpid().
 | 
			
		||||
	PidFn func() (int, error)
 | 
			
		||||
	// If non-empty, each of the collected metrics is prefixed by the
 | 
			
		||||
	// provided string and an underscore ("_").
 | 
			
		||||
	Namespace string
 | 
			
		||||
	// If true, any error encountered during collection is reported as an
 | 
			
		||||
	// invalid metric (see NewInvalidMetric). Otherwise, errors are ignored
 | 
			
		||||
	// and the collected metrics will be incomplete. (Possibly, no metrics
 | 
			
		||||
	// will be collected at all.) While that's usually not desired, it is
 | 
			
		||||
	// appropriate for the common "mix-in" of process metrics, where process
 | 
			
		||||
	// metrics are nice to have, but failing to collect them should not
 | 
			
		||||
	// disrupt the collection of the remaining metrics.
 | 
			
		||||
	ReportErrors bool
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// NewProcessCollector returns a collector which exports the current state of
 | 
			
		||||
// process metrics including CPU, memory and file descriptor usage as well as
 | 
			
		||||
// the process start time. The detailed behavior is defined by the provided
 | 
			
		||||
// ProcessCollectorOpts. The zero value of ProcessCollectorOpts creates a
 | 
			
		||||
// collector for the current process with an empty namespace string and no error
 | 
			
		||||
// reporting.
 | 
			
		||||
//
 | 
			
		||||
// The collector only works on operating systems with a Linux-style proc
 | 
			
		||||
// filesystem and on Microsoft Windows. On other operating systems, it will not
 | 
			
		||||
// collect any metrics.
 | 
			
		||||
func NewProcessCollector(opts ProcessCollectorOpts) prometheus.Collector {
 | 
			
		||||
	//nolint:staticcheck // Ignore SA1019 until v2.
 | 
			
		||||
	return prometheus.NewProcessCollector(prometheus.ProcessCollectorOpts{
 | 
			
		||||
		PidFn:        opts.PidFn,
 | 
			
		||||
		Namespace:    opts.Namespace,
 | 
			
		||||
		ReportErrors: opts.ReportErrors,
 | 
			
		||||
	})
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										1586
									
								
								vendor/github.com/prometheus/client_model/go/metrics.pb.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										1586
									
								
								vendor/github.com/prometheus/client_model/go/metrics.pb.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										5
									
								
								vendor/github.com/prometheus/common/expfmt/decode.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										5
									
								
								vendor/github.com/prometheus/common/expfmt/decode.go
									
									
									
										generated
									
									
										vendored
									
									
								
							@@ -132,7 +132,10 @@ func (d *textDecoder) Decode(v *dto.MetricFamily) error {
 | 
			
		||||
	}
 | 
			
		||||
	// Pick off one MetricFamily per Decode until there's nothing left.
 | 
			
		||||
	for key, fam := range d.fams {
 | 
			
		||||
		*v = *fam
 | 
			
		||||
		v.Name = fam.Name
 | 
			
		||||
		v.Help = fam.Help
 | 
			
		||||
		v.Type = fam.Type
 | 
			
		||||
		v.Metric = fam.Metric
 | 
			
		||||
		delete(d.fams, key)
 | 
			
		||||
		return nil
 | 
			
		||||
	}
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										13
									
								
								vendor/github.com/prometheus/common/expfmt/encode.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										13
									
								
								vendor/github.com/prometheus/common/expfmt/encode.go
									
									
									
										generated
									
									
										vendored
									
									
								
							@@ -18,9 +18,9 @@ import (
 | 
			
		||||
	"io"
 | 
			
		||||
	"net/http"
 | 
			
		||||
 | 
			
		||||
	"github.com/golang/protobuf/proto" //nolint:staticcheck // Ignore SA1019. Need to keep deprecated package for compatibility.
 | 
			
		||||
	"github.com/matttproud/golang_protobuf_extensions/pbutil"
 | 
			
		||||
	"github.com/prometheus/common/internal/bitbucket.org/ww/goautoneg"
 | 
			
		||||
	"google.golang.org/protobuf/encoding/prototext"
 | 
			
		||||
 | 
			
		||||
	dto "github.com/prometheus/client_model/go"
 | 
			
		||||
)
 | 
			
		||||
@@ -99,8 +99,11 @@ func NegotiateIncludingOpenMetrics(h http.Header) Format {
 | 
			
		||||
		if ac.Type == "text" && ac.SubType == "plain" && (ver == TextVersion || ver == "") {
 | 
			
		||||
			return FmtText
 | 
			
		||||
		}
 | 
			
		||||
		if ac.Type+"/"+ac.SubType == OpenMetricsType && (ver == OpenMetricsVersion || ver == "") {
 | 
			
		||||
			return FmtOpenMetrics
 | 
			
		||||
		if ac.Type+"/"+ac.SubType == OpenMetricsType && (ver == OpenMetricsVersion_0_0_1 || ver == OpenMetricsVersion_1_0_0 || ver == "") {
 | 
			
		||||
			if ver == OpenMetricsVersion_1_0_0 {
 | 
			
		||||
				return FmtOpenMetrics_1_0_0
 | 
			
		||||
			}
 | 
			
		||||
			return FmtOpenMetrics_0_0_1
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	return FmtText
 | 
			
		||||
@@ -133,7 +136,7 @@ func NewEncoder(w io.Writer, format Format) Encoder {
 | 
			
		||||
	case FmtProtoText:
 | 
			
		||||
		return encoderCloser{
 | 
			
		||||
			encode: func(v *dto.MetricFamily) error {
 | 
			
		||||
				_, err := fmt.Fprintln(w, proto.MarshalTextString(v))
 | 
			
		||||
				_, err := fmt.Fprintln(w, prototext.Format(v))
 | 
			
		||||
				return err
 | 
			
		||||
			},
 | 
			
		||||
			close: func() error { return nil },
 | 
			
		||||
@@ -146,7 +149,7 @@ func NewEncoder(w io.Writer, format Format) Encoder {
 | 
			
		||||
			},
 | 
			
		||||
			close: func() error { return nil },
 | 
			
		||||
		}
 | 
			
		||||
	case FmtOpenMetrics:
 | 
			
		||||
	case FmtOpenMetrics_0_0_1, FmtOpenMetrics_1_0_0:
 | 
			
		||||
		return encoderCloser{
 | 
			
		||||
			encode: func(v *dto.MetricFamily) error {
 | 
			
		||||
				_, err := MetricFamilyToOpenMetrics(w, v)
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										26
									
								
								vendor/github.com/prometheus/common/expfmt/expfmt.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										26
									
								
								vendor/github.com/prometheus/common/expfmt/expfmt.go
									
									
									
										generated
									
									
										vendored
									
									
								
							@@ -19,20 +19,22 @@ type Format string
 | 
			
		||||
 | 
			
		||||
// Constants to assemble the Content-Type values for the different wire protocols.
 | 
			
		||||
const (
 | 
			
		||||
	TextVersion        = "0.0.4"
 | 
			
		||||
	ProtoType          = `application/vnd.google.protobuf`
 | 
			
		||||
	ProtoProtocol      = `io.prometheus.client.MetricFamily`
 | 
			
		||||
	ProtoFmt           = ProtoType + "; proto=" + ProtoProtocol + ";"
 | 
			
		||||
	OpenMetricsType    = `application/openmetrics-text`
 | 
			
		||||
	OpenMetricsVersion = "0.0.1"
 | 
			
		||||
	TextVersion              = "0.0.4"
 | 
			
		||||
	ProtoType                = `application/vnd.google.protobuf`
 | 
			
		||||
	ProtoProtocol            = `io.prometheus.client.MetricFamily`
 | 
			
		||||
	ProtoFmt                 = ProtoType + "; proto=" + ProtoProtocol + ";"
 | 
			
		||||
	OpenMetricsType          = `application/openmetrics-text`
 | 
			
		||||
	OpenMetricsVersion_0_0_1 = "0.0.1"
 | 
			
		||||
	OpenMetricsVersion_1_0_0 = "1.0.0"
 | 
			
		||||
 | 
			
		||||
	// The Content-Type values for the different wire protocols.
 | 
			
		||||
	FmtUnknown      Format = `<unknown>`
 | 
			
		||||
	FmtText         Format = `text/plain; version=` + TextVersion + `; charset=utf-8`
 | 
			
		||||
	FmtProtoDelim   Format = ProtoFmt + ` encoding=delimited`
 | 
			
		||||
	FmtProtoText    Format = ProtoFmt + ` encoding=text`
 | 
			
		||||
	FmtProtoCompact Format = ProtoFmt + ` encoding=compact-text`
 | 
			
		||||
	FmtOpenMetrics  Format = OpenMetricsType + `; version=` + OpenMetricsVersion + `; charset=utf-8`
 | 
			
		||||
	FmtUnknown           Format = `<unknown>`
 | 
			
		||||
	FmtText              Format = `text/plain; version=` + TextVersion + `; charset=utf-8`
 | 
			
		||||
	FmtProtoDelim        Format = ProtoFmt + ` encoding=delimited`
 | 
			
		||||
	FmtProtoText         Format = ProtoFmt + ` encoding=text`
 | 
			
		||||
	FmtProtoCompact      Format = ProtoFmt + ` encoding=compact-text`
 | 
			
		||||
	FmtOpenMetrics_1_0_0 Format = OpenMetricsType + `; version=` + OpenMetricsVersion_1_0_0 + `; charset=utf-8`
 | 
			
		||||
	FmtOpenMetrics_0_0_1 Format = OpenMetricsType + `; version=` + OpenMetricsVersion_0_0_1 + `; charset=utf-8`
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
const (
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										2
									
								
								vendor/github.com/prometheus/common/expfmt/text_parse.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								vendor/github.com/prometheus/common/expfmt/text_parse.go
									
									
									
										generated
									
									
										vendored
									
									
								
							@@ -24,8 +24,8 @@ import (
 | 
			
		||||
 | 
			
		||||
	dto "github.com/prometheus/client_model/go"
 | 
			
		||||
 | 
			
		||||
	"github.com/golang/protobuf/proto" //nolint:staticcheck // Ignore SA1019. Need to keep deprecated package for compatibility.
 | 
			
		||||
	"github.com/prometheus/common/model"
 | 
			
		||||
	"google.golang.org/protobuf/proto"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// A stateFn is a function that represents a state in a state machine. By
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										2
									
								
								vendor/github.com/spf13/pflag/.gitignore
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								vendor/github.com/spf13/pflag/.gitignore
									
									
									
										generated
									
									
										vendored
									
									
								
							@@ -1,2 +0,0 @@
 | 
			
		||||
.idea/*
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										22
									
								
								vendor/github.com/spf13/pflag/.travis.yml
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										22
									
								
								vendor/github.com/spf13/pflag/.travis.yml
									
									
									
										generated
									
									
										vendored
									
									
								
							@@ -1,22 +0,0 @@
 | 
			
		||||
sudo: false
 | 
			
		||||
 | 
			
		||||
language: go
 | 
			
		||||
 | 
			
		||||
go:
 | 
			
		||||
  - 1.9.x
 | 
			
		||||
  - 1.10.x
 | 
			
		||||
  - 1.11.x
 | 
			
		||||
  - tip
 | 
			
		||||
 | 
			
		||||
matrix:
 | 
			
		||||
  allow_failures:
 | 
			
		||||
    - go: tip
 | 
			
		||||
 | 
			
		||||
install:
 | 
			
		||||
  - go get golang.org/x/lint/golint
 | 
			
		||||
  - export PATH=$GOPATH/bin:$PATH
 | 
			
		||||
  - go install ./...
 | 
			
		||||
 | 
			
		||||
script:
 | 
			
		||||
  - verify/all.sh -v
 | 
			
		||||
  - go test ./...
 | 
			
		||||
							
								
								
									
										28
									
								
								vendor/github.com/spf13/pflag/LICENSE
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										28
									
								
								vendor/github.com/spf13/pflag/LICENSE
									
									
									
										generated
									
									
										vendored
									
									
								
							@@ -1,28 +0,0 @@
 | 
			
		||||
Copyright (c) 2012 Alex Ogier. All rights reserved.
 | 
			
		||||
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.
 | 
			
		||||
							
								
								
									
										296
									
								
								vendor/github.com/spf13/pflag/README.md
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										296
									
								
								vendor/github.com/spf13/pflag/README.md
									
									
									
										generated
									
									
										vendored
									
									
								
							@@ -1,296 +0,0 @@
 | 
			
		||||
[](https://travis-ci.org/spf13/pflag)
 | 
			
		||||
[](https://goreportcard.com/report/github.com/spf13/pflag)
 | 
			
		||||
[](https://godoc.org/github.com/spf13/pflag)
 | 
			
		||||
 | 
			
		||||
## Description
 | 
			
		||||
 | 
			
		||||
pflag is a drop-in replacement for Go's flag package, implementing
 | 
			
		||||
POSIX/GNU-style --flags.
 | 
			
		||||
 | 
			
		||||
pflag is compatible with the [GNU extensions to the POSIX recommendations
 | 
			
		||||
for command-line options][1]. For a more precise description, see the
 | 
			
		||||
"Command-line flag syntax" section below.
 | 
			
		||||
 | 
			
		||||
[1]: http://www.gnu.org/software/libc/manual/html_node/Argument-Syntax.html
 | 
			
		||||
 | 
			
		||||
pflag is available under the same style of BSD license as the Go language,
 | 
			
		||||
which can be found in the LICENSE file.
 | 
			
		||||
 | 
			
		||||
## Installation
 | 
			
		||||
 | 
			
		||||
pflag is available using the standard `go get` command.
 | 
			
		||||
 | 
			
		||||
Install by running:
 | 
			
		||||
 | 
			
		||||
    go get github.com/spf13/pflag
 | 
			
		||||
 | 
			
		||||
Run tests by running:
 | 
			
		||||
 | 
			
		||||
    go test github.com/spf13/pflag
 | 
			
		||||
 | 
			
		||||
## Usage
 | 
			
		||||
 | 
			
		||||
pflag is a drop-in replacement of Go's native flag package. If you import
 | 
			
		||||
pflag under the name "flag" then all code should continue to function
 | 
			
		||||
with no changes.
 | 
			
		||||
 | 
			
		||||
``` go
 | 
			
		||||
import flag "github.com/spf13/pflag"
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
There is one exception to this: if you directly instantiate the Flag struct
 | 
			
		||||
there is one more field "Shorthand" that you will need to set.
 | 
			
		||||
Most code never instantiates this struct directly, and instead uses
 | 
			
		||||
functions such as String(), BoolVar(), and Var(), and is therefore
 | 
			
		||||
unaffected.
 | 
			
		||||
 | 
			
		||||
Define flags using flag.String(), Bool(), Int(), etc.
 | 
			
		||||
 | 
			
		||||
This declares an integer flag, -flagname, stored in the pointer ip, with type *int.
 | 
			
		||||
 | 
			
		||||
``` go
 | 
			
		||||
var ip *int = flag.Int("flagname", 1234, "help message for flagname")
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
If you like, you can bind the flag to a variable using the Var() functions.
 | 
			
		||||
 | 
			
		||||
``` go
 | 
			
		||||
var flagvar int
 | 
			
		||||
func init() {
 | 
			
		||||
    flag.IntVar(&flagvar, "flagname", 1234, "help message for flagname")
 | 
			
		||||
}
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
Or you can create custom flags that satisfy the Value interface (with
 | 
			
		||||
pointer receivers) and couple them to flag parsing by
 | 
			
		||||
 | 
			
		||||
``` go
 | 
			
		||||
flag.Var(&flagVal, "name", "help message for flagname")
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
For such flags, the default value is just the initial value of the variable.
 | 
			
		||||
 | 
			
		||||
After all flags are defined, call
 | 
			
		||||
 | 
			
		||||
``` go
 | 
			
		||||
flag.Parse()
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
to parse the command line into the defined flags.
 | 
			
		||||
 | 
			
		||||
Flags may then be used directly. If you're using the flags themselves,
 | 
			
		||||
they are all pointers; if you bind to variables, they're values.
 | 
			
		||||
 | 
			
		||||
``` go
 | 
			
		||||
fmt.Println("ip has value ", *ip)
 | 
			
		||||
fmt.Println("flagvar has value ", flagvar)
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
There are helper functions available to get the value stored in a Flag if you have a FlagSet but find
 | 
			
		||||
it difficult to keep up with all of the pointers in your code.
 | 
			
		||||
If you have a pflag.FlagSet with a flag called 'flagname' of type int you
 | 
			
		||||
can use GetInt() to get the int value. But notice that 'flagname' must exist
 | 
			
		||||
and it must be an int. GetString("flagname") will fail.
 | 
			
		||||
 | 
			
		||||
``` go
 | 
			
		||||
i, err := flagset.GetInt("flagname")
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
After parsing, the arguments after the flag are available as the
 | 
			
		||||
slice flag.Args() or individually as flag.Arg(i).
 | 
			
		||||
The arguments are indexed from 0 through flag.NArg()-1.
 | 
			
		||||
 | 
			
		||||
The pflag package also defines some new functions that are not in flag,
 | 
			
		||||
that give one-letter shorthands for flags. You can use these by appending
 | 
			
		||||
'P' to the name of any function that defines a flag.
 | 
			
		||||
 | 
			
		||||
``` go
 | 
			
		||||
var ip = flag.IntP("flagname", "f", 1234, "help message")
 | 
			
		||||
var flagvar bool
 | 
			
		||||
func init() {
 | 
			
		||||
	flag.BoolVarP(&flagvar, "boolname", "b", true, "help message")
 | 
			
		||||
}
 | 
			
		||||
flag.VarP(&flagVal, "varname", "v", "help message")
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
Shorthand letters can be used with single dashes on the command line.
 | 
			
		||||
Boolean shorthand flags can be combined with other shorthand flags.
 | 
			
		||||
 | 
			
		||||
The default set of command-line flags is controlled by
 | 
			
		||||
top-level functions.  The FlagSet type allows one to define
 | 
			
		||||
independent sets of flags, such as to implement subcommands
 | 
			
		||||
in a command-line interface. The methods of FlagSet are
 | 
			
		||||
analogous to the top-level functions for the command-line
 | 
			
		||||
flag set.
 | 
			
		||||
 | 
			
		||||
## Setting no option default values for flags
 | 
			
		||||
 | 
			
		||||
After you create a flag it is possible to set the pflag.NoOptDefVal for
 | 
			
		||||
the given flag. Doing this changes the meaning of the flag slightly. If
 | 
			
		||||
a flag has a NoOptDefVal and the flag is set on the command line without
 | 
			
		||||
an option the flag will be set to the NoOptDefVal. For example given:
 | 
			
		||||
 | 
			
		||||
``` go
 | 
			
		||||
var ip = flag.IntP("flagname", "f", 1234, "help message")
 | 
			
		||||
flag.Lookup("flagname").NoOptDefVal = "4321"
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
Would result in something like
 | 
			
		||||
 | 
			
		||||
| Parsed Arguments | Resulting Value |
 | 
			
		||||
| -------------    | -------------   |
 | 
			
		||||
| --flagname=1357  | ip=1357         |
 | 
			
		||||
| --flagname       | ip=4321         |
 | 
			
		||||
| [nothing]        | ip=1234         |
 | 
			
		||||
 | 
			
		||||
## Command line flag syntax
 | 
			
		||||
 | 
			
		||||
```
 | 
			
		||||
--flag    // boolean flags, or flags with no option default values
 | 
			
		||||
--flag x  // only on flags without a default value
 | 
			
		||||
--flag=x
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
Unlike the flag package, a single dash before an option means something
 | 
			
		||||
different than a double dash. Single dashes signify a series of shorthand
 | 
			
		||||
letters for flags. All but the last shorthand letter must be boolean flags
 | 
			
		||||
or a flag with a default value
 | 
			
		||||
 | 
			
		||||
```
 | 
			
		||||
// boolean or flags where the 'no option default value' is set
 | 
			
		||||
-f
 | 
			
		||||
-f=true
 | 
			
		||||
-abc
 | 
			
		||||
but
 | 
			
		||||
-b true is INVALID
 | 
			
		||||
 | 
			
		||||
// non-boolean and flags without a 'no option default value'
 | 
			
		||||
-n 1234
 | 
			
		||||
-n=1234
 | 
			
		||||
-n1234
 | 
			
		||||
 | 
			
		||||
// mixed
 | 
			
		||||
-abcs "hello"
 | 
			
		||||
-absd="hello"
 | 
			
		||||
-abcs1234
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
Flag parsing stops after the terminator "--". Unlike the flag package,
 | 
			
		||||
flags can be interspersed with arguments anywhere on the command line
 | 
			
		||||
before this terminator.
 | 
			
		||||
 | 
			
		||||
Integer flags accept 1234, 0664, 0x1234 and may be negative.
 | 
			
		||||
Boolean flags (in their long form) accept 1, 0, t, f, true, false,
 | 
			
		||||
TRUE, FALSE, True, False.
 | 
			
		||||
Duration flags accept any input valid for time.ParseDuration.
 | 
			
		||||
 | 
			
		||||
## Mutating or "Normalizing" Flag names
 | 
			
		||||
 | 
			
		||||
It is possible to set a custom flag name 'normalization function.' It allows flag names to be mutated both when created in the code and when used on the command line to some 'normalized' form. The 'normalized' form is used for comparison. Two examples of using the custom normalization func follow.
 | 
			
		||||
 | 
			
		||||
**Example #1**: You want -, _, and . in flags to compare the same. aka --my-flag == --my_flag == --my.flag
 | 
			
		||||
 | 
			
		||||
``` go
 | 
			
		||||
func wordSepNormalizeFunc(f *pflag.FlagSet, name string) pflag.NormalizedName {
 | 
			
		||||
	from := []string{"-", "_"}
 | 
			
		||||
	to := "."
 | 
			
		||||
	for _, sep := range from {
 | 
			
		||||
		name = strings.Replace(name, sep, to, -1)
 | 
			
		||||
	}
 | 
			
		||||
	return pflag.NormalizedName(name)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
myFlagSet.SetNormalizeFunc(wordSepNormalizeFunc)
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
**Example #2**: You want to alias two flags. aka --old-flag-name == --new-flag-name
 | 
			
		||||
 | 
			
		||||
``` go
 | 
			
		||||
func aliasNormalizeFunc(f *pflag.FlagSet, name string) pflag.NormalizedName {
 | 
			
		||||
	switch name {
 | 
			
		||||
	case "old-flag-name":
 | 
			
		||||
		name = "new-flag-name"
 | 
			
		||||
		break
 | 
			
		||||
	}
 | 
			
		||||
	return pflag.NormalizedName(name)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
myFlagSet.SetNormalizeFunc(aliasNormalizeFunc)
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
## Deprecating a flag or its shorthand
 | 
			
		||||
It is possible to deprecate a flag, or just its shorthand. Deprecating a flag/shorthand hides it from help text and prints a usage message when the deprecated flag/shorthand is used.
 | 
			
		||||
 | 
			
		||||
**Example #1**: You want to deprecate a flag named "badflag" as well as inform the users what flag they should use instead.
 | 
			
		||||
```go
 | 
			
		||||
// deprecate a flag by specifying its name and a usage message
 | 
			
		||||
flags.MarkDeprecated("badflag", "please use --good-flag instead")
 | 
			
		||||
```
 | 
			
		||||
This hides "badflag" from help text, and prints `Flag --badflag has been deprecated, please use --good-flag instead` when "badflag" is used.
 | 
			
		||||
 | 
			
		||||
**Example #2**: You want to keep a flag name "noshorthandflag" but deprecate its shortname "n".
 | 
			
		||||
```go
 | 
			
		||||
// deprecate a flag shorthand by specifying its flag name and a usage message
 | 
			
		||||
flags.MarkShorthandDeprecated("noshorthandflag", "please use --noshorthandflag only")
 | 
			
		||||
```
 | 
			
		||||
This hides the shortname "n" from help text, and prints `Flag shorthand -n has been deprecated, please use --noshorthandflag only` when the shorthand "n" is used.
 | 
			
		||||
 | 
			
		||||
Note that usage message is essential here, and it should not be empty.
 | 
			
		||||
 | 
			
		||||
## Hidden flags
 | 
			
		||||
It is possible to mark a flag as hidden, meaning it will still function as normal, however will not show up in usage/help text.
 | 
			
		||||
 | 
			
		||||
**Example**: You have a flag named "secretFlag" that you need for internal use only and don't want it showing up in help text, or for its usage text to be available.
 | 
			
		||||
```go
 | 
			
		||||
// hide a flag by specifying its name
 | 
			
		||||
flags.MarkHidden("secretFlag")
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
## Disable sorting of flags
 | 
			
		||||
`pflag` allows you to disable sorting of flags for help and usage message.
 | 
			
		||||
 | 
			
		||||
**Example**:
 | 
			
		||||
```go
 | 
			
		||||
flags.BoolP("verbose", "v", false, "verbose output")
 | 
			
		||||
flags.String("coolflag", "yeaah", "it's really cool flag")
 | 
			
		||||
flags.Int("usefulflag", 777, "sometimes it's very useful")
 | 
			
		||||
flags.SortFlags = false
 | 
			
		||||
flags.PrintDefaults()
 | 
			
		||||
```
 | 
			
		||||
**Output**:
 | 
			
		||||
```
 | 
			
		||||
  -v, --verbose           verbose output
 | 
			
		||||
      --coolflag string   it's really cool flag (default "yeaah")
 | 
			
		||||
      --usefulflag int    sometimes it's very useful (default 777)
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
## Supporting Go flags when using pflag
 | 
			
		||||
In order to support flags defined using Go's `flag` package, they must be added to the `pflag` flagset. This is usually necessary
 | 
			
		||||
to support flags defined by third-party dependencies (e.g. `golang/glog`).
 | 
			
		||||
 | 
			
		||||
**Example**: You want to add the Go flags to the `CommandLine` flagset
 | 
			
		||||
```go
 | 
			
		||||
import (
 | 
			
		||||
	goflag "flag"
 | 
			
		||||
	flag "github.com/spf13/pflag"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
var ip *int = flag.Int("flagname", 1234, "help message for flagname")
 | 
			
		||||
 | 
			
		||||
func main() {
 | 
			
		||||
	flag.CommandLine.AddGoFlagSet(goflag.CommandLine)
 | 
			
		||||
	flag.Parse()
 | 
			
		||||
}
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
## More info
 | 
			
		||||
 | 
			
		||||
You can see the full reference documentation of the pflag package
 | 
			
		||||
[at godoc.org][3], or through go's standard documentation system by
 | 
			
		||||
running `godoc -http=:6060` and browsing to
 | 
			
		||||
[http://localhost:6060/pkg/github.com/spf13/pflag][2] after
 | 
			
		||||
installation.
 | 
			
		||||
 | 
			
		||||
[2]: http://localhost:6060/pkg/github.com/spf13/pflag
 | 
			
		||||
[3]: http://godoc.org/github.com/spf13/pflag
 | 
			
		||||
							
								
								
									
										94
									
								
								vendor/github.com/spf13/pflag/bool.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										94
									
								
								vendor/github.com/spf13/pflag/bool.go
									
									
									
										generated
									
									
										vendored
									
									
								
							@@ -1,94 +0,0 @@
 | 
			
		||||
package pflag
 | 
			
		||||
 | 
			
		||||
import "strconv"
 | 
			
		||||
 | 
			
		||||
// optional interface to indicate boolean flags that can be
 | 
			
		||||
// supplied without "=value" text
 | 
			
		||||
type boolFlag interface {
 | 
			
		||||
	Value
 | 
			
		||||
	IsBoolFlag() bool
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// -- bool Value
 | 
			
		||||
type boolValue bool
 | 
			
		||||
 | 
			
		||||
func newBoolValue(val bool, p *bool) *boolValue {
 | 
			
		||||
	*p = val
 | 
			
		||||
	return (*boolValue)(p)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (b *boolValue) Set(s string) error {
 | 
			
		||||
	v, err := strconv.ParseBool(s)
 | 
			
		||||
	*b = boolValue(v)
 | 
			
		||||
	return err
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (b *boolValue) Type() string {
 | 
			
		||||
	return "bool"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (b *boolValue) String() string { return strconv.FormatBool(bool(*b)) }
 | 
			
		||||
 | 
			
		||||
func (b *boolValue) IsBoolFlag() bool { return true }
 | 
			
		||||
 | 
			
		||||
func boolConv(sval string) (interface{}, error) {
 | 
			
		||||
	return strconv.ParseBool(sval)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// GetBool return the bool value of a flag with the given name
 | 
			
		||||
func (f *FlagSet) GetBool(name string) (bool, error) {
 | 
			
		||||
	val, err := f.getFlagType(name, "bool", boolConv)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return false, err
 | 
			
		||||
	}
 | 
			
		||||
	return val.(bool), nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// BoolVar defines a bool flag with specified name, default value, and usage string.
 | 
			
		||||
// The argument p points to a bool variable in which to store the value of the flag.
 | 
			
		||||
func (f *FlagSet) BoolVar(p *bool, name string, value bool, usage string) {
 | 
			
		||||
	f.BoolVarP(p, name, "", value, usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// BoolVarP is like BoolVar, but accepts a shorthand letter that can be used after a single dash.
 | 
			
		||||
func (f *FlagSet) BoolVarP(p *bool, name, shorthand string, value bool, usage string) {
 | 
			
		||||
	flag := f.VarPF(newBoolValue(value, p), name, shorthand, usage)
 | 
			
		||||
	flag.NoOptDefVal = "true"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// BoolVar defines a bool flag with specified name, default value, and usage string.
 | 
			
		||||
// The argument p points to a bool variable in which to store the value of the flag.
 | 
			
		||||
func BoolVar(p *bool, name string, value bool, usage string) {
 | 
			
		||||
	BoolVarP(p, name, "", value, usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// BoolVarP is like BoolVar, but accepts a shorthand letter that can be used after a single dash.
 | 
			
		||||
func BoolVarP(p *bool, name, shorthand string, value bool, usage string) {
 | 
			
		||||
	flag := CommandLine.VarPF(newBoolValue(value, p), name, shorthand, usage)
 | 
			
		||||
	flag.NoOptDefVal = "true"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Bool defines a bool flag with specified name, default value, and usage string.
 | 
			
		||||
// The return value is the address of a bool variable that stores the value of the flag.
 | 
			
		||||
func (f *FlagSet) Bool(name string, value bool, usage string) *bool {
 | 
			
		||||
	return f.BoolP(name, "", value, usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// BoolP is like Bool, but accepts a shorthand letter that can be used after a single dash.
 | 
			
		||||
func (f *FlagSet) BoolP(name, shorthand string, value bool, usage string) *bool {
 | 
			
		||||
	p := new(bool)
 | 
			
		||||
	f.BoolVarP(p, name, shorthand, value, usage)
 | 
			
		||||
	return p
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Bool defines a bool flag with specified name, default value, and usage string.
 | 
			
		||||
// The return value is the address of a bool variable that stores the value of the flag.
 | 
			
		||||
func Bool(name string, value bool, usage string) *bool {
 | 
			
		||||
	return BoolP(name, "", value, usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// BoolP is like Bool, but accepts a shorthand letter that can be used after a single dash.
 | 
			
		||||
func BoolP(name, shorthand string, value bool, usage string) *bool {
 | 
			
		||||
	b := CommandLine.BoolP(name, shorthand, value, usage)
 | 
			
		||||
	return b
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										185
									
								
								vendor/github.com/spf13/pflag/bool_slice.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										185
									
								
								vendor/github.com/spf13/pflag/bool_slice.go
									
									
									
										generated
									
									
										vendored
									
									
								
							@@ -1,185 +0,0 @@
 | 
			
		||||
package pflag
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"io"
 | 
			
		||||
	"strconv"
 | 
			
		||||
	"strings"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// -- boolSlice Value
 | 
			
		||||
type boolSliceValue struct {
 | 
			
		||||
	value   *[]bool
 | 
			
		||||
	changed bool
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func newBoolSliceValue(val []bool, p *[]bool) *boolSliceValue {
 | 
			
		||||
	bsv := new(boolSliceValue)
 | 
			
		||||
	bsv.value = p
 | 
			
		||||
	*bsv.value = val
 | 
			
		||||
	return bsv
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Set converts, and assigns, the comma-separated boolean argument string representation as the []bool value of this flag.
 | 
			
		||||
// If Set is called on a flag that already has a []bool assigned, the newly converted values will be appended.
 | 
			
		||||
func (s *boolSliceValue) Set(val string) error {
 | 
			
		||||
 | 
			
		||||
	// remove all quote characters
 | 
			
		||||
	rmQuote := strings.NewReplacer(`"`, "", `'`, "", "`", "")
 | 
			
		||||
 | 
			
		||||
	// read flag arguments with CSV parser
 | 
			
		||||
	boolStrSlice, err := readAsCSV(rmQuote.Replace(val))
 | 
			
		||||
	if err != nil && err != io.EOF {
 | 
			
		||||
		return err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// parse boolean values into slice
 | 
			
		||||
	out := make([]bool, 0, len(boolStrSlice))
 | 
			
		||||
	for _, boolStr := range boolStrSlice {
 | 
			
		||||
		b, err := strconv.ParseBool(strings.TrimSpace(boolStr))
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			return err
 | 
			
		||||
		}
 | 
			
		||||
		out = append(out, b)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if !s.changed {
 | 
			
		||||
		*s.value = out
 | 
			
		||||
	} else {
 | 
			
		||||
		*s.value = append(*s.value, out...)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	s.changed = true
 | 
			
		||||
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Type returns a string that uniquely represents this flag's type.
 | 
			
		||||
func (s *boolSliceValue) Type() string {
 | 
			
		||||
	return "boolSlice"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// String defines a "native" format for this boolean slice flag value.
 | 
			
		||||
func (s *boolSliceValue) String() string {
 | 
			
		||||
 | 
			
		||||
	boolStrSlice := make([]string, len(*s.value))
 | 
			
		||||
	for i, b := range *s.value {
 | 
			
		||||
		boolStrSlice[i] = strconv.FormatBool(b)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	out, _ := writeAsCSV(boolStrSlice)
 | 
			
		||||
 | 
			
		||||
	return "[" + out + "]"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (s *boolSliceValue) fromString(val string) (bool, error) {
 | 
			
		||||
	return strconv.ParseBool(val)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (s *boolSliceValue) toString(val bool) string {
 | 
			
		||||
	return strconv.FormatBool(val)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (s *boolSliceValue) Append(val string) error {
 | 
			
		||||
	i, err := s.fromString(val)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return err
 | 
			
		||||
	}
 | 
			
		||||
	*s.value = append(*s.value, i)
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (s *boolSliceValue) Replace(val []string) error {
 | 
			
		||||
	out := make([]bool, len(val))
 | 
			
		||||
	for i, d := range val {
 | 
			
		||||
		var err error
 | 
			
		||||
		out[i], err = s.fromString(d)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			return err
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	*s.value = out
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (s *boolSliceValue) GetSlice() []string {
 | 
			
		||||
	out := make([]string, len(*s.value))
 | 
			
		||||
	for i, d := range *s.value {
 | 
			
		||||
		out[i] = s.toString(d)
 | 
			
		||||
	}
 | 
			
		||||
	return out
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func boolSliceConv(val string) (interface{}, error) {
 | 
			
		||||
	val = strings.Trim(val, "[]")
 | 
			
		||||
	// Empty string would cause a slice with one (empty) entry
 | 
			
		||||
	if len(val) == 0 {
 | 
			
		||||
		return []bool{}, nil
 | 
			
		||||
	}
 | 
			
		||||
	ss := strings.Split(val, ",")
 | 
			
		||||
	out := make([]bool, len(ss))
 | 
			
		||||
	for i, t := range ss {
 | 
			
		||||
		var err error
 | 
			
		||||
		out[i], err = strconv.ParseBool(t)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			return nil, err
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	return out, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// GetBoolSlice returns the []bool value of a flag with the given name.
 | 
			
		||||
func (f *FlagSet) GetBoolSlice(name string) ([]bool, error) {
 | 
			
		||||
	val, err := f.getFlagType(name, "boolSlice", boolSliceConv)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return []bool{}, err
 | 
			
		||||
	}
 | 
			
		||||
	return val.([]bool), nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// BoolSliceVar defines a boolSlice flag with specified name, default value, and usage string.
 | 
			
		||||
// The argument p points to a []bool variable in which to store the value of the flag.
 | 
			
		||||
func (f *FlagSet) BoolSliceVar(p *[]bool, name string, value []bool, usage string) {
 | 
			
		||||
	f.VarP(newBoolSliceValue(value, p), name, "", usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// BoolSliceVarP is like BoolSliceVar, but accepts a shorthand letter that can be used after a single dash.
 | 
			
		||||
func (f *FlagSet) BoolSliceVarP(p *[]bool, name, shorthand string, value []bool, usage string) {
 | 
			
		||||
	f.VarP(newBoolSliceValue(value, p), name, shorthand, usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// BoolSliceVar defines a []bool flag with specified name, default value, and usage string.
 | 
			
		||||
// The argument p points to a []bool variable in which to store the value of the flag.
 | 
			
		||||
func BoolSliceVar(p *[]bool, name string, value []bool, usage string) {
 | 
			
		||||
	CommandLine.VarP(newBoolSliceValue(value, p), name, "", usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// BoolSliceVarP is like BoolSliceVar, but accepts a shorthand letter that can be used after a single dash.
 | 
			
		||||
func BoolSliceVarP(p *[]bool, name, shorthand string, value []bool, usage string) {
 | 
			
		||||
	CommandLine.VarP(newBoolSliceValue(value, p), name, shorthand, usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// BoolSlice defines a []bool flag with specified name, default value, and usage string.
 | 
			
		||||
// The return value is the address of a []bool variable that stores the value of the flag.
 | 
			
		||||
func (f *FlagSet) BoolSlice(name string, value []bool, usage string) *[]bool {
 | 
			
		||||
	p := []bool{}
 | 
			
		||||
	f.BoolSliceVarP(&p, name, "", value, usage)
 | 
			
		||||
	return &p
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// BoolSliceP is like BoolSlice, but accepts a shorthand letter that can be used after a single dash.
 | 
			
		||||
func (f *FlagSet) BoolSliceP(name, shorthand string, value []bool, usage string) *[]bool {
 | 
			
		||||
	p := []bool{}
 | 
			
		||||
	f.BoolSliceVarP(&p, name, shorthand, value, usage)
 | 
			
		||||
	return &p
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// BoolSlice defines a []bool flag with specified name, default value, and usage string.
 | 
			
		||||
// The return value is the address of a []bool variable that stores the value of the flag.
 | 
			
		||||
func BoolSlice(name string, value []bool, usage string) *[]bool {
 | 
			
		||||
	return CommandLine.BoolSliceP(name, "", value, usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// BoolSliceP is like BoolSlice, but accepts a shorthand letter that can be used after a single dash.
 | 
			
		||||
func BoolSliceP(name, shorthand string, value []bool, usage string) *[]bool {
 | 
			
		||||
	return CommandLine.BoolSliceP(name, shorthand, value, usage)
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										209
									
								
								vendor/github.com/spf13/pflag/bytes.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										209
									
								
								vendor/github.com/spf13/pflag/bytes.go
									
									
									
										generated
									
									
										vendored
									
									
								
							@@ -1,209 +0,0 @@
 | 
			
		||||
package pflag
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"encoding/base64"
 | 
			
		||||
	"encoding/hex"
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"strings"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// BytesHex adapts []byte for use as a flag. Value of flag is HEX encoded
 | 
			
		||||
type bytesHexValue []byte
 | 
			
		||||
 | 
			
		||||
// String implements pflag.Value.String.
 | 
			
		||||
func (bytesHex bytesHexValue) String() string {
 | 
			
		||||
	return fmt.Sprintf("%X", []byte(bytesHex))
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Set implements pflag.Value.Set.
 | 
			
		||||
func (bytesHex *bytesHexValue) Set(value string) error {
 | 
			
		||||
	bin, err := hex.DecodeString(strings.TrimSpace(value))
 | 
			
		||||
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	*bytesHex = bin
 | 
			
		||||
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Type implements pflag.Value.Type.
 | 
			
		||||
func (*bytesHexValue) Type() string {
 | 
			
		||||
	return "bytesHex"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func newBytesHexValue(val []byte, p *[]byte) *bytesHexValue {
 | 
			
		||||
	*p = val
 | 
			
		||||
	return (*bytesHexValue)(p)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func bytesHexConv(sval string) (interface{}, error) {
 | 
			
		||||
 | 
			
		||||
	bin, err := hex.DecodeString(sval)
 | 
			
		||||
 | 
			
		||||
	if err == nil {
 | 
			
		||||
		return bin, nil
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return nil, fmt.Errorf("invalid string being converted to Bytes: %s %s", sval, err)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// GetBytesHex return the []byte value of a flag with the given name
 | 
			
		||||
func (f *FlagSet) GetBytesHex(name string) ([]byte, error) {
 | 
			
		||||
	val, err := f.getFlagType(name, "bytesHex", bytesHexConv)
 | 
			
		||||
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return []byte{}, err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return val.([]byte), nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// BytesHexVar defines an []byte flag with specified name, default value, and usage string.
 | 
			
		||||
// The argument p points to an []byte variable in which to store the value of the flag.
 | 
			
		||||
func (f *FlagSet) BytesHexVar(p *[]byte, name string, value []byte, usage string) {
 | 
			
		||||
	f.VarP(newBytesHexValue(value, p), name, "", usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// BytesHexVarP is like BytesHexVar, but accepts a shorthand letter that can be used after a single dash.
 | 
			
		||||
func (f *FlagSet) BytesHexVarP(p *[]byte, name, shorthand string, value []byte, usage string) {
 | 
			
		||||
	f.VarP(newBytesHexValue(value, p), name, shorthand, usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// BytesHexVar defines an []byte flag with specified name, default value, and usage string.
 | 
			
		||||
// The argument p points to an []byte variable in which to store the value of the flag.
 | 
			
		||||
func BytesHexVar(p *[]byte, name string, value []byte, usage string) {
 | 
			
		||||
	CommandLine.VarP(newBytesHexValue(value, p), name, "", usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// BytesHexVarP is like BytesHexVar, but accepts a shorthand letter that can be used after a single dash.
 | 
			
		||||
func BytesHexVarP(p *[]byte, name, shorthand string, value []byte, usage string) {
 | 
			
		||||
	CommandLine.VarP(newBytesHexValue(value, p), name, shorthand, usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// BytesHex defines an []byte flag with specified name, default value, and usage string.
 | 
			
		||||
// The return value is the address of an []byte variable that stores the value of the flag.
 | 
			
		||||
func (f *FlagSet) BytesHex(name string, value []byte, usage string) *[]byte {
 | 
			
		||||
	p := new([]byte)
 | 
			
		||||
	f.BytesHexVarP(p, name, "", value, usage)
 | 
			
		||||
	return p
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// BytesHexP is like BytesHex, but accepts a shorthand letter that can be used after a single dash.
 | 
			
		||||
func (f *FlagSet) BytesHexP(name, shorthand string, value []byte, usage string) *[]byte {
 | 
			
		||||
	p := new([]byte)
 | 
			
		||||
	f.BytesHexVarP(p, name, shorthand, value, usage)
 | 
			
		||||
	return p
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// BytesHex defines an []byte flag with specified name, default value, and usage string.
 | 
			
		||||
// The return value is the address of an []byte variable that stores the value of the flag.
 | 
			
		||||
func BytesHex(name string, value []byte, usage string) *[]byte {
 | 
			
		||||
	return CommandLine.BytesHexP(name, "", value, usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// BytesHexP is like BytesHex, but accepts a shorthand letter that can be used after a single dash.
 | 
			
		||||
func BytesHexP(name, shorthand string, value []byte, usage string) *[]byte {
 | 
			
		||||
	return CommandLine.BytesHexP(name, shorthand, value, usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// BytesBase64 adapts []byte for use as a flag. Value of flag is Base64 encoded
 | 
			
		||||
type bytesBase64Value []byte
 | 
			
		||||
 | 
			
		||||
// String implements pflag.Value.String.
 | 
			
		||||
func (bytesBase64 bytesBase64Value) String() string {
 | 
			
		||||
	return base64.StdEncoding.EncodeToString([]byte(bytesBase64))
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Set implements pflag.Value.Set.
 | 
			
		||||
func (bytesBase64 *bytesBase64Value) Set(value string) error {
 | 
			
		||||
	bin, err := base64.StdEncoding.DecodeString(strings.TrimSpace(value))
 | 
			
		||||
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	*bytesBase64 = bin
 | 
			
		||||
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Type implements pflag.Value.Type.
 | 
			
		||||
func (*bytesBase64Value) Type() string {
 | 
			
		||||
	return "bytesBase64"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func newBytesBase64Value(val []byte, p *[]byte) *bytesBase64Value {
 | 
			
		||||
	*p = val
 | 
			
		||||
	return (*bytesBase64Value)(p)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func bytesBase64ValueConv(sval string) (interface{}, error) {
 | 
			
		||||
 | 
			
		||||
	bin, err := base64.StdEncoding.DecodeString(sval)
 | 
			
		||||
	if err == nil {
 | 
			
		||||
		return bin, nil
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return nil, fmt.Errorf("invalid string being converted to Bytes: %s %s", sval, err)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// GetBytesBase64 return the []byte value of a flag with the given name
 | 
			
		||||
func (f *FlagSet) GetBytesBase64(name string) ([]byte, error) {
 | 
			
		||||
	val, err := f.getFlagType(name, "bytesBase64", bytesBase64ValueConv)
 | 
			
		||||
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return []byte{}, err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return val.([]byte), nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// BytesBase64Var defines an []byte flag with specified name, default value, and usage string.
 | 
			
		||||
// The argument p points to an []byte variable in which to store the value of the flag.
 | 
			
		||||
func (f *FlagSet) BytesBase64Var(p *[]byte, name string, value []byte, usage string) {
 | 
			
		||||
	f.VarP(newBytesBase64Value(value, p), name, "", usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// BytesBase64VarP is like BytesBase64Var, but accepts a shorthand letter that can be used after a single dash.
 | 
			
		||||
func (f *FlagSet) BytesBase64VarP(p *[]byte, name, shorthand string, value []byte, usage string) {
 | 
			
		||||
	f.VarP(newBytesBase64Value(value, p), name, shorthand, usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// BytesBase64Var defines an []byte flag with specified name, default value, and usage string.
 | 
			
		||||
// The argument p points to an []byte variable in which to store the value of the flag.
 | 
			
		||||
func BytesBase64Var(p *[]byte, name string, value []byte, usage string) {
 | 
			
		||||
	CommandLine.VarP(newBytesBase64Value(value, p), name, "", usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// BytesBase64VarP is like BytesBase64Var, but accepts a shorthand letter that can be used after a single dash.
 | 
			
		||||
func BytesBase64VarP(p *[]byte, name, shorthand string, value []byte, usage string) {
 | 
			
		||||
	CommandLine.VarP(newBytesBase64Value(value, p), name, shorthand, usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// BytesBase64 defines an []byte flag with specified name, default value, and usage string.
 | 
			
		||||
// The return value is the address of an []byte variable that stores the value of the flag.
 | 
			
		||||
func (f *FlagSet) BytesBase64(name string, value []byte, usage string) *[]byte {
 | 
			
		||||
	p := new([]byte)
 | 
			
		||||
	f.BytesBase64VarP(p, name, "", value, usage)
 | 
			
		||||
	return p
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// BytesBase64P is like BytesBase64, but accepts a shorthand letter that can be used after a single dash.
 | 
			
		||||
func (f *FlagSet) BytesBase64P(name, shorthand string, value []byte, usage string) *[]byte {
 | 
			
		||||
	p := new([]byte)
 | 
			
		||||
	f.BytesBase64VarP(p, name, shorthand, value, usage)
 | 
			
		||||
	return p
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// BytesBase64 defines an []byte flag with specified name, default value, and usage string.
 | 
			
		||||
// The return value is the address of an []byte variable that stores the value of the flag.
 | 
			
		||||
func BytesBase64(name string, value []byte, usage string) *[]byte {
 | 
			
		||||
	return CommandLine.BytesBase64P(name, "", value, usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// BytesBase64P is like BytesBase64, but accepts a shorthand letter that can be used after a single dash.
 | 
			
		||||
func BytesBase64P(name, shorthand string, value []byte, usage string) *[]byte {
 | 
			
		||||
	return CommandLine.BytesBase64P(name, shorthand, value, usage)
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										96
									
								
								vendor/github.com/spf13/pflag/count.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										96
									
								
								vendor/github.com/spf13/pflag/count.go
									
									
									
										generated
									
									
										vendored
									
									
								
							@@ -1,96 +0,0 @@
 | 
			
		||||
package pflag
 | 
			
		||||
 | 
			
		||||
import "strconv"
 | 
			
		||||
 | 
			
		||||
// -- count Value
 | 
			
		||||
type countValue int
 | 
			
		||||
 | 
			
		||||
func newCountValue(val int, p *int) *countValue {
 | 
			
		||||
	*p = val
 | 
			
		||||
	return (*countValue)(p)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (i *countValue) Set(s string) error {
 | 
			
		||||
	// "+1" means that no specific value was passed, so increment
 | 
			
		||||
	if s == "+1" {
 | 
			
		||||
		*i = countValue(*i + 1)
 | 
			
		||||
		return nil
 | 
			
		||||
	}
 | 
			
		||||
	v, err := strconv.ParseInt(s, 0, 0)
 | 
			
		||||
	*i = countValue(v)
 | 
			
		||||
	return err
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (i *countValue) Type() string {
 | 
			
		||||
	return "count"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (i *countValue) String() string { return strconv.Itoa(int(*i)) }
 | 
			
		||||
 | 
			
		||||
func countConv(sval string) (interface{}, error) {
 | 
			
		||||
	i, err := strconv.Atoi(sval)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
	return i, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// GetCount return the int value of a flag with the given name
 | 
			
		||||
func (f *FlagSet) GetCount(name string) (int, error) {
 | 
			
		||||
	val, err := f.getFlagType(name, "count", countConv)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return 0, err
 | 
			
		||||
	}
 | 
			
		||||
	return val.(int), nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// CountVar defines a count flag with specified name, default value, and usage string.
 | 
			
		||||
// The argument p points to an int variable in which to store the value of the flag.
 | 
			
		||||
// A count flag will add 1 to its value every time it is found on the command line
 | 
			
		||||
func (f *FlagSet) CountVar(p *int, name string, usage string) {
 | 
			
		||||
	f.CountVarP(p, name, "", usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// CountVarP is like CountVar only take a shorthand for the flag name.
 | 
			
		||||
func (f *FlagSet) CountVarP(p *int, name, shorthand string, usage string) {
 | 
			
		||||
	flag := f.VarPF(newCountValue(0, p), name, shorthand, usage)
 | 
			
		||||
	flag.NoOptDefVal = "+1"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// CountVar like CountVar only the flag is placed on the CommandLine instead of a given flag set
 | 
			
		||||
func CountVar(p *int, name string, usage string) {
 | 
			
		||||
	CommandLine.CountVar(p, name, usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// CountVarP is like CountVar only take a shorthand for the flag name.
 | 
			
		||||
func CountVarP(p *int, name, shorthand string, usage string) {
 | 
			
		||||
	CommandLine.CountVarP(p, name, shorthand, usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Count defines a count flag with specified name, default value, and usage string.
 | 
			
		||||
// The return value is the address of an int variable that stores the value of the flag.
 | 
			
		||||
// A count flag will add 1 to its value every time it is found on the command line
 | 
			
		||||
func (f *FlagSet) Count(name string, usage string) *int {
 | 
			
		||||
	p := new(int)
 | 
			
		||||
	f.CountVarP(p, name, "", usage)
 | 
			
		||||
	return p
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// CountP is like Count only takes a shorthand for the flag name.
 | 
			
		||||
func (f *FlagSet) CountP(name, shorthand string, usage string) *int {
 | 
			
		||||
	p := new(int)
 | 
			
		||||
	f.CountVarP(p, name, shorthand, usage)
 | 
			
		||||
	return p
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Count defines a count flag with specified name, default value, and usage string.
 | 
			
		||||
// The return value is the address of an int variable that stores the value of the flag.
 | 
			
		||||
// A count flag will add 1 to its value evey time it is found on the command line
 | 
			
		||||
func Count(name string, usage string) *int {
 | 
			
		||||
	return CommandLine.CountP(name, "", usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// CountP is like Count only takes a shorthand for the flag name.
 | 
			
		||||
func CountP(name, shorthand string, usage string) *int {
 | 
			
		||||
	return CommandLine.CountP(name, shorthand, usage)
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										86
									
								
								vendor/github.com/spf13/pflag/duration.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										86
									
								
								vendor/github.com/spf13/pflag/duration.go
									
									
									
										generated
									
									
										vendored
									
									
								
							@@ -1,86 +0,0 @@
 | 
			
		||||
package pflag
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"time"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// -- time.Duration Value
 | 
			
		||||
type durationValue time.Duration
 | 
			
		||||
 | 
			
		||||
func newDurationValue(val time.Duration, p *time.Duration) *durationValue {
 | 
			
		||||
	*p = val
 | 
			
		||||
	return (*durationValue)(p)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (d *durationValue) Set(s string) error {
 | 
			
		||||
	v, err := time.ParseDuration(s)
 | 
			
		||||
	*d = durationValue(v)
 | 
			
		||||
	return err
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (d *durationValue) Type() string {
 | 
			
		||||
	return "duration"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (d *durationValue) String() string { return (*time.Duration)(d).String() }
 | 
			
		||||
 | 
			
		||||
func durationConv(sval string) (interface{}, error) {
 | 
			
		||||
	return time.ParseDuration(sval)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// GetDuration return the duration value of a flag with the given name
 | 
			
		||||
func (f *FlagSet) GetDuration(name string) (time.Duration, error) {
 | 
			
		||||
	val, err := f.getFlagType(name, "duration", durationConv)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return 0, err
 | 
			
		||||
	}
 | 
			
		||||
	return val.(time.Duration), nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// DurationVar defines a time.Duration flag with specified name, default value, and usage string.
 | 
			
		||||
// The argument p points to a time.Duration variable in which to store the value of the flag.
 | 
			
		||||
func (f *FlagSet) DurationVar(p *time.Duration, name string, value time.Duration, usage string) {
 | 
			
		||||
	f.VarP(newDurationValue(value, p), name, "", usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// DurationVarP is like DurationVar, but accepts a shorthand letter that can be used after a single dash.
 | 
			
		||||
func (f *FlagSet) DurationVarP(p *time.Duration, name, shorthand string, value time.Duration, usage string) {
 | 
			
		||||
	f.VarP(newDurationValue(value, p), name, shorthand, usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// DurationVar defines a time.Duration flag with specified name, default value, and usage string.
 | 
			
		||||
// The argument p points to a time.Duration variable in which to store the value of the flag.
 | 
			
		||||
func DurationVar(p *time.Duration, name string, value time.Duration, usage string) {
 | 
			
		||||
	CommandLine.VarP(newDurationValue(value, p), name, "", usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// DurationVarP is like DurationVar, but accepts a shorthand letter that can be used after a single dash.
 | 
			
		||||
func DurationVarP(p *time.Duration, name, shorthand string, value time.Duration, usage string) {
 | 
			
		||||
	CommandLine.VarP(newDurationValue(value, p), name, shorthand, usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Duration defines a time.Duration flag with specified name, default value, and usage string.
 | 
			
		||||
// The return value is the address of a time.Duration variable that stores the value of the flag.
 | 
			
		||||
func (f *FlagSet) Duration(name string, value time.Duration, usage string) *time.Duration {
 | 
			
		||||
	p := new(time.Duration)
 | 
			
		||||
	f.DurationVarP(p, name, "", value, usage)
 | 
			
		||||
	return p
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// DurationP is like Duration, but accepts a shorthand letter that can be used after a single dash.
 | 
			
		||||
func (f *FlagSet) DurationP(name, shorthand string, value time.Duration, usage string) *time.Duration {
 | 
			
		||||
	p := new(time.Duration)
 | 
			
		||||
	f.DurationVarP(p, name, shorthand, value, usage)
 | 
			
		||||
	return p
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Duration defines a time.Duration flag with specified name, default value, and usage string.
 | 
			
		||||
// The return value is the address of a time.Duration variable that stores the value of the flag.
 | 
			
		||||
func Duration(name string, value time.Duration, usage string) *time.Duration {
 | 
			
		||||
	return CommandLine.DurationP(name, "", value, usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// DurationP is like Duration, but accepts a shorthand letter that can be used after a single dash.
 | 
			
		||||
func DurationP(name, shorthand string, value time.Duration, usage string) *time.Duration {
 | 
			
		||||
	return CommandLine.DurationP(name, shorthand, value, usage)
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										166
									
								
								vendor/github.com/spf13/pflag/duration_slice.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										166
									
								
								vendor/github.com/spf13/pflag/duration_slice.go
									
									
									
										generated
									
									
										vendored
									
									
								
							@@ -1,166 +0,0 @@
 | 
			
		||||
package pflag
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"strings"
 | 
			
		||||
	"time"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// -- durationSlice Value
 | 
			
		||||
type durationSliceValue struct {
 | 
			
		||||
	value   *[]time.Duration
 | 
			
		||||
	changed bool
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func newDurationSliceValue(val []time.Duration, p *[]time.Duration) *durationSliceValue {
 | 
			
		||||
	dsv := new(durationSliceValue)
 | 
			
		||||
	dsv.value = p
 | 
			
		||||
	*dsv.value = val
 | 
			
		||||
	return dsv
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (s *durationSliceValue) Set(val string) error {
 | 
			
		||||
	ss := strings.Split(val, ",")
 | 
			
		||||
	out := make([]time.Duration, len(ss))
 | 
			
		||||
	for i, d := range ss {
 | 
			
		||||
		var err error
 | 
			
		||||
		out[i], err = time.ParseDuration(d)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			return err
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
	}
 | 
			
		||||
	if !s.changed {
 | 
			
		||||
		*s.value = out
 | 
			
		||||
	} else {
 | 
			
		||||
		*s.value = append(*s.value, out...)
 | 
			
		||||
	}
 | 
			
		||||
	s.changed = true
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (s *durationSliceValue) Type() string {
 | 
			
		||||
	return "durationSlice"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (s *durationSliceValue) String() string {
 | 
			
		||||
	out := make([]string, len(*s.value))
 | 
			
		||||
	for i, d := range *s.value {
 | 
			
		||||
		out[i] = fmt.Sprintf("%s", d)
 | 
			
		||||
	}
 | 
			
		||||
	return "[" + strings.Join(out, ",") + "]"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (s *durationSliceValue) fromString(val string) (time.Duration, error) {
 | 
			
		||||
	return time.ParseDuration(val)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (s *durationSliceValue) toString(val time.Duration) string {
 | 
			
		||||
	return fmt.Sprintf("%s", val)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (s *durationSliceValue) Append(val string) error {
 | 
			
		||||
	i, err := s.fromString(val)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return err
 | 
			
		||||
	}
 | 
			
		||||
	*s.value = append(*s.value, i)
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (s *durationSliceValue) Replace(val []string) error {
 | 
			
		||||
	out := make([]time.Duration, len(val))
 | 
			
		||||
	for i, d := range val {
 | 
			
		||||
		var err error
 | 
			
		||||
		out[i], err = s.fromString(d)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			return err
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	*s.value = out
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (s *durationSliceValue) GetSlice() []string {
 | 
			
		||||
	out := make([]string, len(*s.value))
 | 
			
		||||
	for i, d := range *s.value {
 | 
			
		||||
		out[i] = s.toString(d)
 | 
			
		||||
	}
 | 
			
		||||
	return out
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func durationSliceConv(val string) (interface{}, error) {
 | 
			
		||||
	val = strings.Trim(val, "[]")
 | 
			
		||||
	// Empty string would cause a slice with one (empty) entry
 | 
			
		||||
	if len(val) == 0 {
 | 
			
		||||
		return []time.Duration{}, nil
 | 
			
		||||
	}
 | 
			
		||||
	ss := strings.Split(val, ",")
 | 
			
		||||
	out := make([]time.Duration, len(ss))
 | 
			
		||||
	for i, d := range ss {
 | 
			
		||||
		var err error
 | 
			
		||||
		out[i], err = time.ParseDuration(d)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			return nil, err
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
	}
 | 
			
		||||
	return out, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// GetDurationSlice returns the []time.Duration value of a flag with the given name
 | 
			
		||||
func (f *FlagSet) GetDurationSlice(name string) ([]time.Duration, error) {
 | 
			
		||||
	val, err := f.getFlagType(name, "durationSlice", durationSliceConv)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return []time.Duration{}, err
 | 
			
		||||
	}
 | 
			
		||||
	return val.([]time.Duration), nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// DurationSliceVar defines a durationSlice flag with specified name, default value, and usage string.
 | 
			
		||||
// The argument p points to a []time.Duration variable in which to store the value of the flag.
 | 
			
		||||
func (f *FlagSet) DurationSliceVar(p *[]time.Duration, name string, value []time.Duration, usage string) {
 | 
			
		||||
	f.VarP(newDurationSliceValue(value, p), name, "", usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// DurationSliceVarP is like DurationSliceVar, but accepts a shorthand letter that can be used after a single dash.
 | 
			
		||||
func (f *FlagSet) DurationSliceVarP(p *[]time.Duration, name, shorthand string, value []time.Duration, usage string) {
 | 
			
		||||
	f.VarP(newDurationSliceValue(value, p), name, shorthand, usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// DurationSliceVar defines a duration[] flag with specified name, default value, and usage string.
 | 
			
		||||
// The argument p points to a duration[] variable in which to store the value of the flag.
 | 
			
		||||
func DurationSliceVar(p *[]time.Duration, name string, value []time.Duration, usage string) {
 | 
			
		||||
	CommandLine.VarP(newDurationSliceValue(value, p), name, "", usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// DurationSliceVarP is like DurationSliceVar, but accepts a shorthand letter that can be used after a single dash.
 | 
			
		||||
func DurationSliceVarP(p *[]time.Duration, name, shorthand string, value []time.Duration, usage string) {
 | 
			
		||||
	CommandLine.VarP(newDurationSliceValue(value, p), name, shorthand, usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// DurationSlice defines a []time.Duration flag with specified name, default value, and usage string.
 | 
			
		||||
// The return value is the address of a []time.Duration variable that stores the value of the flag.
 | 
			
		||||
func (f *FlagSet) DurationSlice(name string, value []time.Duration, usage string) *[]time.Duration {
 | 
			
		||||
	p := []time.Duration{}
 | 
			
		||||
	f.DurationSliceVarP(&p, name, "", value, usage)
 | 
			
		||||
	return &p
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// DurationSliceP is like DurationSlice, but accepts a shorthand letter that can be used after a single dash.
 | 
			
		||||
func (f *FlagSet) DurationSliceP(name, shorthand string, value []time.Duration, usage string) *[]time.Duration {
 | 
			
		||||
	p := []time.Duration{}
 | 
			
		||||
	f.DurationSliceVarP(&p, name, shorthand, value, usage)
 | 
			
		||||
	return &p
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// DurationSlice defines a []time.Duration flag with specified name, default value, and usage string.
 | 
			
		||||
// The return value is the address of a []time.Duration variable that stores the value of the flag.
 | 
			
		||||
func DurationSlice(name string, value []time.Duration, usage string) *[]time.Duration {
 | 
			
		||||
	return CommandLine.DurationSliceP(name, "", value, usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// DurationSliceP is like DurationSlice, but accepts a shorthand letter that can be used after a single dash.
 | 
			
		||||
func DurationSliceP(name, shorthand string, value []time.Duration, usage string) *[]time.Duration {
 | 
			
		||||
	return CommandLine.DurationSliceP(name, shorthand, value, usage)
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										1239
									
								
								vendor/github.com/spf13/pflag/flag.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										1239
									
								
								vendor/github.com/spf13/pflag/flag.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										88
									
								
								vendor/github.com/spf13/pflag/float32.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										88
									
								
								vendor/github.com/spf13/pflag/float32.go
									
									
									
										generated
									
									
										vendored
									
									
								
							@@ -1,88 +0,0 @@
 | 
			
		||||
package pflag
 | 
			
		||||
 | 
			
		||||
import "strconv"
 | 
			
		||||
 | 
			
		||||
// -- float32 Value
 | 
			
		||||
type float32Value float32
 | 
			
		||||
 | 
			
		||||
func newFloat32Value(val float32, p *float32) *float32Value {
 | 
			
		||||
	*p = val
 | 
			
		||||
	return (*float32Value)(p)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (f *float32Value) Set(s string) error {
 | 
			
		||||
	v, err := strconv.ParseFloat(s, 32)
 | 
			
		||||
	*f = float32Value(v)
 | 
			
		||||
	return err
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (f *float32Value) Type() string {
 | 
			
		||||
	return "float32"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (f *float32Value) String() string { return strconv.FormatFloat(float64(*f), 'g', -1, 32) }
 | 
			
		||||
 | 
			
		||||
func float32Conv(sval string) (interface{}, error) {
 | 
			
		||||
	v, err := strconv.ParseFloat(sval, 32)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return 0, err
 | 
			
		||||
	}
 | 
			
		||||
	return float32(v), nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// GetFloat32 return the float32 value of a flag with the given name
 | 
			
		||||
func (f *FlagSet) GetFloat32(name string) (float32, error) {
 | 
			
		||||
	val, err := f.getFlagType(name, "float32", float32Conv)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return 0, err
 | 
			
		||||
	}
 | 
			
		||||
	return val.(float32), nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Float32Var defines a float32 flag with specified name, default value, and usage string.
 | 
			
		||||
// The argument p points to a float32 variable in which to store the value of the flag.
 | 
			
		||||
func (f *FlagSet) Float32Var(p *float32, name string, value float32, usage string) {
 | 
			
		||||
	f.VarP(newFloat32Value(value, p), name, "", usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Float32VarP is like Float32Var, but accepts a shorthand letter that can be used after a single dash.
 | 
			
		||||
func (f *FlagSet) Float32VarP(p *float32, name, shorthand string, value float32, usage string) {
 | 
			
		||||
	f.VarP(newFloat32Value(value, p), name, shorthand, usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Float32Var defines a float32 flag with specified name, default value, and usage string.
 | 
			
		||||
// The argument p points to a float32 variable in which to store the value of the flag.
 | 
			
		||||
func Float32Var(p *float32, name string, value float32, usage string) {
 | 
			
		||||
	CommandLine.VarP(newFloat32Value(value, p), name, "", usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Float32VarP is like Float32Var, but accepts a shorthand letter that can be used after a single dash.
 | 
			
		||||
func Float32VarP(p *float32, name, shorthand string, value float32, usage string) {
 | 
			
		||||
	CommandLine.VarP(newFloat32Value(value, p), name, shorthand, usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Float32 defines a float32 flag with specified name, default value, and usage string.
 | 
			
		||||
// The return value is the address of a float32 variable that stores the value of the flag.
 | 
			
		||||
func (f *FlagSet) Float32(name string, value float32, usage string) *float32 {
 | 
			
		||||
	p := new(float32)
 | 
			
		||||
	f.Float32VarP(p, name, "", value, usage)
 | 
			
		||||
	return p
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Float32P is like Float32, but accepts a shorthand letter that can be used after a single dash.
 | 
			
		||||
func (f *FlagSet) Float32P(name, shorthand string, value float32, usage string) *float32 {
 | 
			
		||||
	p := new(float32)
 | 
			
		||||
	f.Float32VarP(p, name, shorthand, value, usage)
 | 
			
		||||
	return p
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Float32 defines a float32 flag with specified name, default value, and usage string.
 | 
			
		||||
// The return value is the address of a float32 variable that stores the value of the flag.
 | 
			
		||||
func Float32(name string, value float32, usage string) *float32 {
 | 
			
		||||
	return CommandLine.Float32P(name, "", value, usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Float32P is like Float32, but accepts a shorthand letter that can be used after a single dash.
 | 
			
		||||
func Float32P(name, shorthand string, value float32, usage string) *float32 {
 | 
			
		||||
	return CommandLine.Float32P(name, shorthand, value, usage)
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										174
									
								
								vendor/github.com/spf13/pflag/float32_slice.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										174
									
								
								vendor/github.com/spf13/pflag/float32_slice.go
									
									
									
										generated
									
									
										vendored
									
									
								
							@@ -1,174 +0,0 @@
 | 
			
		||||
package pflag
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"strconv"
 | 
			
		||||
	"strings"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// -- float32Slice Value
 | 
			
		||||
type float32SliceValue struct {
 | 
			
		||||
	value   *[]float32
 | 
			
		||||
	changed bool
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func newFloat32SliceValue(val []float32, p *[]float32) *float32SliceValue {
 | 
			
		||||
	isv := new(float32SliceValue)
 | 
			
		||||
	isv.value = p
 | 
			
		||||
	*isv.value = val
 | 
			
		||||
	return isv
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (s *float32SliceValue) Set(val string) error {
 | 
			
		||||
	ss := strings.Split(val, ",")
 | 
			
		||||
	out := make([]float32, len(ss))
 | 
			
		||||
	for i, d := range ss {
 | 
			
		||||
		var err error
 | 
			
		||||
		var temp64 float64
 | 
			
		||||
		temp64, err = strconv.ParseFloat(d, 32)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			return err
 | 
			
		||||
		}
 | 
			
		||||
		out[i] = float32(temp64)
 | 
			
		||||
 | 
			
		||||
	}
 | 
			
		||||
	if !s.changed {
 | 
			
		||||
		*s.value = out
 | 
			
		||||
	} else {
 | 
			
		||||
		*s.value = append(*s.value, out...)
 | 
			
		||||
	}
 | 
			
		||||
	s.changed = true
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (s *float32SliceValue) Type() string {
 | 
			
		||||
	return "float32Slice"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (s *float32SliceValue) String() string {
 | 
			
		||||
	out := make([]string, len(*s.value))
 | 
			
		||||
	for i, d := range *s.value {
 | 
			
		||||
		out[i] = fmt.Sprintf("%f", d)
 | 
			
		||||
	}
 | 
			
		||||
	return "[" + strings.Join(out, ",") + "]"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (s *float32SliceValue) fromString(val string) (float32, error) {
 | 
			
		||||
	t64, err := strconv.ParseFloat(val, 32)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return 0, err
 | 
			
		||||
	}
 | 
			
		||||
	return float32(t64), nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (s *float32SliceValue) toString(val float32) string {
 | 
			
		||||
	return fmt.Sprintf("%f", val)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (s *float32SliceValue) Append(val string) error {
 | 
			
		||||
	i, err := s.fromString(val)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return err
 | 
			
		||||
	}
 | 
			
		||||
	*s.value = append(*s.value, i)
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (s *float32SliceValue) Replace(val []string) error {
 | 
			
		||||
	out := make([]float32, len(val))
 | 
			
		||||
	for i, d := range val {
 | 
			
		||||
		var err error
 | 
			
		||||
		out[i], err = s.fromString(d)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			return err
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	*s.value = out
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (s *float32SliceValue) GetSlice() []string {
 | 
			
		||||
	out := make([]string, len(*s.value))
 | 
			
		||||
	for i, d := range *s.value {
 | 
			
		||||
		out[i] = s.toString(d)
 | 
			
		||||
	}
 | 
			
		||||
	return out
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func float32SliceConv(val string) (interface{}, error) {
 | 
			
		||||
	val = strings.Trim(val, "[]")
 | 
			
		||||
	// Empty string would cause a slice with one (empty) entry
 | 
			
		||||
	if len(val) == 0 {
 | 
			
		||||
		return []float32{}, nil
 | 
			
		||||
	}
 | 
			
		||||
	ss := strings.Split(val, ",")
 | 
			
		||||
	out := make([]float32, len(ss))
 | 
			
		||||
	for i, d := range ss {
 | 
			
		||||
		var err error
 | 
			
		||||
		var temp64 float64
 | 
			
		||||
		temp64, err = strconv.ParseFloat(d, 32)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			return nil, err
 | 
			
		||||
		}
 | 
			
		||||
		out[i] = float32(temp64)
 | 
			
		||||
 | 
			
		||||
	}
 | 
			
		||||
	return out, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// GetFloat32Slice return the []float32 value of a flag with the given name
 | 
			
		||||
func (f *FlagSet) GetFloat32Slice(name string) ([]float32, error) {
 | 
			
		||||
	val, err := f.getFlagType(name, "float32Slice", float32SliceConv)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return []float32{}, err
 | 
			
		||||
	}
 | 
			
		||||
	return val.([]float32), nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Float32SliceVar defines a float32Slice flag with specified name, default value, and usage string.
 | 
			
		||||
// The argument p points to a []float32 variable in which to store the value of the flag.
 | 
			
		||||
func (f *FlagSet) Float32SliceVar(p *[]float32, name string, value []float32, usage string) {
 | 
			
		||||
	f.VarP(newFloat32SliceValue(value, p), name, "", usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Float32SliceVarP is like Float32SliceVar, but accepts a shorthand letter that can be used after a single dash.
 | 
			
		||||
func (f *FlagSet) Float32SliceVarP(p *[]float32, name, shorthand string, value []float32, usage string) {
 | 
			
		||||
	f.VarP(newFloat32SliceValue(value, p), name, shorthand, usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Float32SliceVar defines a float32[] flag with specified name, default value, and usage string.
 | 
			
		||||
// The argument p points to a float32[] variable in which to store the value of the flag.
 | 
			
		||||
func Float32SliceVar(p *[]float32, name string, value []float32, usage string) {
 | 
			
		||||
	CommandLine.VarP(newFloat32SliceValue(value, p), name, "", usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Float32SliceVarP is like Float32SliceVar, but accepts a shorthand letter that can be used after a single dash.
 | 
			
		||||
func Float32SliceVarP(p *[]float32, name, shorthand string, value []float32, usage string) {
 | 
			
		||||
	CommandLine.VarP(newFloat32SliceValue(value, p), name, shorthand, usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Float32Slice defines a []float32 flag with specified name, default value, and usage string.
 | 
			
		||||
// The return value is the address of a []float32 variable that stores the value of the flag.
 | 
			
		||||
func (f *FlagSet) Float32Slice(name string, value []float32, usage string) *[]float32 {
 | 
			
		||||
	p := []float32{}
 | 
			
		||||
	f.Float32SliceVarP(&p, name, "", value, usage)
 | 
			
		||||
	return &p
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Float32SliceP is like Float32Slice, but accepts a shorthand letter that can be used after a single dash.
 | 
			
		||||
func (f *FlagSet) Float32SliceP(name, shorthand string, value []float32, usage string) *[]float32 {
 | 
			
		||||
	p := []float32{}
 | 
			
		||||
	f.Float32SliceVarP(&p, name, shorthand, value, usage)
 | 
			
		||||
	return &p
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Float32Slice defines a []float32 flag with specified name, default value, and usage string.
 | 
			
		||||
// The return value is the address of a []float32 variable that stores the value of the flag.
 | 
			
		||||
func Float32Slice(name string, value []float32, usage string) *[]float32 {
 | 
			
		||||
	return CommandLine.Float32SliceP(name, "", value, usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Float32SliceP is like Float32Slice, but accepts a shorthand letter that can be used after a single dash.
 | 
			
		||||
func Float32SliceP(name, shorthand string, value []float32, usage string) *[]float32 {
 | 
			
		||||
	return CommandLine.Float32SliceP(name, shorthand, value, usage)
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										84
									
								
								vendor/github.com/spf13/pflag/float64.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										84
									
								
								vendor/github.com/spf13/pflag/float64.go
									
									
									
										generated
									
									
										vendored
									
									
								
							@@ -1,84 +0,0 @@
 | 
			
		||||
package pflag
 | 
			
		||||
 | 
			
		||||
import "strconv"
 | 
			
		||||
 | 
			
		||||
// -- float64 Value
 | 
			
		||||
type float64Value float64
 | 
			
		||||
 | 
			
		||||
func newFloat64Value(val float64, p *float64) *float64Value {
 | 
			
		||||
	*p = val
 | 
			
		||||
	return (*float64Value)(p)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (f *float64Value) Set(s string) error {
 | 
			
		||||
	v, err := strconv.ParseFloat(s, 64)
 | 
			
		||||
	*f = float64Value(v)
 | 
			
		||||
	return err
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (f *float64Value) Type() string {
 | 
			
		||||
	return "float64"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (f *float64Value) String() string { return strconv.FormatFloat(float64(*f), 'g', -1, 64) }
 | 
			
		||||
 | 
			
		||||
func float64Conv(sval string) (interface{}, error) {
 | 
			
		||||
	return strconv.ParseFloat(sval, 64)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// GetFloat64 return the float64 value of a flag with the given name
 | 
			
		||||
func (f *FlagSet) GetFloat64(name string) (float64, error) {
 | 
			
		||||
	val, err := f.getFlagType(name, "float64", float64Conv)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return 0, err
 | 
			
		||||
	}
 | 
			
		||||
	return val.(float64), nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Float64Var defines a float64 flag with specified name, default value, and usage string.
 | 
			
		||||
// The argument p points to a float64 variable in which to store the value of the flag.
 | 
			
		||||
func (f *FlagSet) Float64Var(p *float64, name string, value float64, usage string) {
 | 
			
		||||
	f.VarP(newFloat64Value(value, p), name, "", usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Float64VarP is like Float64Var, but accepts a shorthand letter that can be used after a single dash.
 | 
			
		||||
func (f *FlagSet) Float64VarP(p *float64, name, shorthand string, value float64, usage string) {
 | 
			
		||||
	f.VarP(newFloat64Value(value, p), name, shorthand, usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Float64Var defines a float64 flag with specified name, default value, and usage string.
 | 
			
		||||
// The argument p points to a float64 variable in which to store the value of the flag.
 | 
			
		||||
func Float64Var(p *float64, name string, value float64, usage string) {
 | 
			
		||||
	CommandLine.VarP(newFloat64Value(value, p), name, "", usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Float64VarP is like Float64Var, but accepts a shorthand letter that can be used after a single dash.
 | 
			
		||||
func Float64VarP(p *float64, name, shorthand string, value float64, usage string) {
 | 
			
		||||
	CommandLine.VarP(newFloat64Value(value, p), name, shorthand, usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Float64 defines a float64 flag with specified name, default value, and usage string.
 | 
			
		||||
// The return value is the address of a float64 variable that stores the value of the flag.
 | 
			
		||||
func (f *FlagSet) Float64(name string, value float64, usage string) *float64 {
 | 
			
		||||
	p := new(float64)
 | 
			
		||||
	f.Float64VarP(p, name, "", value, usage)
 | 
			
		||||
	return p
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Float64P is like Float64, but accepts a shorthand letter that can be used after a single dash.
 | 
			
		||||
func (f *FlagSet) Float64P(name, shorthand string, value float64, usage string) *float64 {
 | 
			
		||||
	p := new(float64)
 | 
			
		||||
	f.Float64VarP(p, name, shorthand, value, usage)
 | 
			
		||||
	return p
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Float64 defines a float64 flag with specified name, default value, and usage string.
 | 
			
		||||
// The return value is the address of a float64 variable that stores the value of the flag.
 | 
			
		||||
func Float64(name string, value float64, usage string) *float64 {
 | 
			
		||||
	return CommandLine.Float64P(name, "", value, usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Float64P is like Float64, but accepts a shorthand letter that can be used after a single dash.
 | 
			
		||||
func Float64P(name, shorthand string, value float64, usage string) *float64 {
 | 
			
		||||
	return CommandLine.Float64P(name, shorthand, value, usage)
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										166
									
								
								vendor/github.com/spf13/pflag/float64_slice.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										166
									
								
								vendor/github.com/spf13/pflag/float64_slice.go
									
									
									
										generated
									
									
										vendored
									
									
								
							@@ -1,166 +0,0 @@
 | 
			
		||||
package pflag
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"strconv"
 | 
			
		||||
	"strings"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// -- float64Slice Value
 | 
			
		||||
type float64SliceValue struct {
 | 
			
		||||
	value   *[]float64
 | 
			
		||||
	changed bool
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func newFloat64SliceValue(val []float64, p *[]float64) *float64SliceValue {
 | 
			
		||||
	isv := new(float64SliceValue)
 | 
			
		||||
	isv.value = p
 | 
			
		||||
	*isv.value = val
 | 
			
		||||
	return isv
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (s *float64SliceValue) Set(val string) error {
 | 
			
		||||
	ss := strings.Split(val, ",")
 | 
			
		||||
	out := make([]float64, len(ss))
 | 
			
		||||
	for i, d := range ss {
 | 
			
		||||
		var err error
 | 
			
		||||
		out[i], err = strconv.ParseFloat(d, 64)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			return err
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
	}
 | 
			
		||||
	if !s.changed {
 | 
			
		||||
		*s.value = out
 | 
			
		||||
	} else {
 | 
			
		||||
		*s.value = append(*s.value, out...)
 | 
			
		||||
	}
 | 
			
		||||
	s.changed = true
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (s *float64SliceValue) Type() string {
 | 
			
		||||
	return "float64Slice"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (s *float64SliceValue) String() string {
 | 
			
		||||
	out := make([]string, len(*s.value))
 | 
			
		||||
	for i, d := range *s.value {
 | 
			
		||||
		out[i] = fmt.Sprintf("%f", d)
 | 
			
		||||
	}
 | 
			
		||||
	return "[" + strings.Join(out, ",") + "]"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (s *float64SliceValue) fromString(val string) (float64, error) {
 | 
			
		||||
	return strconv.ParseFloat(val, 64)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (s *float64SliceValue) toString(val float64) string {
 | 
			
		||||
	return fmt.Sprintf("%f", val)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (s *float64SliceValue) Append(val string) error {
 | 
			
		||||
	i, err := s.fromString(val)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return err
 | 
			
		||||
	}
 | 
			
		||||
	*s.value = append(*s.value, i)
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (s *float64SliceValue) Replace(val []string) error {
 | 
			
		||||
	out := make([]float64, len(val))
 | 
			
		||||
	for i, d := range val {
 | 
			
		||||
		var err error
 | 
			
		||||
		out[i], err = s.fromString(d)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			return err
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	*s.value = out
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (s *float64SliceValue) GetSlice() []string {
 | 
			
		||||
	out := make([]string, len(*s.value))
 | 
			
		||||
	for i, d := range *s.value {
 | 
			
		||||
		out[i] = s.toString(d)
 | 
			
		||||
	}
 | 
			
		||||
	return out
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func float64SliceConv(val string) (interface{}, error) {
 | 
			
		||||
	val = strings.Trim(val, "[]")
 | 
			
		||||
	// Empty string would cause a slice with one (empty) entry
 | 
			
		||||
	if len(val) == 0 {
 | 
			
		||||
		return []float64{}, nil
 | 
			
		||||
	}
 | 
			
		||||
	ss := strings.Split(val, ",")
 | 
			
		||||
	out := make([]float64, len(ss))
 | 
			
		||||
	for i, d := range ss {
 | 
			
		||||
		var err error
 | 
			
		||||
		out[i], err = strconv.ParseFloat(d, 64)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			return nil, err
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
	}
 | 
			
		||||
	return out, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// GetFloat64Slice return the []float64 value of a flag with the given name
 | 
			
		||||
func (f *FlagSet) GetFloat64Slice(name string) ([]float64, error) {
 | 
			
		||||
	val, err := f.getFlagType(name, "float64Slice", float64SliceConv)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return []float64{}, err
 | 
			
		||||
	}
 | 
			
		||||
	return val.([]float64), nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Float64SliceVar defines a float64Slice flag with specified name, default value, and usage string.
 | 
			
		||||
// The argument p points to a []float64 variable in which to store the value of the flag.
 | 
			
		||||
func (f *FlagSet) Float64SliceVar(p *[]float64, name string, value []float64, usage string) {
 | 
			
		||||
	f.VarP(newFloat64SliceValue(value, p), name, "", usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Float64SliceVarP is like Float64SliceVar, but accepts a shorthand letter that can be used after a single dash.
 | 
			
		||||
func (f *FlagSet) Float64SliceVarP(p *[]float64, name, shorthand string, value []float64, usage string) {
 | 
			
		||||
	f.VarP(newFloat64SliceValue(value, p), name, shorthand, usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Float64SliceVar defines a float64[] flag with specified name, default value, and usage string.
 | 
			
		||||
// The argument p points to a float64[] variable in which to store the value of the flag.
 | 
			
		||||
func Float64SliceVar(p *[]float64, name string, value []float64, usage string) {
 | 
			
		||||
	CommandLine.VarP(newFloat64SliceValue(value, p), name, "", usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Float64SliceVarP is like Float64SliceVar, but accepts a shorthand letter that can be used after a single dash.
 | 
			
		||||
func Float64SliceVarP(p *[]float64, name, shorthand string, value []float64, usage string) {
 | 
			
		||||
	CommandLine.VarP(newFloat64SliceValue(value, p), name, shorthand, usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Float64Slice defines a []float64 flag with specified name, default value, and usage string.
 | 
			
		||||
// The return value is the address of a []float64 variable that stores the value of the flag.
 | 
			
		||||
func (f *FlagSet) Float64Slice(name string, value []float64, usage string) *[]float64 {
 | 
			
		||||
	p := []float64{}
 | 
			
		||||
	f.Float64SliceVarP(&p, name, "", value, usage)
 | 
			
		||||
	return &p
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Float64SliceP is like Float64Slice, but accepts a shorthand letter that can be used after a single dash.
 | 
			
		||||
func (f *FlagSet) Float64SliceP(name, shorthand string, value []float64, usage string) *[]float64 {
 | 
			
		||||
	p := []float64{}
 | 
			
		||||
	f.Float64SliceVarP(&p, name, shorthand, value, usage)
 | 
			
		||||
	return &p
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Float64Slice defines a []float64 flag with specified name, default value, and usage string.
 | 
			
		||||
// The return value is the address of a []float64 variable that stores the value of the flag.
 | 
			
		||||
func Float64Slice(name string, value []float64, usage string) *[]float64 {
 | 
			
		||||
	return CommandLine.Float64SliceP(name, "", value, usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Float64SliceP is like Float64Slice, but accepts a shorthand letter that can be used after a single dash.
 | 
			
		||||
func Float64SliceP(name, shorthand string, value []float64, usage string) *[]float64 {
 | 
			
		||||
	return CommandLine.Float64SliceP(name, shorthand, value, usage)
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										105
									
								
								vendor/github.com/spf13/pflag/golangflag.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										105
									
								
								vendor/github.com/spf13/pflag/golangflag.go
									
									
									
										generated
									
									
										vendored
									
									
								
							@@ -1,105 +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.
 | 
			
		||||
 | 
			
		||||
package pflag
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	goflag "flag"
 | 
			
		||||
	"reflect"
 | 
			
		||||
	"strings"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// flagValueWrapper implements pflag.Value around a flag.Value.  The main
 | 
			
		||||
// difference here is the addition of the Type method that returns a string
 | 
			
		||||
// name of the type.  As this is generally unknown, we approximate that with
 | 
			
		||||
// reflection.
 | 
			
		||||
type flagValueWrapper struct {
 | 
			
		||||
	inner    goflag.Value
 | 
			
		||||
	flagType string
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// We are just copying the boolFlag interface out of goflag as that is what
 | 
			
		||||
// they use to decide if a flag should get "true" when no arg is given.
 | 
			
		||||
type goBoolFlag interface {
 | 
			
		||||
	goflag.Value
 | 
			
		||||
	IsBoolFlag() bool
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func wrapFlagValue(v goflag.Value) Value {
 | 
			
		||||
	// If the flag.Value happens to also be a pflag.Value, just use it directly.
 | 
			
		||||
	if pv, ok := v.(Value); ok {
 | 
			
		||||
		return pv
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	pv := &flagValueWrapper{
 | 
			
		||||
		inner: v,
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	t := reflect.TypeOf(v)
 | 
			
		||||
	if t.Kind() == reflect.Interface || t.Kind() == reflect.Ptr {
 | 
			
		||||
		t = t.Elem()
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	pv.flagType = strings.TrimSuffix(t.Name(), "Value")
 | 
			
		||||
	return pv
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (v *flagValueWrapper) String() string {
 | 
			
		||||
	return v.inner.String()
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (v *flagValueWrapper) Set(s string) error {
 | 
			
		||||
	return v.inner.Set(s)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (v *flagValueWrapper) Type() string {
 | 
			
		||||
	return v.flagType
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// PFlagFromGoFlag will return a *pflag.Flag given a *flag.Flag
 | 
			
		||||
// If the *flag.Flag.Name was a single character (ex: `v`) it will be accessiblei
 | 
			
		||||
// with both `-v` and `--v` in flags. If the golang flag was more than a single
 | 
			
		||||
// character (ex: `verbose`) it will only be accessible via `--verbose`
 | 
			
		||||
func PFlagFromGoFlag(goflag *goflag.Flag) *Flag {
 | 
			
		||||
	// Remember the default value as a string; it won't change.
 | 
			
		||||
	flag := &Flag{
 | 
			
		||||
		Name:  goflag.Name,
 | 
			
		||||
		Usage: goflag.Usage,
 | 
			
		||||
		Value: wrapFlagValue(goflag.Value),
 | 
			
		||||
		// Looks like golang flags don't set DefValue correctly  :-(
 | 
			
		||||
		//DefValue: goflag.DefValue,
 | 
			
		||||
		DefValue: goflag.Value.String(),
 | 
			
		||||
	}
 | 
			
		||||
	// Ex: if the golang flag was -v, allow both -v and --v to work
 | 
			
		||||
	if len(flag.Name) == 1 {
 | 
			
		||||
		flag.Shorthand = flag.Name
 | 
			
		||||
	}
 | 
			
		||||
	if fv, ok := goflag.Value.(goBoolFlag); ok && fv.IsBoolFlag() {
 | 
			
		||||
		flag.NoOptDefVal = "true"
 | 
			
		||||
	}
 | 
			
		||||
	return flag
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// AddGoFlag will add the given *flag.Flag to the pflag.FlagSet
 | 
			
		||||
func (f *FlagSet) AddGoFlag(goflag *goflag.Flag) {
 | 
			
		||||
	if f.Lookup(goflag.Name) != nil {
 | 
			
		||||
		return
 | 
			
		||||
	}
 | 
			
		||||
	newflag := PFlagFromGoFlag(goflag)
 | 
			
		||||
	f.AddFlag(newflag)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// AddGoFlagSet will add the given *flag.FlagSet to the pflag.FlagSet
 | 
			
		||||
func (f *FlagSet) AddGoFlagSet(newSet *goflag.FlagSet) {
 | 
			
		||||
	if newSet == nil {
 | 
			
		||||
		return
 | 
			
		||||
	}
 | 
			
		||||
	newSet.VisitAll(func(goflag *goflag.Flag) {
 | 
			
		||||
		f.AddGoFlag(goflag)
 | 
			
		||||
	})
 | 
			
		||||
	if f.addedGoFlagSets == nil {
 | 
			
		||||
		f.addedGoFlagSets = make([]*goflag.FlagSet, 0)
 | 
			
		||||
	}
 | 
			
		||||
	f.addedGoFlagSets = append(f.addedGoFlagSets, newSet)
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										84
									
								
								vendor/github.com/spf13/pflag/int.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										84
									
								
								vendor/github.com/spf13/pflag/int.go
									
									
									
										generated
									
									
										vendored
									
									
								
							@@ -1,84 +0,0 @@
 | 
			
		||||
package pflag
 | 
			
		||||
 | 
			
		||||
import "strconv"
 | 
			
		||||
 | 
			
		||||
// -- int Value
 | 
			
		||||
type intValue int
 | 
			
		||||
 | 
			
		||||
func newIntValue(val int, p *int) *intValue {
 | 
			
		||||
	*p = val
 | 
			
		||||
	return (*intValue)(p)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (i *intValue) Set(s string) error {
 | 
			
		||||
	v, err := strconv.ParseInt(s, 0, 64)
 | 
			
		||||
	*i = intValue(v)
 | 
			
		||||
	return err
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (i *intValue) Type() string {
 | 
			
		||||
	return "int"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (i *intValue) String() string { return strconv.Itoa(int(*i)) }
 | 
			
		||||
 | 
			
		||||
func intConv(sval string) (interface{}, error) {
 | 
			
		||||
	return strconv.Atoi(sval)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// GetInt return the int value of a flag with the given name
 | 
			
		||||
func (f *FlagSet) GetInt(name string) (int, error) {
 | 
			
		||||
	val, err := f.getFlagType(name, "int", intConv)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return 0, err
 | 
			
		||||
	}
 | 
			
		||||
	return val.(int), nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// IntVar defines an int flag with specified name, default value, and usage string.
 | 
			
		||||
// The argument p points to an int variable in which to store the value of the flag.
 | 
			
		||||
func (f *FlagSet) IntVar(p *int, name string, value int, usage string) {
 | 
			
		||||
	f.VarP(newIntValue(value, p), name, "", usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// IntVarP is like IntVar, but accepts a shorthand letter that can be used after a single dash.
 | 
			
		||||
func (f *FlagSet) IntVarP(p *int, name, shorthand string, value int, usage string) {
 | 
			
		||||
	f.VarP(newIntValue(value, p), name, shorthand, usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// IntVar defines an int flag with specified name, default value, and usage string.
 | 
			
		||||
// The argument p points to an int variable in which to store the value of the flag.
 | 
			
		||||
func IntVar(p *int, name string, value int, usage string) {
 | 
			
		||||
	CommandLine.VarP(newIntValue(value, p), name, "", usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// IntVarP is like IntVar, but accepts a shorthand letter that can be used after a single dash.
 | 
			
		||||
func IntVarP(p *int, name, shorthand string, value int, usage string) {
 | 
			
		||||
	CommandLine.VarP(newIntValue(value, p), name, shorthand, usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Int defines an int flag with specified name, default value, and usage string.
 | 
			
		||||
// The return value is the address of an int variable that stores the value of the flag.
 | 
			
		||||
func (f *FlagSet) Int(name string, value int, usage string) *int {
 | 
			
		||||
	p := new(int)
 | 
			
		||||
	f.IntVarP(p, name, "", value, usage)
 | 
			
		||||
	return p
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// IntP is like Int, but accepts a shorthand letter that can be used after a single dash.
 | 
			
		||||
func (f *FlagSet) IntP(name, shorthand string, value int, usage string) *int {
 | 
			
		||||
	p := new(int)
 | 
			
		||||
	f.IntVarP(p, name, shorthand, value, usage)
 | 
			
		||||
	return p
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Int defines an int flag with specified name, default value, and usage string.
 | 
			
		||||
// The return value is the address of an int variable that stores the value of the flag.
 | 
			
		||||
func Int(name string, value int, usage string) *int {
 | 
			
		||||
	return CommandLine.IntP(name, "", value, usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// IntP is like Int, but accepts a shorthand letter that can be used after a single dash.
 | 
			
		||||
func IntP(name, shorthand string, value int, usage string) *int {
 | 
			
		||||
	return CommandLine.IntP(name, shorthand, value, usage)
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										88
									
								
								vendor/github.com/spf13/pflag/int16.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										88
									
								
								vendor/github.com/spf13/pflag/int16.go
									
									
									
										generated
									
									
										vendored
									
									
								
							@@ -1,88 +0,0 @@
 | 
			
		||||
package pflag
 | 
			
		||||
 | 
			
		||||
import "strconv"
 | 
			
		||||
 | 
			
		||||
// -- int16 Value
 | 
			
		||||
type int16Value int16
 | 
			
		||||
 | 
			
		||||
func newInt16Value(val int16, p *int16) *int16Value {
 | 
			
		||||
	*p = val
 | 
			
		||||
	return (*int16Value)(p)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (i *int16Value) Set(s string) error {
 | 
			
		||||
	v, err := strconv.ParseInt(s, 0, 16)
 | 
			
		||||
	*i = int16Value(v)
 | 
			
		||||
	return err
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (i *int16Value) Type() string {
 | 
			
		||||
	return "int16"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (i *int16Value) String() string { return strconv.FormatInt(int64(*i), 10) }
 | 
			
		||||
 | 
			
		||||
func int16Conv(sval string) (interface{}, error) {
 | 
			
		||||
	v, err := strconv.ParseInt(sval, 0, 16)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return 0, err
 | 
			
		||||
	}
 | 
			
		||||
	return int16(v), nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// GetInt16 returns the int16 value of a flag with the given name
 | 
			
		||||
func (f *FlagSet) GetInt16(name string) (int16, error) {
 | 
			
		||||
	val, err := f.getFlagType(name, "int16", int16Conv)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return 0, err
 | 
			
		||||
	}
 | 
			
		||||
	return val.(int16), nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Int16Var defines an int16 flag with specified name, default value, and usage string.
 | 
			
		||||
// The argument p points to an int16 variable in which to store the value of the flag.
 | 
			
		||||
func (f *FlagSet) Int16Var(p *int16, name string, value int16, usage string) {
 | 
			
		||||
	f.VarP(newInt16Value(value, p), name, "", usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Int16VarP is like Int16Var, but accepts a shorthand letter that can be used after a single dash.
 | 
			
		||||
func (f *FlagSet) Int16VarP(p *int16, name, shorthand string, value int16, usage string) {
 | 
			
		||||
	f.VarP(newInt16Value(value, p), name, shorthand, usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Int16Var defines an int16 flag with specified name, default value, and usage string.
 | 
			
		||||
// The argument p points to an int16 variable in which to store the value of the flag.
 | 
			
		||||
func Int16Var(p *int16, name string, value int16, usage string) {
 | 
			
		||||
	CommandLine.VarP(newInt16Value(value, p), name, "", usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Int16VarP is like Int16Var, but accepts a shorthand letter that can be used after a single dash.
 | 
			
		||||
func Int16VarP(p *int16, name, shorthand string, value int16, usage string) {
 | 
			
		||||
	CommandLine.VarP(newInt16Value(value, p), name, shorthand, usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Int16 defines an int16 flag with specified name, default value, and usage string.
 | 
			
		||||
// The return value is the address of an int16 variable that stores the value of the flag.
 | 
			
		||||
func (f *FlagSet) Int16(name string, value int16, usage string) *int16 {
 | 
			
		||||
	p := new(int16)
 | 
			
		||||
	f.Int16VarP(p, name, "", value, usage)
 | 
			
		||||
	return p
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Int16P is like Int16, but accepts a shorthand letter that can be used after a single dash.
 | 
			
		||||
func (f *FlagSet) Int16P(name, shorthand string, value int16, usage string) *int16 {
 | 
			
		||||
	p := new(int16)
 | 
			
		||||
	f.Int16VarP(p, name, shorthand, value, usage)
 | 
			
		||||
	return p
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Int16 defines an int16 flag with specified name, default value, and usage string.
 | 
			
		||||
// The return value is the address of an int16 variable that stores the value of the flag.
 | 
			
		||||
func Int16(name string, value int16, usage string) *int16 {
 | 
			
		||||
	return CommandLine.Int16P(name, "", value, usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Int16P is like Int16, but accepts a shorthand letter that can be used after a single dash.
 | 
			
		||||
func Int16P(name, shorthand string, value int16, usage string) *int16 {
 | 
			
		||||
	return CommandLine.Int16P(name, shorthand, value, usage)
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										88
									
								
								vendor/github.com/spf13/pflag/int32.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										88
									
								
								vendor/github.com/spf13/pflag/int32.go
									
									
									
										generated
									
									
										vendored
									
									
								
							@@ -1,88 +0,0 @@
 | 
			
		||||
package pflag
 | 
			
		||||
 | 
			
		||||
import "strconv"
 | 
			
		||||
 | 
			
		||||
// -- int32 Value
 | 
			
		||||
type int32Value int32
 | 
			
		||||
 | 
			
		||||
func newInt32Value(val int32, p *int32) *int32Value {
 | 
			
		||||
	*p = val
 | 
			
		||||
	return (*int32Value)(p)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (i *int32Value) Set(s string) error {
 | 
			
		||||
	v, err := strconv.ParseInt(s, 0, 32)
 | 
			
		||||
	*i = int32Value(v)
 | 
			
		||||
	return err
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (i *int32Value) Type() string {
 | 
			
		||||
	return "int32"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (i *int32Value) String() string { return strconv.FormatInt(int64(*i), 10) }
 | 
			
		||||
 | 
			
		||||
func int32Conv(sval string) (interface{}, error) {
 | 
			
		||||
	v, err := strconv.ParseInt(sval, 0, 32)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return 0, err
 | 
			
		||||
	}
 | 
			
		||||
	return int32(v), nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// GetInt32 return the int32 value of a flag with the given name
 | 
			
		||||
func (f *FlagSet) GetInt32(name string) (int32, error) {
 | 
			
		||||
	val, err := f.getFlagType(name, "int32", int32Conv)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return 0, err
 | 
			
		||||
	}
 | 
			
		||||
	return val.(int32), nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Int32Var defines an int32 flag with specified name, default value, and usage string.
 | 
			
		||||
// The argument p points to an int32 variable in which to store the value of the flag.
 | 
			
		||||
func (f *FlagSet) Int32Var(p *int32, name string, value int32, usage string) {
 | 
			
		||||
	f.VarP(newInt32Value(value, p), name, "", usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Int32VarP is like Int32Var, but accepts a shorthand letter that can be used after a single dash.
 | 
			
		||||
func (f *FlagSet) Int32VarP(p *int32, name, shorthand string, value int32, usage string) {
 | 
			
		||||
	f.VarP(newInt32Value(value, p), name, shorthand, usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Int32Var defines an int32 flag with specified name, default value, and usage string.
 | 
			
		||||
// The argument p points to an int32 variable in which to store the value of the flag.
 | 
			
		||||
func Int32Var(p *int32, name string, value int32, usage string) {
 | 
			
		||||
	CommandLine.VarP(newInt32Value(value, p), name, "", usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Int32VarP is like Int32Var, but accepts a shorthand letter that can be used after a single dash.
 | 
			
		||||
func Int32VarP(p *int32, name, shorthand string, value int32, usage string) {
 | 
			
		||||
	CommandLine.VarP(newInt32Value(value, p), name, shorthand, usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Int32 defines an int32 flag with specified name, default value, and usage string.
 | 
			
		||||
// The return value is the address of an int32 variable that stores the value of the flag.
 | 
			
		||||
func (f *FlagSet) Int32(name string, value int32, usage string) *int32 {
 | 
			
		||||
	p := new(int32)
 | 
			
		||||
	f.Int32VarP(p, name, "", value, usage)
 | 
			
		||||
	return p
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Int32P is like Int32, but accepts a shorthand letter that can be used after a single dash.
 | 
			
		||||
func (f *FlagSet) Int32P(name, shorthand string, value int32, usage string) *int32 {
 | 
			
		||||
	p := new(int32)
 | 
			
		||||
	f.Int32VarP(p, name, shorthand, value, usage)
 | 
			
		||||
	return p
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Int32 defines an int32 flag with specified name, default value, and usage string.
 | 
			
		||||
// The return value is the address of an int32 variable that stores the value of the flag.
 | 
			
		||||
func Int32(name string, value int32, usage string) *int32 {
 | 
			
		||||
	return CommandLine.Int32P(name, "", value, usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Int32P is like Int32, but accepts a shorthand letter that can be used after a single dash.
 | 
			
		||||
func Int32P(name, shorthand string, value int32, usage string) *int32 {
 | 
			
		||||
	return CommandLine.Int32P(name, shorthand, value, usage)
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										174
									
								
								vendor/github.com/spf13/pflag/int32_slice.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										174
									
								
								vendor/github.com/spf13/pflag/int32_slice.go
									
									
									
										generated
									
									
										vendored
									
									
								
							@@ -1,174 +0,0 @@
 | 
			
		||||
package pflag
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"strconv"
 | 
			
		||||
	"strings"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// -- int32Slice Value
 | 
			
		||||
type int32SliceValue struct {
 | 
			
		||||
	value   *[]int32
 | 
			
		||||
	changed bool
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func newInt32SliceValue(val []int32, p *[]int32) *int32SliceValue {
 | 
			
		||||
	isv := new(int32SliceValue)
 | 
			
		||||
	isv.value = p
 | 
			
		||||
	*isv.value = val
 | 
			
		||||
	return isv
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (s *int32SliceValue) Set(val string) error {
 | 
			
		||||
	ss := strings.Split(val, ",")
 | 
			
		||||
	out := make([]int32, len(ss))
 | 
			
		||||
	for i, d := range ss {
 | 
			
		||||
		var err error
 | 
			
		||||
		var temp64 int64
 | 
			
		||||
		temp64, err = strconv.ParseInt(d, 0, 32)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			return err
 | 
			
		||||
		}
 | 
			
		||||
		out[i] = int32(temp64)
 | 
			
		||||
 | 
			
		||||
	}
 | 
			
		||||
	if !s.changed {
 | 
			
		||||
		*s.value = out
 | 
			
		||||
	} else {
 | 
			
		||||
		*s.value = append(*s.value, out...)
 | 
			
		||||
	}
 | 
			
		||||
	s.changed = true
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (s *int32SliceValue) Type() string {
 | 
			
		||||
	return "int32Slice"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (s *int32SliceValue) String() string {
 | 
			
		||||
	out := make([]string, len(*s.value))
 | 
			
		||||
	for i, d := range *s.value {
 | 
			
		||||
		out[i] = fmt.Sprintf("%d", d)
 | 
			
		||||
	}
 | 
			
		||||
	return "[" + strings.Join(out, ",") + "]"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (s *int32SliceValue) fromString(val string) (int32, error) {
 | 
			
		||||
	t64, err := strconv.ParseInt(val, 0, 32)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return 0, err
 | 
			
		||||
	}
 | 
			
		||||
	return int32(t64), nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (s *int32SliceValue) toString(val int32) string {
 | 
			
		||||
	return fmt.Sprintf("%d", val)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (s *int32SliceValue) Append(val string) error {
 | 
			
		||||
	i, err := s.fromString(val)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return err
 | 
			
		||||
	}
 | 
			
		||||
	*s.value = append(*s.value, i)
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (s *int32SliceValue) Replace(val []string) error {
 | 
			
		||||
	out := make([]int32, len(val))
 | 
			
		||||
	for i, d := range val {
 | 
			
		||||
		var err error
 | 
			
		||||
		out[i], err = s.fromString(d)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			return err
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	*s.value = out
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (s *int32SliceValue) GetSlice() []string {
 | 
			
		||||
	out := make([]string, len(*s.value))
 | 
			
		||||
	for i, d := range *s.value {
 | 
			
		||||
		out[i] = s.toString(d)
 | 
			
		||||
	}
 | 
			
		||||
	return out
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func int32SliceConv(val string) (interface{}, error) {
 | 
			
		||||
	val = strings.Trim(val, "[]")
 | 
			
		||||
	// Empty string would cause a slice with one (empty) entry
 | 
			
		||||
	if len(val) == 0 {
 | 
			
		||||
		return []int32{}, nil
 | 
			
		||||
	}
 | 
			
		||||
	ss := strings.Split(val, ",")
 | 
			
		||||
	out := make([]int32, len(ss))
 | 
			
		||||
	for i, d := range ss {
 | 
			
		||||
		var err error
 | 
			
		||||
		var temp64 int64
 | 
			
		||||
		temp64, err = strconv.ParseInt(d, 0, 32)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			return nil, err
 | 
			
		||||
		}
 | 
			
		||||
		out[i] = int32(temp64)
 | 
			
		||||
 | 
			
		||||
	}
 | 
			
		||||
	return out, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// GetInt32Slice return the []int32 value of a flag with the given name
 | 
			
		||||
func (f *FlagSet) GetInt32Slice(name string) ([]int32, error) {
 | 
			
		||||
	val, err := f.getFlagType(name, "int32Slice", int32SliceConv)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return []int32{}, err
 | 
			
		||||
	}
 | 
			
		||||
	return val.([]int32), nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Int32SliceVar defines a int32Slice flag with specified name, default value, and usage string.
 | 
			
		||||
// The argument p points to a []int32 variable in which to store the value of the flag.
 | 
			
		||||
func (f *FlagSet) Int32SliceVar(p *[]int32, name string, value []int32, usage string) {
 | 
			
		||||
	f.VarP(newInt32SliceValue(value, p), name, "", usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Int32SliceVarP is like Int32SliceVar, but accepts a shorthand letter that can be used after a single dash.
 | 
			
		||||
func (f *FlagSet) Int32SliceVarP(p *[]int32, name, shorthand string, value []int32, usage string) {
 | 
			
		||||
	f.VarP(newInt32SliceValue(value, p), name, shorthand, usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Int32SliceVar defines a int32[] flag with specified name, default value, and usage string.
 | 
			
		||||
// The argument p points to a int32[] variable in which to store the value of the flag.
 | 
			
		||||
func Int32SliceVar(p *[]int32, name string, value []int32, usage string) {
 | 
			
		||||
	CommandLine.VarP(newInt32SliceValue(value, p), name, "", usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Int32SliceVarP is like Int32SliceVar, but accepts a shorthand letter that can be used after a single dash.
 | 
			
		||||
func Int32SliceVarP(p *[]int32, name, shorthand string, value []int32, usage string) {
 | 
			
		||||
	CommandLine.VarP(newInt32SliceValue(value, p), name, shorthand, usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Int32Slice defines a []int32 flag with specified name, default value, and usage string.
 | 
			
		||||
// The return value is the address of a []int32 variable that stores the value of the flag.
 | 
			
		||||
func (f *FlagSet) Int32Slice(name string, value []int32, usage string) *[]int32 {
 | 
			
		||||
	p := []int32{}
 | 
			
		||||
	f.Int32SliceVarP(&p, name, "", value, usage)
 | 
			
		||||
	return &p
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Int32SliceP is like Int32Slice, but accepts a shorthand letter that can be used after a single dash.
 | 
			
		||||
func (f *FlagSet) Int32SliceP(name, shorthand string, value []int32, usage string) *[]int32 {
 | 
			
		||||
	p := []int32{}
 | 
			
		||||
	f.Int32SliceVarP(&p, name, shorthand, value, usage)
 | 
			
		||||
	return &p
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Int32Slice defines a []int32 flag with specified name, default value, and usage string.
 | 
			
		||||
// The return value is the address of a []int32 variable that stores the value of the flag.
 | 
			
		||||
func Int32Slice(name string, value []int32, usage string) *[]int32 {
 | 
			
		||||
	return CommandLine.Int32SliceP(name, "", value, usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Int32SliceP is like Int32Slice, but accepts a shorthand letter that can be used after a single dash.
 | 
			
		||||
func Int32SliceP(name, shorthand string, value []int32, usage string) *[]int32 {
 | 
			
		||||
	return CommandLine.Int32SliceP(name, shorthand, value, usage)
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										84
									
								
								vendor/github.com/spf13/pflag/int64.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										84
									
								
								vendor/github.com/spf13/pflag/int64.go
									
									
									
										generated
									
									
										vendored
									
									
								
							@@ -1,84 +0,0 @@
 | 
			
		||||
package pflag
 | 
			
		||||
 | 
			
		||||
import "strconv"
 | 
			
		||||
 | 
			
		||||
// -- int64 Value
 | 
			
		||||
type int64Value int64
 | 
			
		||||
 | 
			
		||||
func newInt64Value(val int64, p *int64) *int64Value {
 | 
			
		||||
	*p = val
 | 
			
		||||
	return (*int64Value)(p)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (i *int64Value) Set(s string) error {
 | 
			
		||||
	v, err := strconv.ParseInt(s, 0, 64)
 | 
			
		||||
	*i = int64Value(v)
 | 
			
		||||
	return err
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (i *int64Value) Type() string {
 | 
			
		||||
	return "int64"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (i *int64Value) String() string { return strconv.FormatInt(int64(*i), 10) }
 | 
			
		||||
 | 
			
		||||
func int64Conv(sval string) (interface{}, error) {
 | 
			
		||||
	return strconv.ParseInt(sval, 0, 64)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// GetInt64 return the int64 value of a flag with the given name
 | 
			
		||||
func (f *FlagSet) GetInt64(name string) (int64, error) {
 | 
			
		||||
	val, err := f.getFlagType(name, "int64", int64Conv)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return 0, err
 | 
			
		||||
	}
 | 
			
		||||
	return val.(int64), nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Int64Var defines an int64 flag with specified name, default value, and usage string.
 | 
			
		||||
// The argument p points to an int64 variable in which to store the value of the flag.
 | 
			
		||||
func (f *FlagSet) Int64Var(p *int64, name string, value int64, usage string) {
 | 
			
		||||
	f.VarP(newInt64Value(value, p), name, "", usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Int64VarP is like Int64Var, but accepts a shorthand letter that can be used after a single dash.
 | 
			
		||||
func (f *FlagSet) Int64VarP(p *int64, name, shorthand string, value int64, usage string) {
 | 
			
		||||
	f.VarP(newInt64Value(value, p), name, shorthand, usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Int64Var defines an int64 flag with specified name, default value, and usage string.
 | 
			
		||||
// The argument p points to an int64 variable in which to store the value of the flag.
 | 
			
		||||
func Int64Var(p *int64, name string, value int64, usage string) {
 | 
			
		||||
	CommandLine.VarP(newInt64Value(value, p), name, "", usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Int64VarP is like Int64Var, but accepts a shorthand letter that can be used after a single dash.
 | 
			
		||||
func Int64VarP(p *int64, name, shorthand string, value int64, usage string) {
 | 
			
		||||
	CommandLine.VarP(newInt64Value(value, p), name, shorthand, usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Int64 defines an int64 flag with specified name, default value, and usage string.
 | 
			
		||||
// The return value is the address of an int64 variable that stores the value of the flag.
 | 
			
		||||
func (f *FlagSet) Int64(name string, value int64, usage string) *int64 {
 | 
			
		||||
	p := new(int64)
 | 
			
		||||
	f.Int64VarP(p, name, "", value, usage)
 | 
			
		||||
	return p
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Int64P is like Int64, but accepts a shorthand letter that can be used after a single dash.
 | 
			
		||||
func (f *FlagSet) Int64P(name, shorthand string, value int64, usage string) *int64 {
 | 
			
		||||
	p := new(int64)
 | 
			
		||||
	f.Int64VarP(p, name, shorthand, value, usage)
 | 
			
		||||
	return p
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Int64 defines an int64 flag with specified name, default value, and usage string.
 | 
			
		||||
// The return value is the address of an int64 variable that stores the value of the flag.
 | 
			
		||||
func Int64(name string, value int64, usage string) *int64 {
 | 
			
		||||
	return CommandLine.Int64P(name, "", value, usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Int64P is like Int64, but accepts a shorthand letter that can be used after a single dash.
 | 
			
		||||
func Int64P(name, shorthand string, value int64, usage string) *int64 {
 | 
			
		||||
	return CommandLine.Int64P(name, shorthand, value, usage)
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										166
									
								
								vendor/github.com/spf13/pflag/int64_slice.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										166
									
								
								vendor/github.com/spf13/pflag/int64_slice.go
									
									
									
										generated
									
									
										vendored
									
									
								
							@@ -1,166 +0,0 @@
 | 
			
		||||
package pflag
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"strconv"
 | 
			
		||||
	"strings"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// -- int64Slice Value
 | 
			
		||||
type int64SliceValue struct {
 | 
			
		||||
	value   *[]int64
 | 
			
		||||
	changed bool
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func newInt64SliceValue(val []int64, p *[]int64) *int64SliceValue {
 | 
			
		||||
	isv := new(int64SliceValue)
 | 
			
		||||
	isv.value = p
 | 
			
		||||
	*isv.value = val
 | 
			
		||||
	return isv
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (s *int64SliceValue) Set(val string) error {
 | 
			
		||||
	ss := strings.Split(val, ",")
 | 
			
		||||
	out := make([]int64, len(ss))
 | 
			
		||||
	for i, d := range ss {
 | 
			
		||||
		var err error
 | 
			
		||||
		out[i], err = strconv.ParseInt(d, 0, 64)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			return err
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
	}
 | 
			
		||||
	if !s.changed {
 | 
			
		||||
		*s.value = out
 | 
			
		||||
	} else {
 | 
			
		||||
		*s.value = append(*s.value, out...)
 | 
			
		||||
	}
 | 
			
		||||
	s.changed = true
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (s *int64SliceValue) Type() string {
 | 
			
		||||
	return "int64Slice"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (s *int64SliceValue) String() string {
 | 
			
		||||
	out := make([]string, len(*s.value))
 | 
			
		||||
	for i, d := range *s.value {
 | 
			
		||||
		out[i] = fmt.Sprintf("%d", d)
 | 
			
		||||
	}
 | 
			
		||||
	return "[" + strings.Join(out, ",") + "]"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (s *int64SliceValue) fromString(val string) (int64, error) {
 | 
			
		||||
	return strconv.ParseInt(val, 0, 64)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (s *int64SliceValue) toString(val int64) string {
 | 
			
		||||
	return fmt.Sprintf("%d", val)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (s *int64SliceValue) Append(val string) error {
 | 
			
		||||
	i, err := s.fromString(val)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return err
 | 
			
		||||
	}
 | 
			
		||||
	*s.value = append(*s.value, i)
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (s *int64SliceValue) Replace(val []string) error {
 | 
			
		||||
	out := make([]int64, len(val))
 | 
			
		||||
	for i, d := range val {
 | 
			
		||||
		var err error
 | 
			
		||||
		out[i], err = s.fromString(d)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			return err
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	*s.value = out
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (s *int64SliceValue) GetSlice() []string {
 | 
			
		||||
	out := make([]string, len(*s.value))
 | 
			
		||||
	for i, d := range *s.value {
 | 
			
		||||
		out[i] = s.toString(d)
 | 
			
		||||
	}
 | 
			
		||||
	return out
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func int64SliceConv(val string) (interface{}, error) {
 | 
			
		||||
	val = strings.Trim(val, "[]")
 | 
			
		||||
	// Empty string would cause a slice with one (empty) entry
 | 
			
		||||
	if len(val) == 0 {
 | 
			
		||||
		return []int64{}, nil
 | 
			
		||||
	}
 | 
			
		||||
	ss := strings.Split(val, ",")
 | 
			
		||||
	out := make([]int64, len(ss))
 | 
			
		||||
	for i, d := range ss {
 | 
			
		||||
		var err error
 | 
			
		||||
		out[i], err = strconv.ParseInt(d, 0, 64)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			return nil, err
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
	}
 | 
			
		||||
	return out, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// GetInt64Slice return the []int64 value of a flag with the given name
 | 
			
		||||
func (f *FlagSet) GetInt64Slice(name string) ([]int64, error) {
 | 
			
		||||
	val, err := f.getFlagType(name, "int64Slice", int64SliceConv)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return []int64{}, err
 | 
			
		||||
	}
 | 
			
		||||
	return val.([]int64), nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Int64SliceVar defines a int64Slice flag with specified name, default value, and usage string.
 | 
			
		||||
// The argument p points to a []int64 variable in which to store the value of the flag.
 | 
			
		||||
func (f *FlagSet) Int64SliceVar(p *[]int64, name string, value []int64, usage string) {
 | 
			
		||||
	f.VarP(newInt64SliceValue(value, p), name, "", usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Int64SliceVarP is like Int64SliceVar, but accepts a shorthand letter that can be used after a single dash.
 | 
			
		||||
func (f *FlagSet) Int64SliceVarP(p *[]int64, name, shorthand string, value []int64, usage string) {
 | 
			
		||||
	f.VarP(newInt64SliceValue(value, p), name, shorthand, usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Int64SliceVar defines a int64[] flag with specified name, default value, and usage string.
 | 
			
		||||
// The argument p points to a int64[] variable in which to store the value of the flag.
 | 
			
		||||
func Int64SliceVar(p *[]int64, name string, value []int64, usage string) {
 | 
			
		||||
	CommandLine.VarP(newInt64SliceValue(value, p), name, "", usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Int64SliceVarP is like Int64SliceVar, but accepts a shorthand letter that can be used after a single dash.
 | 
			
		||||
func Int64SliceVarP(p *[]int64, name, shorthand string, value []int64, usage string) {
 | 
			
		||||
	CommandLine.VarP(newInt64SliceValue(value, p), name, shorthand, usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Int64Slice defines a []int64 flag with specified name, default value, and usage string.
 | 
			
		||||
// The return value is the address of a []int64 variable that stores the value of the flag.
 | 
			
		||||
func (f *FlagSet) Int64Slice(name string, value []int64, usage string) *[]int64 {
 | 
			
		||||
	p := []int64{}
 | 
			
		||||
	f.Int64SliceVarP(&p, name, "", value, usage)
 | 
			
		||||
	return &p
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Int64SliceP is like Int64Slice, but accepts a shorthand letter that can be used after a single dash.
 | 
			
		||||
func (f *FlagSet) Int64SliceP(name, shorthand string, value []int64, usage string) *[]int64 {
 | 
			
		||||
	p := []int64{}
 | 
			
		||||
	f.Int64SliceVarP(&p, name, shorthand, value, usage)
 | 
			
		||||
	return &p
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Int64Slice defines a []int64 flag with specified name, default value, and usage string.
 | 
			
		||||
// The return value is the address of a []int64 variable that stores the value of the flag.
 | 
			
		||||
func Int64Slice(name string, value []int64, usage string) *[]int64 {
 | 
			
		||||
	return CommandLine.Int64SliceP(name, "", value, usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Int64SliceP is like Int64Slice, but accepts a shorthand letter that can be used after a single dash.
 | 
			
		||||
func Int64SliceP(name, shorthand string, value []int64, usage string) *[]int64 {
 | 
			
		||||
	return CommandLine.Int64SliceP(name, shorthand, value, usage)
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										88
									
								
								vendor/github.com/spf13/pflag/int8.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										88
									
								
								vendor/github.com/spf13/pflag/int8.go
									
									
									
										generated
									
									
										vendored
									
									
								
							@@ -1,88 +0,0 @@
 | 
			
		||||
package pflag
 | 
			
		||||
 | 
			
		||||
import "strconv"
 | 
			
		||||
 | 
			
		||||
// -- int8 Value
 | 
			
		||||
type int8Value int8
 | 
			
		||||
 | 
			
		||||
func newInt8Value(val int8, p *int8) *int8Value {
 | 
			
		||||
	*p = val
 | 
			
		||||
	return (*int8Value)(p)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (i *int8Value) Set(s string) error {
 | 
			
		||||
	v, err := strconv.ParseInt(s, 0, 8)
 | 
			
		||||
	*i = int8Value(v)
 | 
			
		||||
	return err
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (i *int8Value) Type() string {
 | 
			
		||||
	return "int8"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (i *int8Value) String() string { return strconv.FormatInt(int64(*i), 10) }
 | 
			
		||||
 | 
			
		||||
func int8Conv(sval string) (interface{}, error) {
 | 
			
		||||
	v, err := strconv.ParseInt(sval, 0, 8)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return 0, err
 | 
			
		||||
	}
 | 
			
		||||
	return int8(v), nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// GetInt8 return the int8 value of a flag with the given name
 | 
			
		||||
func (f *FlagSet) GetInt8(name string) (int8, error) {
 | 
			
		||||
	val, err := f.getFlagType(name, "int8", int8Conv)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return 0, err
 | 
			
		||||
	}
 | 
			
		||||
	return val.(int8), nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Int8Var defines an int8 flag with specified name, default value, and usage string.
 | 
			
		||||
// The argument p points to an int8 variable in which to store the value of the flag.
 | 
			
		||||
func (f *FlagSet) Int8Var(p *int8, name string, value int8, usage string) {
 | 
			
		||||
	f.VarP(newInt8Value(value, p), name, "", usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Int8VarP is like Int8Var, but accepts a shorthand letter that can be used after a single dash.
 | 
			
		||||
func (f *FlagSet) Int8VarP(p *int8, name, shorthand string, value int8, usage string) {
 | 
			
		||||
	f.VarP(newInt8Value(value, p), name, shorthand, usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Int8Var defines an int8 flag with specified name, default value, and usage string.
 | 
			
		||||
// The argument p points to an int8 variable in which to store the value of the flag.
 | 
			
		||||
func Int8Var(p *int8, name string, value int8, usage string) {
 | 
			
		||||
	CommandLine.VarP(newInt8Value(value, p), name, "", usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Int8VarP is like Int8Var, but accepts a shorthand letter that can be used after a single dash.
 | 
			
		||||
func Int8VarP(p *int8, name, shorthand string, value int8, usage string) {
 | 
			
		||||
	CommandLine.VarP(newInt8Value(value, p), name, shorthand, usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Int8 defines an int8 flag with specified name, default value, and usage string.
 | 
			
		||||
// The return value is the address of an int8 variable that stores the value of the flag.
 | 
			
		||||
func (f *FlagSet) Int8(name string, value int8, usage string) *int8 {
 | 
			
		||||
	p := new(int8)
 | 
			
		||||
	f.Int8VarP(p, name, "", value, usage)
 | 
			
		||||
	return p
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Int8P is like Int8, but accepts a shorthand letter that can be used after a single dash.
 | 
			
		||||
func (f *FlagSet) Int8P(name, shorthand string, value int8, usage string) *int8 {
 | 
			
		||||
	p := new(int8)
 | 
			
		||||
	f.Int8VarP(p, name, shorthand, value, usage)
 | 
			
		||||
	return p
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Int8 defines an int8 flag with specified name, default value, and usage string.
 | 
			
		||||
// The return value is the address of an int8 variable that stores the value of the flag.
 | 
			
		||||
func Int8(name string, value int8, usage string) *int8 {
 | 
			
		||||
	return CommandLine.Int8P(name, "", value, usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Int8P is like Int8, but accepts a shorthand letter that can be used after a single dash.
 | 
			
		||||
func Int8P(name, shorthand string, value int8, usage string) *int8 {
 | 
			
		||||
	return CommandLine.Int8P(name, shorthand, value, usage)
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										158
									
								
								vendor/github.com/spf13/pflag/int_slice.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										158
									
								
								vendor/github.com/spf13/pflag/int_slice.go
									
									
									
										generated
									
									
										vendored
									
									
								
							@@ -1,158 +0,0 @@
 | 
			
		||||
package pflag
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"strconv"
 | 
			
		||||
	"strings"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// -- intSlice Value
 | 
			
		||||
type intSliceValue struct {
 | 
			
		||||
	value   *[]int
 | 
			
		||||
	changed bool
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func newIntSliceValue(val []int, p *[]int) *intSliceValue {
 | 
			
		||||
	isv := new(intSliceValue)
 | 
			
		||||
	isv.value = p
 | 
			
		||||
	*isv.value = val
 | 
			
		||||
	return isv
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (s *intSliceValue) Set(val string) error {
 | 
			
		||||
	ss := strings.Split(val, ",")
 | 
			
		||||
	out := make([]int, len(ss))
 | 
			
		||||
	for i, d := range ss {
 | 
			
		||||
		var err error
 | 
			
		||||
		out[i], err = strconv.Atoi(d)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			return err
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
	}
 | 
			
		||||
	if !s.changed {
 | 
			
		||||
		*s.value = out
 | 
			
		||||
	} else {
 | 
			
		||||
		*s.value = append(*s.value, out...)
 | 
			
		||||
	}
 | 
			
		||||
	s.changed = true
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (s *intSliceValue) Type() string {
 | 
			
		||||
	return "intSlice"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (s *intSliceValue) String() string {
 | 
			
		||||
	out := make([]string, len(*s.value))
 | 
			
		||||
	for i, d := range *s.value {
 | 
			
		||||
		out[i] = fmt.Sprintf("%d", d)
 | 
			
		||||
	}
 | 
			
		||||
	return "[" + strings.Join(out, ",") + "]"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (s *intSliceValue) Append(val string) error {
 | 
			
		||||
	i, err := strconv.Atoi(val)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return err
 | 
			
		||||
	}
 | 
			
		||||
	*s.value = append(*s.value, i)
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (s *intSliceValue) Replace(val []string) error {
 | 
			
		||||
	out := make([]int, len(val))
 | 
			
		||||
	for i, d := range val {
 | 
			
		||||
		var err error
 | 
			
		||||
		out[i], err = strconv.Atoi(d)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			return err
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	*s.value = out
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (s *intSliceValue) GetSlice() []string {
 | 
			
		||||
	out := make([]string, len(*s.value))
 | 
			
		||||
	for i, d := range *s.value {
 | 
			
		||||
		out[i] = strconv.Itoa(d)
 | 
			
		||||
	}
 | 
			
		||||
	return out
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func intSliceConv(val string) (interface{}, error) {
 | 
			
		||||
	val = strings.Trim(val, "[]")
 | 
			
		||||
	// Empty string would cause a slice with one (empty) entry
 | 
			
		||||
	if len(val) == 0 {
 | 
			
		||||
		return []int{}, nil
 | 
			
		||||
	}
 | 
			
		||||
	ss := strings.Split(val, ",")
 | 
			
		||||
	out := make([]int, len(ss))
 | 
			
		||||
	for i, d := range ss {
 | 
			
		||||
		var err error
 | 
			
		||||
		out[i], err = strconv.Atoi(d)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			return nil, err
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
	}
 | 
			
		||||
	return out, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// GetIntSlice return the []int value of a flag with the given name
 | 
			
		||||
func (f *FlagSet) GetIntSlice(name string) ([]int, error) {
 | 
			
		||||
	val, err := f.getFlagType(name, "intSlice", intSliceConv)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return []int{}, err
 | 
			
		||||
	}
 | 
			
		||||
	return val.([]int), nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// IntSliceVar defines a intSlice flag with specified name, default value, and usage string.
 | 
			
		||||
// The argument p points to a []int variable in which to store the value of the flag.
 | 
			
		||||
func (f *FlagSet) IntSliceVar(p *[]int, name string, value []int, usage string) {
 | 
			
		||||
	f.VarP(newIntSliceValue(value, p), name, "", usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// IntSliceVarP is like IntSliceVar, but accepts a shorthand letter that can be used after a single dash.
 | 
			
		||||
func (f *FlagSet) IntSliceVarP(p *[]int, name, shorthand string, value []int, usage string) {
 | 
			
		||||
	f.VarP(newIntSliceValue(value, p), name, shorthand, usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// IntSliceVar defines a int[] flag with specified name, default value, and usage string.
 | 
			
		||||
// The argument p points to a int[] variable in which to store the value of the flag.
 | 
			
		||||
func IntSliceVar(p *[]int, name string, value []int, usage string) {
 | 
			
		||||
	CommandLine.VarP(newIntSliceValue(value, p), name, "", usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// IntSliceVarP is like IntSliceVar, but accepts a shorthand letter that can be used after a single dash.
 | 
			
		||||
func IntSliceVarP(p *[]int, name, shorthand string, value []int, usage string) {
 | 
			
		||||
	CommandLine.VarP(newIntSliceValue(value, p), name, shorthand, usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// IntSlice defines a []int flag with specified name, default value, and usage string.
 | 
			
		||||
// The return value is the address of a []int variable that stores the value of the flag.
 | 
			
		||||
func (f *FlagSet) IntSlice(name string, value []int, usage string) *[]int {
 | 
			
		||||
	p := []int{}
 | 
			
		||||
	f.IntSliceVarP(&p, name, "", value, usage)
 | 
			
		||||
	return &p
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// IntSliceP is like IntSlice, but accepts a shorthand letter that can be used after a single dash.
 | 
			
		||||
func (f *FlagSet) IntSliceP(name, shorthand string, value []int, usage string) *[]int {
 | 
			
		||||
	p := []int{}
 | 
			
		||||
	f.IntSliceVarP(&p, name, shorthand, value, usage)
 | 
			
		||||
	return &p
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// IntSlice defines a []int flag with specified name, default value, and usage string.
 | 
			
		||||
// The return value is the address of a []int variable that stores the value of the flag.
 | 
			
		||||
func IntSlice(name string, value []int, usage string) *[]int {
 | 
			
		||||
	return CommandLine.IntSliceP(name, "", value, usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// IntSliceP is like IntSlice, but accepts a shorthand letter that can be used after a single dash.
 | 
			
		||||
func IntSliceP(name, shorthand string, value []int, usage string) *[]int {
 | 
			
		||||
	return CommandLine.IntSliceP(name, shorthand, value, usage)
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										94
									
								
								vendor/github.com/spf13/pflag/ip.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										94
									
								
								vendor/github.com/spf13/pflag/ip.go
									
									
									
										generated
									
									
										vendored
									
									
								
							@@ -1,94 +0,0 @@
 | 
			
		||||
package pflag
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"net"
 | 
			
		||||
	"strings"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// -- net.IP value
 | 
			
		||||
type ipValue net.IP
 | 
			
		||||
 | 
			
		||||
func newIPValue(val net.IP, p *net.IP) *ipValue {
 | 
			
		||||
	*p = val
 | 
			
		||||
	return (*ipValue)(p)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (i *ipValue) String() string { return net.IP(*i).String() }
 | 
			
		||||
func (i *ipValue) Set(s string) error {
 | 
			
		||||
	ip := net.ParseIP(strings.TrimSpace(s))
 | 
			
		||||
	if ip == nil {
 | 
			
		||||
		return fmt.Errorf("failed to parse IP: %q", s)
 | 
			
		||||
	}
 | 
			
		||||
	*i = ipValue(ip)
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (i *ipValue) Type() string {
 | 
			
		||||
	return "ip"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func ipConv(sval string) (interface{}, error) {
 | 
			
		||||
	ip := net.ParseIP(sval)
 | 
			
		||||
	if ip != nil {
 | 
			
		||||
		return ip, nil
 | 
			
		||||
	}
 | 
			
		||||
	return nil, fmt.Errorf("invalid string being converted to IP address: %s", sval)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// GetIP return the net.IP value of a flag with the given name
 | 
			
		||||
func (f *FlagSet) GetIP(name string) (net.IP, error) {
 | 
			
		||||
	val, err := f.getFlagType(name, "ip", ipConv)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
	return val.(net.IP), nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// IPVar defines an net.IP flag with specified name, default value, and usage string.
 | 
			
		||||
// The argument p points to an net.IP variable in which to store the value of the flag.
 | 
			
		||||
func (f *FlagSet) IPVar(p *net.IP, name string, value net.IP, usage string) {
 | 
			
		||||
	f.VarP(newIPValue(value, p), name, "", usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// IPVarP is like IPVar, but accepts a shorthand letter that can be used after a single dash.
 | 
			
		||||
func (f *FlagSet) IPVarP(p *net.IP, name, shorthand string, value net.IP, usage string) {
 | 
			
		||||
	f.VarP(newIPValue(value, p), name, shorthand, usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// IPVar defines an net.IP flag with specified name, default value, and usage string.
 | 
			
		||||
// The argument p points to an net.IP variable in which to store the value of the flag.
 | 
			
		||||
func IPVar(p *net.IP, name string, value net.IP, usage string) {
 | 
			
		||||
	CommandLine.VarP(newIPValue(value, p), name, "", usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// IPVarP is like IPVar, but accepts a shorthand letter that can be used after a single dash.
 | 
			
		||||
func IPVarP(p *net.IP, name, shorthand string, value net.IP, usage string) {
 | 
			
		||||
	CommandLine.VarP(newIPValue(value, p), name, shorthand, usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// IP defines an net.IP flag with specified name, default value, and usage string.
 | 
			
		||||
// The return value is the address of an net.IP variable that stores the value of the flag.
 | 
			
		||||
func (f *FlagSet) IP(name string, value net.IP, usage string) *net.IP {
 | 
			
		||||
	p := new(net.IP)
 | 
			
		||||
	f.IPVarP(p, name, "", value, usage)
 | 
			
		||||
	return p
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// IPP is like IP, but accepts a shorthand letter that can be used after a single dash.
 | 
			
		||||
func (f *FlagSet) IPP(name, shorthand string, value net.IP, usage string) *net.IP {
 | 
			
		||||
	p := new(net.IP)
 | 
			
		||||
	f.IPVarP(p, name, shorthand, value, usage)
 | 
			
		||||
	return p
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// IP defines an net.IP flag with specified name, default value, and usage string.
 | 
			
		||||
// The return value is the address of an net.IP variable that stores the value of the flag.
 | 
			
		||||
func IP(name string, value net.IP, usage string) *net.IP {
 | 
			
		||||
	return CommandLine.IPP(name, "", value, usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// IPP is like IP, but accepts a shorthand letter that can be used after a single dash.
 | 
			
		||||
func IPP(name, shorthand string, value net.IP, usage string) *net.IP {
 | 
			
		||||
	return CommandLine.IPP(name, shorthand, value, usage)
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										186
									
								
								vendor/github.com/spf13/pflag/ip_slice.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										186
									
								
								vendor/github.com/spf13/pflag/ip_slice.go
									
									
									
										generated
									
									
										vendored
									
									
								
							@@ -1,186 +0,0 @@
 | 
			
		||||
package pflag
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"io"
 | 
			
		||||
	"net"
 | 
			
		||||
	"strings"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// -- ipSlice Value
 | 
			
		||||
type ipSliceValue struct {
 | 
			
		||||
	value   *[]net.IP
 | 
			
		||||
	changed bool
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func newIPSliceValue(val []net.IP, p *[]net.IP) *ipSliceValue {
 | 
			
		||||
	ipsv := new(ipSliceValue)
 | 
			
		||||
	ipsv.value = p
 | 
			
		||||
	*ipsv.value = val
 | 
			
		||||
	return ipsv
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Set converts, and assigns, the comma-separated IP argument string representation as the []net.IP value of this flag.
 | 
			
		||||
// If Set is called on a flag that already has a []net.IP assigned, the newly converted values will be appended.
 | 
			
		||||
func (s *ipSliceValue) Set(val string) error {
 | 
			
		||||
 | 
			
		||||
	// remove all quote characters
 | 
			
		||||
	rmQuote := strings.NewReplacer(`"`, "", `'`, "", "`", "")
 | 
			
		||||
 | 
			
		||||
	// read flag arguments with CSV parser
 | 
			
		||||
	ipStrSlice, err := readAsCSV(rmQuote.Replace(val))
 | 
			
		||||
	if err != nil && err != io.EOF {
 | 
			
		||||
		return err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// parse ip values into slice
 | 
			
		||||
	out := make([]net.IP, 0, len(ipStrSlice))
 | 
			
		||||
	for _, ipStr := range ipStrSlice {
 | 
			
		||||
		ip := net.ParseIP(strings.TrimSpace(ipStr))
 | 
			
		||||
		if ip == nil {
 | 
			
		||||
			return fmt.Errorf("invalid string being converted to IP address: %s", ipStr)
 | 
			
		||||
		}
 | 
			
		||||
		out = append(out, ip)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if !s.changed {
 | 
			
		||||
		*s.value = out
 | 
			
		||||
	} else {
 | 
			
		||||
		*s.value = append(*s.value, out...)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	s.changed = true
 | 
			
		||||
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Type returns a string that uniquely represents this flag's type.
 | 
			
		||||
func (s *ipSliceValue) Type() string {
 | 
			
		||||
	return "ipSlice"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// String defines a "native" format for this net.IP slice flag value.
 | 
			
		||||
func (s *ipSliceValue) String() string {
 | 
			
		||||
 | 
			
		||||
	ipStrSlice := make([]string, len(*s.value))
 | 
			
		||||
	for i, ip := range *s.value {
 | 
			
		||||
		ipStrSlice[i] = ip.String()
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	out, _ := writeAsCSV(ipStrSlice)
 | 
			
		||||
 | 
			
		||||
	return "[" + out + "]"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (s *ipSliceValue) fromString(val string) (net.IP, error) {
 | 
			
		||||
	return net.ParseIP(strings.TrimSpace(val)), nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (s *ipSliceValue) toString(val net.IP) string {
 | 
			
		||||
	return val.String()
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (s *ipSliceValue) Append(val string) error {
 | 
			
		||||
	i, err := s.fromString(val)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return err
 | 
			
		||||
	}
 | 
			
		||||
	*s.value = append(*s.value, i)
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (s *ipSliceValue) Replace(val []string) error {
 | 
			
		||||
	out := make([]net.IP, len(val))
 | 
			
		||||
	for i, d := range val {
 | 
			
		||||
		var err error
 | 
			
		||||
		out[i], err = s.fromString(d)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			return err
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	*s.value = out
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (s *ipSliceValue) GetSlice() []string {
 | 
			
		||||
	out := make([]string, len(*s.value))
 | 
			
		||||
	for i, d := range *s.value {
 | 
			
		||||
		out[i] = s.toString(d)
 | 
			
		||||
	}
 | 
			
		||||
	return out
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func ipSliceConv(val string) (interface{}, error) {
 | 
			
		||||
	val = strings.Trim(val, "[]")
 | 
			
		||||
	// Empty string would cause a slice with one (empty) entry
 | 
			
		||||
	if len(val) == 0 {
 | 
			
		||||
		return []net.IP{}, nil
 | 
			
		||||
	}
 | 
			
		||||
	ss := strings.Split(val, ",")
 | 
			
		||||
	out := make([]net.IP, len(ss))
 | 
			
		||||
	for i, sval := range ss {
 | 
			
		||||
		ip := net.ParseIP(strings.TrimSpace(sval))
 | 
			
		||||
		if ip == nil {
 | 
			
		||||
			return nil, fmt.Errorf("invalid string being converted to IP address: %s", sval)
 | 
			
		||||
		}
 | 
			
		||||
		out[i] = ip
 | 
			
		||||
	}
 | 
			
		||||
	return out, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// GetIPSlice returns the []net.IP value of a flag with the given name
 | 
			
		||||
func (f *FlagSet) GetIPSlice(name string) ([]net.IP, error) {
 | 
			
		||||
	val, err := f.getFlagType(name, "ipSlice", ipSliceConv)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return []net.IP{}, err
 | 
			
		||||
	}
 | 
			
		||||
	return val.([]net.IP), nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// IPSliceVar defines a ipSlice flag with specified name, default value, and usage string.
 | 
			
		||||
// The argument p points to a []net.IP variable in which to store the value of the flag.
 | 
			
		||||
func (f *FlagSet) IPSliceVar(p *[]net.IP, name string, value []net.IP, usage string) {
 | 
			
		||||
	f.VarP(newIPSliceValue(value, p), name, "", usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// IPSliceVarP is like IPSliceVar, but accepts a shorthand letter that can be used after a single dash.
 | 
			
		||||
func (f *FlagSet) IPSliceVarP(p *[]net.IP, name, shorthand string, value []net.IP, usage string) {
 | 
			
		||||
	f.VarP(newIPSliceValue(value, p), name, shorthand, usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// IPSliceVar defines a []net.IP flag with specified name, default value, and usage string.
 | 
			
		||||
// The argument p points to a []net.IP variable in which to store the value of the flag.
 | 
			
		||||
func IPSliceVar(p *[]net.IP, name string, value []net.IP, usage string) {
 | 
			
		||||
	CommandLine.VarP(newIPSliceValue(value, p), name, "", usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// IPSliceVarP is like IPSliceVar, but accepts a shorthand letter that can be used after a single dash.
 | 
			
		||||
func IPSliceVarP(p *[]net.IP, name, shorthand string, value []net.IP, usage string) {
 | 
			
		||||
	CommandLine.VarP(newIPSliceValue(value, p), name, shorthand, usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// IPSlice defines a []net.IP flag with specified name, default value, and usage string.
 | 
			
		||||
// The return value is the address of a []net.IP variable that stores the value of that flag.
 | 
			
		||||
func (f *FlagSet) IPSlice(name string, value []net.IP, usage string) *[]net.IP {
 | 
			
		||||
	p := []net.IP{}
 | 
			
		||||
	f.IPSliceVarP(&p, name, "", value, usage)
 | 
			
		||||
	return &p
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// IPSliceP is like IPSlice, but accepts a shorthand letter that can be used after a single dash.
 | 
			
		||||
func (f *FlagSet) IPSliceP(name, shorthand string, value []net.IP, usage string) *[]net.IP {
 | 
			
		||||
	p := []net.IP{}
 | 
			
		||||
	f.IPSliceVarP(&p, name, shorthand, value, usage)
 | 
			
		||||
	return &p
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// IPSlice defines a []net.IP flag with specified name, default value, and usage string.
 | 
			
		||||
// The return value is the address of a []net.IP variable that stores the value of the flag.
 | 
			
		||||
func IPSlice(name string, value []net.IP, usage string) *[]net.IP {
 | 
			
		||||
	return CommandLine.IPSliceP(name, "", value, usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// IPSliceP is like IPSlice, but accepts a shorthand letter that can be used after a single dash.
 | 
			
		||||
func IPSliceP(name, shorthand string, value []net.IP, usage string) *[]net.IP {
 | 
			
		||||
	return CommandLine.IPSliceP(name, shorthand, value, usage)
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										122
									
								
								vendor/github.com/spf13/pflag/ipmask.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										122
									
								
								vendor/github.com/spf13/pflag/ipmask.go
									
									
									
										generated
									
									
										vendored
									
									
								
							@@ -1,122 +0,0 @@
 | 
			
		||||
package pflag
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"net"
 | 
			
		||||
	"strconv"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// -- net.IPMask value
 | 
			
		||||
type ipMaskValue net.IPMask
 | 
			
		||||
 | 
			
		||||
func newIPMaskValue(val net.IPMask, p *net.IPMask) *ipMaskValue {
 | 
			
		||||
	*p = val
 | 
			
		||||
	return (*ipMaskValue)(p)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (i *ipMaskValue) String() string { return net.IPMask(*i).String() }
 | 
			
		||||
func (i *ipMaskValue) Set(s string) error {
 | 
			
		||||
	ip := ParseIPv4Mask(s)
 | 
			
		||||
	if ip == nil {
 | 
			
		||||
		return fmt.Errorf("failed to parse IP mask: %q", s)
 | 
			
		||||
	}
 | 
			
		||||
	*i = ipMaskValue(ip)
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (i *ipMaskValue) Type() string {
 | 
			
		||||
	return "ipMask"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// ParseIPv4Mask written in IP form (e.g. 255.255.255.0).
 | 
			
		||||
// This function should really belong to the net package.
 | 
			
		||||
func ParseIPv4Mask(s string) net.IPMask {
 | 
			
		||||
	mask := net.ParseIP(s)
 | 
			
		||||
	if mask == nil {
 | 
			
		||||
		if len(s) != 8 {
 | 
			
		||||
			return nil
 | 
			
		||||
		}
 | 
			
		||||
		// net.IPMask.String() actually outputs things like ffffff00
 | 
			
		||||
		// so write a horrible parser for that as well  :-(
 | 
			
		||||
		m := []int{}
 | 
			
		||||
		for i := 0; i < 4; i++ {
 | 
			
		||||
			b := "0x" + s[2*i:2*i+2]
 | 
			
		||||
			d, err := strconv.ParseInt(b, 0, 0)
 | 
			
		||||
			if err != nil {
 | 
			
		||||
				return nil
 | 
			
		||||
			}
 | 
			
		||||
			m = append(m, int(d))
 | 
			
		||||
		}
 | 
			
		||||
		s := fmt.Sprintf("%d.%d.%d.%d", m[0], m[1], m[2], m[3])
 | 
			
		||||
		mask = net.ParseIP(s)
 | 
			
		||||
		if mask == nil {
 | 
			
		||||
			return nil
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	return net.IPv4Mask(mask[12], mask[13], mask[14], mask[15])
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func parseIPv4Mask(sval string) (interface{}, error) {
 | 
			
		||||
	mask := ParseIPv4Mask(sval)
 | 
			
		||||
	if mask == nil {
 | 
			
		||||
		return nil, fmt.Errorf("unable to parse %s as net.IPMask", sval)
 | 
			
		||||
	}
 | 
			
		||||
	return mask, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// GetIPv4Mask return the net.IPv4Mask value of a flag with the given name
 | 
			
		||||
func (f *FlagSet) GetIPv4Mask(name string) (net.IPMask, error) {
 | 
			
		||||
	val, err := f.getFlagType(name, "ipMask", parseIPv4Mask)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
	return val.(net.IPMask), nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// IPMaskVar defines an net.IPMask flag with specified name, default value, and usage string.
 | 
			
		||||
// The argument p points to an net.IPMask variable in which to store the value of the flag.
 | 
			
		||||
func (f *FlagSet) IPMaskVar(p *net.IPMask, name string, value net.IPMask, usage string) {
 | 
			
		||||
	f.VarP(newIPMaskValue(value, p), name, "", usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// IPMaskVarP is like IPMaskVar, but accepts a shorthand letter that can be used after a single dash.
 | 
			
		||||
func (f *FlagSet) IPMaskVarP(p *net.IPMask, name, shorthand string, value net.IPMask, usage string) {
 | 
			
		||||
	f.VarP(newIPMaskValue(value, p), name, shorthand, usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// IPMaskVar defines an net.IPMask flag with specified name, default value, and usage string.
 | 
			
		||||
// The argument p points to an net.IPMask variable in which to store the value of the flag.
 | 
			
		||||
func IPMaskVar(p *net.IPMask, name string, value net.IPMask, usage string) {
 | 
			
		||||
	CommandLine.VarP(newIPMaskValue(value, p), name, "", usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// IPMaskVarP is like IPMaskVar, but accepts a shorthand letter that can be used after a single dash.
 | 
			
		||||
func IPMaskVarP(p *net.IPMask, name, shorthand string, value net.IPMask, usage string) {
 | 
			
		||||
	CommandLine.VarP(newIPMaskValue(value, p), name, shorthand, usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// IPMask defines an net.IPMask flag with specified name, default value, and usage string.
 | 
			
		||||
// The return value is the address of an net.IPMask variable that stores the value of the flag.
 | 
			
		||||
func (f *FlagSet) IPMask(name string, value net.IPMask, usage string) *net.IPMask {
 | 
			
		||||
	p := new(net.IPMask)
 | 
			
		||||
	f.IPMaskVarP(p, name, "", value, usage)
 | 
			
		||||
	return p
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// IPMaskP is like IPMask, but accepts a shorthand letter that can be used after a single dash.
 | 
			
		||||
func (f *FlagSet) IPMaskP(name, shorthand string, value net.IPMask, usage string) *net.IPMask {
 | 
			
		||||
	p := new(net.IPMask)
 | 
			
		||||
	f.IPMaskVarP(p, name, shorthand, value, usage)
 | 
			
		||||
	return p
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// IPMask defines an net.IPMask flag with specified name, default value, and usage string.
 | 
			
		||||
// The return value is the address of an net.IPMask variable that stores the value of the flag.
 | 
			
		||||
func IPMask(name string, value net.IPMask, usage string) *net.IPMask {
 | 
			
		||||
	return CommandLine.IPMaskP(name, "", value, usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// IPMaskP is like IP, but accepts a shorthand letter that can be used after a single dash.
 | 
			
		||||
func IPMaskP(name, shorthand string, value net.IPMask, usage string) *net.IPMask {
 | 
			
		||||
	return CommandLine.IPMaskP(name, shorthand, value, usage)
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										98
									
								
								vendor/github.com/spf13/pflag/ipnet.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										98
									
								
								vendor/github.com/spf13/pflag/ipnet.go
									
									
									
										generated
									
									
										vendored
									
									
								
							@@ -1,98 +0,0 @@
 | 
			
		||||
package pflag
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"net"
 | 
			
		||||
	"strings"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// IPNet adapts net.IPNet for use as a flag.
 | 
			
		||||
type ipNetValue net.IPNet
 | 
			
		||||
 | 
			
		||||
func (ipnet ipNetValue) String() string {
 | 
			
		||||
	n := net.IPNet(ipnet)
 | 
			
		||||
	return n.String()
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (ipnet *ipNetValue) Set(value string) error {
 | 
			
		||||
	_, n, err := net.ParseCIDR(strings.TrimSpace(value))
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return err
 | 
			
		||||
	}
 | 
			
		||||
	*ipnet = ipNetValue(*n)
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (*ipNetValue) Type() string {
 | 
			
		||||
	return "ipNet"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func newIPNetValue(val net.IPNet, p *net.IPNet) *ipNetValue {
 | 
			
		||||
	*p = val
 | 
			
		||||
	return (*ipNetValue)(p)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func ipNetConv(sval string) (interface{}, error) {
 | 
			
		||||
	_, n, err := net.ParseCIDR(strings.TrimSpace(sval))
 | 
			
		||||
	if err == nil {
 | 
			
		||||
		return *n, nil
 | 
			
		||||
	}
 | 
			
		||||
	return nil, fmt.Errorf("invalid string being converted to IPNet: %s", sval)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// GetIPNet return the net.IPNet value of a flag with the given name
 | 
			
		||||
func (f *FlagSet) GetIPNet(name string) (net.IPNet, error) {
 | 
			
		||||
	val, err := f.getFlagType(name, "ipNet", ipNetConv)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return net.IPNet{}, err
 | 
			
		||||
	}
 | 
			
		||||
	return val.(net.IPNet), nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// IPNetVar defines an net.IPNet flag with specified name, default value, and usage string.
 | 
			
		||||
// The argument p points to an net.IPNet variable in which to store the value of the flag.
 | 
			
		||||
func (f *FlagSet) IPNetVar(p *net.IPNet, name string, value net.IPNet, usage string) {
 | 
			
		||||
	f.VarP(newIPNetValue(value, p), name, "", usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// IPNetVarP is like IPNetVar, but accepts a shorthand letter that can be used after a single dash.
 | 
			
		||||
func (f *FlagSet) IPNetVarP(p *net.IPNet, name, shorthand string, value net.IPNet, usage string) {
 | 
			
		||||
	f.VarP(newIPNetValue(value, p), name, shorthand, usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// IPNetVar defines an net.IPNet flag with specified name, default value, and usage string.
 | 
			
		||||
// The argument p points to an net.IPNet variable in which to store the value of the flag.
 | 
			
		||||
func IPNetVar(p *net.IPNet, name string, value net.IPNet, usage string) {
 | 
			
		||||
	CommandLine.VarP(newIPNetValue(value, p), name, "", usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// IPNetVarP is like IPNetVar, but accepts a shorthand letter that can be used after a single dash.
 | 
			
		||||
func IPNetVarP(p *net.IPNet, name, shorthand string, value net.IPNet, usage string) {
 | 
			
		||||
	CommandLine.VarP(newIPNetValue(value, p), name, shorthand, usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// IPNet defines an net.IPNet flag with specified name, default value, and usage string.
 | 
			
		||||
// The return value is the address of an net.IPNet variable that stores the value of the flag.
 | 
			
		||||
func (f *FlagSet) IPNet(name string, value net.IPNet, usage string) *net.IPNet {
 | 
			
		||||
	p := new(net.IPNet)
 | 
			
		||||
	f.IPNetVarP(p, name, "", value, usage)
 | 
			
		||||
	return p
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// IPNetP is like IPNet, but accepts a shorthand letter that can be used after a single dash.
 | 
			
		||||
func (f *FlagSet) IPNetP(name, shorthand string, value net.IPNet, usage string) *net.IPNet {
 | 
			
		||||
	p := new(net.IPNet)
 | 
			
		||||
	f.IPNetVarP(p, name, shorthand, value, usage)
 | 
			
		||||
	return p
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// IPNet defines an net.IPNet flag with specified name, default value, and usage string.
 | 
			
		||||
// The return value is the address of an net.IPNet variable that stores the value of the flag.
 | 
			
		||||
func IPNet(name string, value net.IPNet, usage string) *net.IPNet {
 | 
			
		||||
	return CommandLine.IPNetP(name, "", value, usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// IPNetP is like IPNet, but accepts a shorthand letter that can be used after a single dash.
 | 
			
		||||
func IPNetP(name, shorthand string, value net.IPNet, usage string) *net.IPNet {
 | 
			
		||||
	return CommandLine.IPNetP(name, shorthand, value, usage)
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										80
									
								
								vendor/github.com/spf13/pflag/string.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										80
									
								
								vendor/github.com/spf13/pflag/string.go
									
									
									
										generated
									
									
										vendored
									
									
								
							@@ -1,80 +0,0 @@
 | 
			
		||||
package pflag
 | 
			
		||||
 | 
			
		||||
// -- string Value
 | 
			
		||||
type stringValue string
 | 
			
		||||
 | 
			
		||||
func newStringValue(val string, p *string) *stringValue {
 | 
			
		||||
	*p = val
 | 
			
		||||
	return (*stringValue)(p)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (s *stringValue) Set(val string) error {
 | 
			
		||||
	*s = stringValue(val)
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
func (s *stringValue) Type() string {
 | 
			
		||||
	return "string"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (s *stringValue) String() string { return string(*s) }
 | 
			
		||||
 | 
			
		||||
func stringConv(sval string) (interface{}, error) {
 | 
			
		||||
	return sval, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// GetString return the string value of a flag with the given name
 | 
			
		||||
func (f *FlagSet) GetString(name string) (string, error) {
 | 
			
		||||
	val, err := f.getFlagType(name, "string", stringConv)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return "", err
 | 
			
		||||
	}
 | 
			
		||||
	return val.(string), nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// StringVar defines a string flag with specified name, default value, and usage string.
 | 
			
		||||
// The argument p points to a string variable in which to store the value of the flag.
 | 
			
		||||
func (f *FlagSet) StringVar(p *string, name string, value string, usage string) {
 | 
			
		||||
	f.VarP(newStringValue(value, p), name, "", usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// StringVarP is like StringVar, but accepts a shorthand letter that can be used after a single dash.
 | 
			
		||||
func (f *FlagSet) StringVarP(p *string, name, shorthand string, value string, usage string) {
 | 
			
		||||
	f.VarP(newStringValue(value, p), name, shorthand, usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// StringVar defines a string flag with specified name, default value, and usage string.
 | 
			
		||||
// The argument p points to a string variable in which to store the value of the flag.
 | 
			
		||||
func StringVar(p *string, name string, value string, usage string) {
 | 
			
		||||
	CommandLine.VarP(newStringValue(value, p), name, "", usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// StringVarP is like StringVar, but accepts a shorthand letter that can be used after a single dash.
 | 
			
		||||
func StringVarP(p *string, name, shorthand string, value string, usage string) {
 | 
			
		||||
	CommandLine.VarP(newStringValue(value, p), name, shorthand, usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// String defines a string flag with specified name, default value, and usage string.
 | 
			
		||||
// The return value is the address of a string variable that stores the value of the flag.
 | 
			
		||||
func (f *FlagSet) String(name string, value string, usage string) *string {
 | 
			
		||||
	p := new(string)
 | 
			
		||||
	f.StringVarP(p, name, "", value, usage)
 | 
			
		||||
	return p
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// StringP is like String, but accepts a shorthand letter that can be used after a single dash.
 | 
			
		||||
func (f *FlagSet) StringP(name, shorthand string, value string, usage string) *string {
 | 
			
		||||
	p := new(string)
 | 
			
		||||
	f.StringVarP(p, name, shorthand, value, usage)
 | 
			
		||||
	return p
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// String defines a string flag with specified name, default value, and usage string.
 | 
			
		||||
// The return value is the address of a string variable that stores the value of the flag.
 | 
			
		||||
func String(name string, value string, usage string) *string {
 | 
			
		||||
	return CommandLine.StringP(name, "", value, usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// StringP is like String, but accepts a shorthand letter that can be used after a single dash.
 | 
			
		||||
func StringP(name, shorthand string, value string, usage string) *string {
 | 
			
		||||
	return CommandLine.StringP(name, shorthand, value, usage)
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										129
									
								
								vendor/github.com/spf13/pflag/string_array.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										129
									
								
								vendor/github.com/spf13/pflag/string_array.go
									
									
									
										generated
									
									
										vendored
									
									
								
							@@ -1,129 +0,0 @@
 | 
			
		||||
package pflag
 | 
			
		||||
 | 
			
		||||
// -- stringArray Value
 | 
			
		||||
type stringArrayValue struct {
 | 
			
		||||
	value   *[]string
 | 
			
		||||
	changed bool
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func newStringArrayValue(val []string, p *[]string) *stringArrayValue {
 | 
			
		||||
	ssv := new(stringArrayValue)
 | 
			
		||||
	ssv.value = p
 | 
			
		||||
	*ssv.value = val
 | 
			
		||||
	return ssv
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (s *stringArrayValue) Set(val string) error {
 | 
			
		||||
	if !s.changed {
 | 
			
		||||
		*s.value = []string{val}
 | 
			
		||||
		s.changed = true
 | 
			
		||||
	} else {
 | 
			
		||||
		*s.value = append(*s.value, val)
 | 
			
		||||
	}
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (s *stringArrayValue) Append(val string) error {
 | 
			
		||||
	*s.value = append(*s.value, val)
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (s *stringArrayValue) Replace(val []string) error {
 | 
			
		||||
	out := make([]string, len(val))
 | 
			
		||||
	for i, d := range val {
 | 
			
		||||
		var err error
 | 
			
		||||
		out[i] = d
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			return err
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	*s.value = out
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (s *stringArrayValue) GetSlice() []string {
 | 
			
		||||
	out := make([]string, len(*s.value))
 | 
			
		||||
	for i, d := range *s.value {
 | 
			
		||||
		out[i] = d
 | 
			
		||||
	}
 | 
			
		||||
	return out
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (s *stringArrayValue) Type() string {
 | 
			
		||||
	return "stringArray"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (s *stringArrayValue) String() string {
 | 
			
		||||
	str, _ := writeAsCSV(*s.value)
 | 
			
		||||
	return "[" + str + "]"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func stringArrayConv(sval string) (interface{}, error) {
 | 
			
		||||
	sval = sval[1 : len(sval)-1]
 | 
			
		||||
	// An empty string would cause a array with one (empty) string
 | 
			
		||||
	if len(sval) == 0 {
 | 
			
		||||
		return []string{}, nil
 | 
			
		||||
	}
 | 
			
		||||
	return readAsCSV(sval)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// GetStringArray return the []string value of a flag with the given name
 | 
			
		||||
func (f *FlagSet) GetStringArray(name string) ([]string, error) {
 | 
			
		||||
	val, err := f.getFlagType(name, "stringArray", stringArrayConv)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return []string{}, err
 | 
			
		||||
	}
 | 
			
		||||
	return val.([]string), nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// StringArrayVar defines a string flag with specified name, default value, and usage string.
 | 
			
		||||
// The argument p points to a []string variable in which to store the values of the multiple flags.
 | 
			
		||||
// The value of each argument will not try to be separated by comma. Use a StringSlice for that.
 | 
			
		||||
func (f *FlagSet) StringArrayVar(p *[]string, name string, value []string, usage string) {
 | 
			
		||||
	f.VarP(newStringArrayValue(value, p), name, "", usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// StringArrayVarP is like StringArrayVar, but accepts a shorthand letter that can be used after a single dash.
 | 
			
		||||
func (f *FlagSet) StringArrayVarP(p *[]string, name, shorthand string, value []string, usage string) {
 | 
			
		||||
	f.VarP(newStringArrayValue(value, p), name, shorthand, usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// StringArrayVar defines a string flag with specified name, default value, and usage string.
 | 
			
		||||
// The argument p points to a []string variable in which to store the value of the flag.
 | 
			
		||||
// The value of each argument will not try to be separated by comma. Use a StringSlice for that.
 | 
			
		||||
func StringArrayVar(p *[]string, name string, value []string, usage string) {
 | 
			
		||||
	CommandLine.VarP(newStringArrayValue(value, p), name, "", usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// StringArrayVarP is like StringArrayVar, but accepts a shorthand letter that can be used after a single dash.
 | 
			
		||||
func StringArrayVarP(p *[]string, name, shorthand string, value []string, usage string) {
 | 
			
		||||
	CommandLine.VarP(newStringArrayValue(value, p), name, shorthand, usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// StringArray defines a string flag with specified name, default value, and usage string.
 | 
			
		||||
// The return value is the address of a []string variable that stores the value of the flag.
 | 
			
		||||
// The value of each argument will not try to be separated by comma. Use a StringSlice for that.
 | 
			
		||||
func (f *FlagSet) StringArray(name string, value []string, usage string) *[]string {
 | 
			
		||||
	p := []string{}
 | 
			
		||||
	f.StringArrayVarP(&p, name, "", value, usage)
 | 
			
		||||
	return &p
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// StringArrayP is like StringArray, but accepts a shorthand letter that can be used after a single dash.
 | 
			
		||||
func (f *FlagSet) StringArrayP(name, shorthand string, value []string, usage string) *[]string {
 | 
			
		||||
	p := []string{}
 | 
			
		||||
	f.StringArrayVarP(&p, name, shorthand, value, usage)
 | 
			
		||||
	return &p
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// StringArray defines a string flag with specified name, default value, and usage string.
 | 
			
		||||
// The return value is the address of a []string variable that stores the value of the flag.
 | 
			
		||||
// The value of each argument will not try to be separated by comma. Use a StringSlice for that.
 | 
			
		||||
func StringArray(name string, value []string, usage string) *[]string {
 | 
			
		||||
	return CommandLine.StringArrayP(name, "", value, usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// StringArrayP is like StringArray, but accepts a shorthand letter that can be used after a single dash.
 | 
			
		||||
func StringArrayP(name, shorthand string, value []string, usage string) *[]string {
 | 
			
		||||
	return CommandLine.StringArrayP(name, shorthand, value, usage)
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										163
									
								
								vendor/github.com/spf13/pflag/string_slice.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										163
									
								
								vendor/github.com/spf13/pflag/string_slice.go
									
									
									
										generated
									
									
										vendored
									
									
								
							@@ -1,163 +0,0 @@
 | 
			
		||||
package pflag
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"bytes"
 | 
			
		||||
	"encoding/csv"
 | 
			
		||||
	"strings"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// -- stringSlice Value
 | 
			
		||||
type stringSliceValue struct {
 | 
			
		||||
	value   *[]string
 | 
			
		||||
	changed bool
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func newStringSliceValue(val []string, p *[]string) *stringSliceValue {
 | 
			
		||||
	ssv := new(stringSliceValue)
 | 
			
		||||
	ssv.value = p
 | 
			
		||||
	*ssv.value = val
 | 
			
		||||
	return ssv
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func readAsCSV(val string) ([]string, error) {
 | 
			
		||||
	if val == "" {
 | 
			
		||||
		return []string{}, nil
 | 
			
		||||
	}
 | 
			
		||||
	stringReader := strings.NewReader(val)
 | 
			
		||||
	csvReader := csv.NewReader(stringReader)
 | 
			
		||||
	return csvReader.Read()
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func writeAsCSV(vals []string) (string, error) {
 | 
			
		||||
	b := &bytes.Buffer{}
 | 
			
		||||
	w := csv.NewWriter(b)
 | 
			
		||||
	err := w.Write(vals)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return "", err
 | 
			
		||||
	}
 | 
			
		||||
	w.Flush()
 | 
			
		||||
	return strings.TrimSuffix(b.String(), "\n"), nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (s *stringSliceValue) Set(val string) error {
 | 
			
		||||
	v, err := readAsCSV(val)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return err
 | 
			
		||||
	}
 | 
			
		||||
	if !s.changed {
 | 
			
		||||
		*s.value = v
 | 
			
		||||
	} else {
 | 
			
		||||
		*s.value = append(*s.value, v...)
 | 
			
		||||
	}
 | 
			
		||||
	s.changed = true
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (s *stringSliceValue) Type() string {
 | 
			
		||||
	return "stringSlice"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (s *stringSliceValue) String() string {
 | 
			
		||||
	str, _ := writeAsCSV(*s.value)
 | 
			
		||||
	return "[" + str + "]"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (s *stringSliceValue) Append(val string) error {
 | 
			
		||||
	*s.value = append(*s.value, val)
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (s *stringSliceValue) Replace(val []string) error {
 | 
			
		||||
	*s.value = val
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (s *stringSliceValue) GetSlice() []string {
 | 
			
		||||
	return *s.value
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func stringSliceConv(sval string) (interface{}, error) {
 | 
			
		||||
	sval = sval[1 : len(sval)-1]
 | 
			
		||||
	// An empty string would cause a slice with one (empty) string
 | 
			
		||||
	if len(sval) == 0 {
 | 
			
		||||
		return []string{}, nil
 | 
			
		||||
	}
 | 
			
		||||
	return readAsCSV(sval)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// GetStringSlice return the []string value of a flag with the given name
 | 
			
		||||
func (f *FlagSet) GetStringSlice(name string) ([]string, error) {
 | 
			
		||||
	val, err := f.getFlagType(name, "stringSlice", stringSliceConv)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return []string{}, err
 | 
			
		||||
	}
 | 
			
		||||
	return val.([]string), nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// StringSliceVar defines a string flag with specified name, default value, and usage string.
 | 
			
		||||
// The argument p points to a []string variable in which to store the value of the flag.
 | 
			
		||||
// Compared to StringArray flags, StringSlice flags take comma-separated value as arguments and split them accordingly.
 | 
			
		||||
// For example:
 | 
			
		||||
//   --ss="v1,v2" --ss="v3"
 | 
			
		||||
// will result in
 | 
			
		||||
//   []string{"v1", "v2", "v3"}
 | 
			
		||||
func (f *FlagSet) StringSliceVar(p *[]string, name string, value []string, usage string) {
 | 
			
		||||
	f.VarP(newStringSliceValue(value, p), name, "", usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// StringSliceVarP is like StringSliceVar, but accepts a shorthand letter that can be used after a single dash.
 | 
			
		||||
func (f *FlagSet) StringSliceVarP(p *[]string, name, shorthand string, value []string, usage string) {
 | 
			
		||||
	f.VarP(newStringSliceValue(value, p), name, shorthand, usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// StringSliceVar defines a string flag with specified name, default value, and usage string.
 | 
			
		||||
// The argument p points to a []string variable in which to store the value of the flag.
 | 
			
		||||
// Compared to StringArray flags, StringSlice flags take comma-separated value as arguments and split them accordingly.
 | 
			
		||||
// For example:
 | 
			
		||||
//   --ss="v1,v2" --ss="v3"
 | 
			
		||||
// will result in
 | 
			
		||||
//   []string{"v1", "v2", "v3"}
 | 
			
		||||
func StringSliceVar(p *[]string, name string, value []string, usage string) {
 | 
			
		||||
	CommandLine.VarP(newStringSliceValue(value, p), name, "", usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// StringSliceVarP is like StringSliceVar, but accepts a shorthand letter that can be used after a single dash.
 | 
			
		||||
func StringSliceVarP(p *[]string, name, shorthand string, value []string, usage string) {
 | 
			
		||||
	CommandLine.VarP(newStringSliceValue(value, p), name, shorthand, usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// StringSlice defines a string flag with specified name, default value, and usage string.
 | 
			
		||||
// The return value is the address of a []string variable that stores the value of the flag.
 | 
			
		||||
// Compared to StringArray flags, StringSlice flags take comma-separated value as arguments and split them accordingly.
 | 
			
		||||
// For example:
 | 
			
		||||
//   --ss="v1,v2" --ss="v3"
 | 
			
		||||
// will result in
 | 
			
		||||
//   []string{"v1", "v2", "v3"}
 | 
			
		||||
func (f *FlagSet) StringSlice(name string, value []string, usage string) *[]string {
 | 
			
		||||
	p := []string{}
 | 
			
		||||
	f.StringSliceVarP(&p, name, "", value, usage)
 | 
			
		||||
	return &p
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// StringSliceP is like StringSlice, but accepts a shorthand letter that can be used after a single dash.
 | 
			
		||||
func (f *FlagSet) StringSliceP(name, shorthand string, value []string, usage string) *[]string {
 | 
			
		||||
	p := []string{}
 | 
			
		||||
	f.StringSliceVarP(&p, name, shorthand, value, usage)
 | 
			
		||||
	return &p
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// StringSlice defines a string flag with specified name, default value, and usage string.
 | 
			
		||||
// The return value is the address of a []string variable that stores the value of the flag.
 | 
			
		||||
// Compared to StringArray flags, StringSlice flags take comma-separated value as arguments and split them accordingly.
 | 
			
		||||
// For example:
 | 
			
		||||
//   --ss="v1,v2" --ss="v3"
 | 
			
		||||
// will result in
 | 
			
		||||
//   []string{"v1", "v2", "v3"}
 | 
			
		||||
func StringSlice(name string, value []string, usage string) *[]string {
 | 
			
		||||
	return CommandLine.StringSliceP(name, "", value, usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// StringSliceP is like StringSlice, but accepts a shorthand letter that can be used after a single dash.
 | 
			
		||||
func StringSliceP(name, shorthand string, value []string, usage string) *[]string {
 | 
			
		||||
	return CommandLine.StringSliceP(name, shorthand, value, usage)
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										149
									
								
								vendor/github.com/spf13/pflag/string_to_int.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										149
									
								
								vendor/github.com/spf13/pflag/string_to_int.go
									
									
									
										generated
									
									
										vendored
									
									
								
							@@ -1,149 +0,0 @@
 | 
			
		||||
package pflag
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"bytes"
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"strconv"
 | 
			
		||||
	"strings"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// -- stringToInt Value
 | 
			
		||||
type stringToIntValue struct {
 | 
			
		||||
	value   *map[string]int
 | 
			
		||||
	changed bool
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func newStringToIntValue(val map[string]int, p *map[string]int) *stringToIntValue {
 | 
			
		||||
	ssv := new(stringToIntValue)
 | 
			
		||||
	ssv.value = p
 | 
			
		||||
	*ssv.value = val
 | 
			
		||||
	return ssv
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Format: a=1,b=2
 | 
			
		||||
func (s *stringToIntValue) Set(val string) error {
 | 
			
		||||
	ss := strings.Split(val, ",")
 | 
			
		||||
	out := make(map[string]int, len(ss))
 | 
			
		||||
	for _, pair := range ss {
 | 
			
		||||
		kv := strings.SplitN(pair, "=", 2)
 | 
			
		||||
		if len(kv) != 2 {
 | 
			
		||||
			return fmt.Errorf("%s must be formatted as key=value", pair)
 | 
			
		||||
		}
 | 
			
		||||
		var err error
 | 
			
		||||
		out[kv[0]], err = strconv.Atoi(kv[1])
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			return err
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	if !s.changed {
 | 
			
		||||
		*s.value = out
 | 
			
		||||
	} else {
 | 
			
		||||
		for k, v := range out {
 | 
			
		||||
			(*s.value)[k] = v
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	s.changed = true
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (s *stringToIntValue) Type() string {
 | 
			
		||||
	return "stringToInt"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (s *stringToIntValue) String() string {
 | 
			
		||||
	var buf bytes.Buffer
 | 
			
		||||
	i := 0
 | 
			
		||||
	for k, v := range *s.value {
 | 
			
		||||
		if i > 0 {
 | 
			
		||||
			buf.WriteRune(',')
 | 
			
		||||
		}
 | 
			
		||||
		buf.WriteString(k)
 | 
			
		||||
		buf.WriteRune('=')
 | 
			
		||||
		buf.WriteString(strconv.Itoa(v))
 | 
			
		||||
		i++
 | 
			
		||||
	}
 | 
			
		||||
	return "[" + buf.String() + "]"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func stringToIntConv(val string) (interface{}, error) {
 | 
			
		||||
	val = strings.Trim(val, "[]")
 | 
			
		||||
	// An empty string would cause an empty map
 | 
			
		||||
	if len(val) == 0 {
 | 
			
		||||
		return map[string]int{}, nil
 | 
			
		||||
	}
 | 
			
		||||
	ss := strings.Split(val, ",")
 | 
			
		||||
	out := make(map[string]int, len(ss))
 | 
			
		||||
	for _, pair := range ss {
 | 
			
		||||
		kv := strings.SplitN(pair, "=", 2)
 | 
			
		||||
		if len(kv) != 2 {
 | 
			
		||||
			return nil, fmt.Errorf("%s must be formatted as key=value", pair)
 | 
			
		||||
		}
 | 
			
		||||
		var err error
 | 
			
		||||
		out[kv[0]], err = strconv.Atoi(kv[1])
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			return nil, err
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	return out, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// GetStringToInt return the map[string]int value of a flag with the given name
 | 
			
		||||
func (f *FlagSet) GetStringToInt(name string) (map[string]int, error) {
 | 
			
		||||
	val, err := f.getFlagType(name, "stringToInt", stringToIntConv)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return map[string]int{}, err
 | 
			
		||||
	}
 | 
			
		||||
	return val.(map[string]int), nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// StringToIntVar defines a string flag with specified name, default value, and usage string.
 | 
			
		||||
// The argument p points to a map[string]int variable in which to store the values of the multiple flags.
 | 
			
		||||
// The value of each argument will not try to be separated by comma
 | 
			
		||||
func (f *FlagSet) StringToIntVar(p *map[string]int, name string, value map[string]int, usage string) {
 | 
			
		||||
	f.VarP(newStringToIntValue(value, p), name, "", usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// StringToIntVarP is like StringToIntVar, but accepts a shorthand letter that can be used after a single dash.
 | 
			
		||||
func (f *FlagSet) StringToIntVarP(p *map[string]int, name, shorthand string, value map[string]int, usage string) {
 | 
			
		||||
	f.VarP(newStringToIntValue(value, p), name, shorthand, usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// StringToIntVar defines a string flag with specified name, default value, and usage string.
 | 
			
		||||
// The argument p points to a map[string]int variable in which to store the value of the flag.
 | 
			
		||||
// The value of each argument will not try to be separated by comma
 | 
			
		||||
func StringToIntVar(p *map[string]int, name string, value map[string]int, usage string) {
 | 
			
		||||
	CommandLine.VarP(newStringToIntValue(value, p), name, "", usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// StringToIntVarP is like StringToIntVar, but accepts a shorthand letter that can be used after a single dash.
 | 
			
		||||
func StringToIntVarP(p *map[string]int, name, shorthand string, value map[string]int, usage string) {
 | 
			
		||||
	CommandLine.VarP(newStringToIntValue(value, p), name, shorthand, usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// StringToInt defines a string flag with specified name, default value, and usage string.
 | 
			
		||||
// The return value is the address of a map[string]int variable that stores the value of the flag.
 | 
			
		||||
// The value of each argument will not try to be separated by comma
 | 
			
		||||
func (f *FlagSet) StringToInt(name string, value map[string]int, usage string) *map[string]int {
 | 
			
		||||
	p := map[string]int{}
 | 
			
		||||
	f.StringToIntVarP(&p, name, "", value, usage)
 | 
			
		||||
	return &p
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// StringToIntP is like StringToInt, but accepts a shorthand letter that can be used after a single dash.
 | 
			
		||||
func (f *FlagSet) StringToIntP(name, shorthand string, value map[string]int, usage string) *map[string]int {
 | 
			
		||||
	p := map[string]int{}
 | 
			
		||||
	f.StringToIntVarP(&p, name, shorthand, value, usage)
 | 
			
		||||
	return &p
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// StringToInt defines a string flag with specified name, default value, and usage string.
 | 
			
		||||
// The return value is the address of a map[string]int variable that stores the value of the flag.
 | 
			
		||||
// The value of each argument will not try to be separated by comma
 | 
			
		||||
func StringToInt(name string, value map[string]int, usage string) *map[string]int {
 | 
			
		||||
	return CommandLine.StringToIntP(name, "", value, usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// StringToIntP is like StringToInt, but accepts a shorthand letter that can be used after a single dash.
 | 
			
		||||
func StringToIntP(name, shorthand string, value map[string]int, usage string) *map[string]int {
 | 
			
		||||
	return CommandLine.StringToIntP(name, shorthand, value, usage)
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										149
									
								
								vendor/github.com/spf13/pflag/string_to_int64.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										149
									
								
								vendor/github.com/spf13/pflag/string_to_int64.go
									
									
									
										generated
									
									
										vendored
									
									
								
							@@ -1,149 +0,0 @@
 | 
			
		||||
package pflag
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"bytes"
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"strconv"
 | 
			
		||||
	"strings"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// -- stringToInt64 Value
 | 
			
		||||
type stringToInt64Value struct {
 | 
			
		||||
	value   *map[string]int64
 | 
			
		||||
	changed bool
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func newStringToInt64Value(val map[string]int64, p *map[string]int64) *stringToInt64Value {
 | 
			
		||||
	ssv := new(stringToInt64Value)
 | 
			
		||||
	ssv.value = p
 | 
			
		||||
	*ssv.value = val
 | 
			
		||||
	return ssv
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Format: a=1,b=2
 | 
			
		||||
func (s *stringToInt64Value) Set(val string) error {
 | 
			
		||||
	ss := strings.Split(val, ",")
 | 
			
		||||
	out := make(map[string]int64, len(ss))
 | 
			
		||||
	for _, pair := range ss {
 | 
			
		||||
		kv := strings.SplitN(pair, "=", 2)
 | 
			
		||||
		if len(kv) != 2 {
 | 
			
		||||
			return fmt.Errorf("%s must be formatted as key=value", pair)
 | 
			
		||||
		}
 | 
			
		||||
		var err error
 | 
			
		||||
		out[kv[0]], err = strconv.ParseInt(kv[1], 10, 64)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			return err
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	if !s.changed {
 | 
			
		||||
		*s.value = out
 | 
			
		||||
	} else {
 | 
			
		||||
		for k, v := range out {
 | 
			
		||||
			(*s.value)[k] = v
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	s.changed = true
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (s *stringToInt64Value) Type() string {
 | 
			
		||||
	return "stringToInt64"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (s *stringToInt64Value) String() string {
 | 
			
		||||
	var buf bytes.Buffer
 | 
			
		||||
	i := 0
 | 
			
		||||
	for k, v := range *s.value {
 | 
			
		||||
		if i > 0 {
 | 
			
		||||
			buf.WriteRune(',')
 | 
			
		||||
		}
 | 
			
		||||
		buf.WriteString(k)
 | 
			
		||||
		buf.WriteRune('=')
 | 
			
		||||
		buf.WriteString(strconv.FormatInt(v, 10))
 | 
			
		||||
		i++
 | 
			
		||||
	}
 | 
			
		||||
	return "[" + buf.String() + "]"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func stringToInt64Conv(val string) (interface{}, error) {
 | 
			
		||||
	val = strings.Trim(val, "[]")
 | 
			
		||||
	// An empty string would cause an empty map
 | 
			
		||||
	if len(val) == 0 {
 | 
			
		||||
		return map[string]int64{}, nil
 | 
			
		||||
	}
 | 
			
		||||
	ss := strings.Split(val, ",")
 | 
			
		||||
	out := make(map[string]int64, len(ss))
 | 
			
		||||
	for _, pair := range ss {
 | 
			
		||||
		kv := strings.SplitN(pair, "=", 2)
 | 
			
		||||
		if len(kv) != 2 {
 | 
			
		||||
			return nil, fmt.Errorf("%s must be formatted as key=value", pair)
 | 
			
		||||
		}
 | 
			
		||||
		var err error
 | 
			
		||||
		out[kv[0]], err = strconv.ParseInt(kv[1], 10, 64)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			return nil, err
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	return out, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// GetStringToInt64 return the map[string]int64 value of a flag with the given name
 | 
			
		||||
func (f *FlagSet) GetStringToInt64(name string) (map[string]int64, error) {
 | 
			
		||||
	val, err := f.getFlagType(name, "stringToInt64", stringToInt64Conv)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return map[string]int64{}, err
 | 
			
		||||
	}
 | 
			
		||||
	return val.(map[string]int64), nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// StringToInt64Var defines a string flag with specified name, default value, and usage string.
 | 
			
		||||
// The argument p point64s to a map[string]int64 variable in which to store the values of the multiple flags.
 | 
			
		||||
// The value of each argument will not try to be separated by comma
 | 
			
		||||
func (f *FlagSet) StringToInt64Var(p *map[string]int64, name string, value map[string]int64, usage string) {
 | 
			
		||||
	f.VarP(newStringToInt64Value(value, p), name, "", usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// StringToInt64VarP is like StringToInt64Var, but accepts a shorthand letter that can be used after a single dash.
 | 
			
		||||
func (f *FlagSet) StringToInt64VarP(p *map[string]int64, name, shorthand string, value map[string]int64, usage string) {
 | 
			
		||||
	f.VarP(newStringToInt64Value(value, p), name, shorthand, usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// StringToInt64Var defines a string flag with specified name, default value, and usage string.
 | 
			
		||||
// The argument p point64s to a map[string]int64 variable in which to store the value of the flag.
 | 
			
		||||
// The value of each argument will not try to be separated by comma
 | 
			
		||||
func StringToInt64Var(p *map[string]int64, name string, value map[string]int64, usage string) {
 | 
			
		||||
	CommandLine.VarP(newStringToInt64Value(value, p), name, "", usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// StringToInt64VarP is like StringToInt64Var, but accepts a shorthand letter that can be used after a single dash.
 | 
			
		||||
func StringToInt64VarP(p *map[string]int64, name, shorthand string, value map[string]int64, usage string) {
 | 
			
		||||
	CommandLine.VarP(newStringToInt64Value(value, p), name, shorthand, usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// StringToInt64 defines a string flag with specified name, default value, and usage string.
 | 
			
		||||
// The return value is the address of a map[string]int64 variable that stores the value of the flag.
 | 
			
		||||
// The value of each argument will not try to be separated by comma
 | 
			
		||||
func (f *FlagSet) StringToInt64(name string, value map[string]int64, usage string) *map[string]int64 {
 | 
			
		||||
	p := map[string]int64{}
 | 
			
		||||
	f.StringToInt64VarP(&p, name, "", value, usage)
 | 
			
		||||
	return &p
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// StringToInt64P is like StringToInt64, but accepts a shorthand letter that can be used after a single dash.
 | 
			
		||||
func (f *FlagSet) StringToInt64P(name, shorthand string, value map[string]int64, usage string) *map[string]int64 {
 | 
			
		||||
	p := map[string]int64{}
 | 
			
		||||
	f.StringToInt64VarP(&p, name, shorthand, value, usage)
 | 
			
		||||
	return &p
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// StringToInt64 defines a string flag with specified name, default value, and usage string.
 | 
			
		||||
// The return value is the address of a map[string]int64 variable that stores the value of the flag.
 | 
			
		||||
// The value of each argument will not try to be separated by comma
 | 
			
		||||
func StringToInt64(name string, value map[string]int64, usage string) *map[string]int64 {
 | 
			
		||||
	return CommandLine.StringToInt64P(name, "", value, usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// StringToInt64P is like StringToInt64, but accepts a shorthand letter that can be used after a single dash.
 | 
			
		||||
func StringToInt64P(name, shorthand string, value map[string]int64, usage string) *map[string]int64 {
 | 
			
		||||
	return CommandLine.StringToInt64P(name, shorthand, value, usage)
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										160
									
								
								vendor/github.com/spf13/pflag/string_to_string.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										160
									
								
								vendor/github.com/spf13/pflag/string_to_string.go
									
									
									
										generated
									
									
										vendored
									
									
								
							@@ -1,160 +0,0 @@
 | 
			
		||||
package pflag
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"bytes"
 | 
			
		||||
	"encoding/csv"
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"strings"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// -- stringToString Value
 | 
			
		||||
type stringToStringValue struct {
 | 
			
		||||
	value   *map[string]string
 | 
			
		||||
	changed bool
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func newStringToStringValue(val map[string]string, p *map[string]string) *stringToStringValue {
 | 
			
		||||
	ssv := new(stringToStringValue)
 | 
			
		||||
	ssv.value = p
 | 
			
		||||
	*ssv.value = val
 | 
			
		||||
	return ssv
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Format: a=1,b=2
 | 
			
		||||
func (s *stringToStringValue) Set(val string) error {
 | 
			
		||||
	var ss []string
 | 
			
		||||
	n := strings.Count(val, "=")
 | 
			
		||||
	switch n {
 | 
			
		||||
	case 0:
 | 
			
		||||
		return fmt.Errorf("%s must be formatted as key=value", val)
 | 
			
		||||
	case 1:
 | 
			
		||||
		ss = append(ss, strings.Trim(val, `"`))
 | 
			
		||||
	default:
 | 
			
		||||
		r := csv.NewReader(strings.NewReader(val))
 | 
			
		||||
		var err error
 | 
			
		||||
		ss, err = r.Read()
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			return err
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	out := make(map[string]string, len(ss))
 | 
			
		||||
	for _, pair := range ss {
 | 
			
		||||
		kv := strings.SplitN(pair, "=", 2)
 | 
			
		||||
		if len(kv) != 2 {
 | 
			
		||||
			return fmt.Errorf("%s must be formatted as key=value", pair)
 | 
			
		||||
		}
 | 
			
		||||
		out[kv[0]] = kv[1]
 | 
			
		||||
	}
 | 
			
		||||
	if !s.changed {
 | 
			
		||||
		*s.value = out
 | 
			
		||||
	} else {
 | 
			
		||||
		for k, v := range out {
 | 
			
		||||
			(*s.value)[k] = v
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	s.changed = true
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (s *stringToStringValue) Type() string {
 | 
			
		||||
	return "stringToString"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (s *stringToStringValue) String() string {
 | 
			
		||||
	records := make([]string, 0, len(*s.value)>>1)
 | 
			
		||||
	for k, v := range *s.value {
 | 
			
		||||
		records = append(records, k+"="+v)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	var buf bytes.Buffer
 | 
			
		||||
	w := csv.NewWriter(&buf)
 | 
			
		||||
	if err := w.Write(records); err != nil {
 | 
			
		||||
		panic(err)
 | 
			
		||||
	}
 | 
			
		||||
	w.Flush()
 | 
			
		||||
	return "[" + strings.TrimSpace(buf.String()) + "]"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func stringToStringConv(val string) (interface{}, error) {
 | 
			
		||||
	val = strings.Trim(val, "[]")
 | 
			
		||||
	// An empty string would cause an empty map
 | 
			
		||||
	if len(val) == 0 {
 | 
			
		||||
		return map[string]string{}, nil
 | 
			
		||||
	}
 | 
			
		||||
	r := csv.NewReader(strings.NewReader(val))
 | 
			
		||||
	ss, err := r.Read()
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
	out := make(map[string]string, len(ss))
 | 
			
		||||
	for _, pair := range ss {
 | 
			
		||||
		kv := strings.SplitN(pair, "=", 2)
 | 
			
		||||
		if len(kv) != 2 {
 | 
			
		||||
			return nil, fmt.Errorf("%s must be formatted as key=value", pair)
 | 
			
		||||
		}
 | 
			
		||||
		out[kv[0]] = kv[1]
 | 
			
		||||
	}
 | 
			
		||||
	return out, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// GetStringToString return the map[string]string value of a flag with the given name
 | 
			
		||||
func (f *FlagSet) GetStringToString(name string) (map[string]string, error) {
 | 
			
		||||
	val, err := f.getFlagType(name, "stringToString", stringToStringConv)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return map[string]string{}, err
 | 
			
		||||
	}
 | 
			
		||||
	return val.(map[string]string), nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// StringToStringVar defines a string flag with specified name, default value, and usage string.
 | 
			
		||||
// The argument p points to a map[string]string variable in which to store the values of the multiple flags.
 | 
			
		||||
// The value of each argument will not try to be separated by comma
 | 
			
		||||
func (f *FlagSet) StringToStringVar(p *map[string]string, name string, value map[string]string, usage string) {
 | 
			
		||||
	f.VarP(newStringToStringValue(value, p), name, "", usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// StringToStringVarP is like StringToStringVar, but accepts a shorthand letter that can be used after a single dash.
 | 
			
		||||
func (f *FlagSet) StringToStringVarP(p *map[string]string, name, shorthand string, value map[string]string, usage string) {
 | 
			
		||||
	f.VarP(newStringToStringValue(value, p), name, shorthand, usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// StringToStringVar defines a string flag with specified name, default value, and usage string.
 | 
			
		||||
// The argument p points to a map[string]string variable in which to store the value of the flag.
 | 
			
		||||
// The value of each argument will not try to be separated by comma
 | 
			
		||||
func StringToStringVar(p *map[string]string, name string, value map[string]string, usage string) {
 | 
			
		||||
	CommandLine.VarP(newStringToStringValue(value, p), name, "", usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// StringToStringVarP is like StringToStringVar, but accepts a shorthand letter that can be used after a single dash.
 | 
			
		||||
func StringToStringVarP(p *map[string]string, name, shorthand string, value map[string]string, usage string) {
 | 
			
		||||
	CommandLine.VarP(newStringToStringValue(value, p), name, shorthand, usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// StringToString defines a string flag with specified name, default value, and usage string.
 | 
			
		||||
// The return value is the address of a map[string]string variable that stores the value of the flag.
 | 
			
		||||
// The value of each argument will not try to be separated by comma
 | 
			
		||||
func (f *FlagSet) StringToString(name string, value map[string]string, usage string) *map[string]string {
 | 
			
		||||
	p := map[string]string{}
 | 
			
		||||
	f.StringToStringVarP(&p, name, "", value, usage)
 | 
			
		||||
	return &p
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// StringToStringP is like StringToString, but accepts a shorthand letter that can be used after a single dash.
 | 
			
		||||
func (f *FlagSet) StringToStringP(name, shorthand string, value map[string]string, usage string) *map[string]string {
 | 
			
		||||
	p := map[string]string{}
 | 
			
		||||
	f.StringToStringVarP(&p, name, shorthand, value, usage)
 | 
			
		||||
	return &p
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// StringToString defines a string flag with specified name, default value, and usage string.
 | 
			
		||||
// The return value is the address of a map[string]string variable that stores the value of the flag.
 | 
			
		||||
// The value of each argument will not try to be separated by comma
 | 
			
		||||
func StringToString(name string, value map[string]string, usage string) *map[string]string {
 | 
			
		||||
	return CommandLine.StringToStringP(name, "", value, usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// StringToStringP is like StringToString, but accepts a shorthand letter that can be used after a single dash.
 | 
			
		||||
func StringToStringP(name, shorthand string, value map[string]string, usage string) *map[string]string {
 | 
			
		||||
	return CommandLine.StringToStringP(name, shorthand, value, usage)
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										88
									
								
								vendor/github.com/spf13/pflag/uint.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										88
									
								
								vendor/github.com/spf13/pflag/uint.go
									
									
									
										generated
									
									
										vendored
									
									
								
							@@ -1,88 +0,0 @@
 | 
			
		||||
package pflag
 | 
			
		||||
 | 
			
		||||
import "strconv"
 | 
			
		||||
 | 
			
		||||
// -- uint Value
 | 
			
		||||
type uintValue uint
 | 
			
		||||
 | 
			
		||||
func newUintValue(val uint, p *uint) *uintValue {
 | 
			
		||||
	*p = val
 | 
			
		||||
	return (*uintValue)(p)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (i *uintValue) Set(s string) error {
 | 
			
		||||
	v, err := strconv.ParseUint(s, 0, 64)
 | 
			
		||||
	*i = uintValue(v)
 | 
			
		||||
	return err
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (i *uintValue) Type() string {
 | 
			
		||||
	return "uint"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (i *uintValue) String() string { return strconv.FormatUint(uint64(*i), 10) }
 | 
			
		||||
 | 
			
		||||
func uintConv(sval string) (interface{}, error) {
 | 
			
		||||
	v, err := strconv.ParseUint(sval, 0, 0)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return 0, err
 | 
			
		||||
	}
 | 
			
		||||
	return uint(v), nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// GetUint return the uint value of a flag with the given name
 | 
			
		||||
func (f *FlagSet) GetUint(name string) (uint, error) {
 | 
			
		||||
	val, err := f.getFlagType(name, "uint", uintConv)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return 0, err
 | 
			
		||||
	}
 | 
			
		||||
	return val.(uint), nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// UintVar defines a uint flag with specified name, default value, and usage string.
 | 
			
		||||
// The argument p points to a uint variable in which to store the value of the flag.
 | 
			
		||||
func (f *FlagSet) UintVar(p *uint, name string, value uint, usage string) {
 | 
			
		||||
	f.VarP(newUintValue(value, p), name, "", usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// UintVarP is like UintVar, but accepts a shorthand letter that can be used after a single dash.
 | 
			
		||||
func (f *FlagSet) UintVarP(p *uint, name, shorthand string, value uint, usage string) {
 | 
			
		||||
	f.VarP(newUintValue(value, p), name, shorthand, usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// UintVar defines a uint flag with specified name, default value, and usage string.
 | 
			
		||||
// The argument p points to a uint  variable in which to store the value of the flag.
 | 
			
		||||
func UintVar(p *uint, name string, value uint, usage string) {
 | 
			
		||||
	CommandLine.VarP(newUintValue(value, p), name, "", usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// UintVarP is like UintVar, but accepts a shorthand letter that can be used after a single dash.
 | 
			
		||||
func UintVarP(p *uint, name, shorthand string, value uint, usage string) {
 | 
			
		||||
	CommandLine.VarP(newUintValue(value, p), name, shorthand, usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Uint defines a uint flag with specified name, default value, and usage string.
 | 
			
		||||
// The return value is the address of a uint  variable that stores the value of the flag.
 | 
			
		||||
func (f *FlagSet) Uint(name string, value uint, usage string) *uint {
 | 
			
		||||
	p := new(uint)
 | 
			
		||||
	f.UintVarP(p, name, "", value, usage)
 | 
			
		||||
	return p
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// UintP is like Uint, but accepts a shorthand letter that can be used after a single dash.
 | 
			
		||||
func (f *FlagSet) UintP(name, shorthand string, value uint, usage string) *uint {
 | 
			
		||||
	p := new(uint)
 | 
			
		||||
	f.UintVarP(p, name, shorthand, value, usage)
 | 
			
		||||
	return p
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Uint defines a uint flag with specified name, default value, and usage string.
 | 
			
		||||
// The return value is the address of a uint  variable that stores the value of the flag.
 | 
			
		||||
func Uint(name string, value uint, usage string) *uint {
 | 
			
		||||
	return CommandLine.UintP(name, "", value, usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// UintP is like Uint, but accepts a shorthand letter that can be used after a single dash.
 | 
			
		||||
func UintP(name, shorthand string, value uint, usage string) *uint {
 | 
			
		||||
	return CommandLine.UintP(name, shorthand, value, usage)
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										88
									
								
								vendor/github.com/spf13/pflag/uint16.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										88
									
								
								vendor/github.com/spf13/pflag/uint16.go
									
									
									
										generated
									
									
										vendored
									
									
								
							@@ -1,88 +0,0 @@
 | 
			
		||||
package pflag
 | 
			
		||||
 | 
			
		||||
import "strconv"
 | 
			
		||||
 | 
			
		||||
// -- uint16 value
 | 
			
		||||
type uint16Value uint16
 | 
			
		||||
 | 
			
		||||
func newUint16Value(val uint16, p *uint16) *uint16Value {
 | 
			
		||||
	*p = val
 | 
			
		||||
	return (*uint16Value)(p)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (i *uint16Value) Set(s string) error {
 | 
			
		||||
	v, err := strconv.ParseUint(s, 0, 16)
 | 
			
		||||
	*i = uint16Value(v)
 | 
			
		||||
	return err
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (i *uint16Value) Type() string {
 | 
			
		||||
	return "uint16"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (i *uint16Value) String() string { return strconv.FormatUint(uint64(*i), 10) }
 | 
			
		||||
 | 
			
		||||
func uint16Conv(sval string) (interface{}, error) {
 | 
			
		||||
	v, err := strconv.ParseUint(sval, 0, 16)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return 0, err
 | 
			
		||||
	}
 | 
			
		||||
	return uint16(v), nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// GetUint16 return the uint16 value of a flag with the given name
 | 
			
		||||
func (f *FlagSet) GetUint16(name string) (uint16, error) {
 | 
			
		||||
	val, err := f.getFlagType(name, "uint16", uint16Conv)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return 0, err
 | 
			
		||||
	}
 | 
			
		||||
	return val.(uint16), nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Uint16Var defines a uint flag with specified name, default value, and usage string.
 | 
			
		||||
// The argument p points to a uint variable in which to store the value of the flag.
 | 
			
		||||
func (f *FlagSet) Uint16Var(p *uint16, name string, value uint16, usage string) {
 | 
			
		||||
	f.VarP(newUint16Value(value, p), name, "", usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Uint16VarP is like Uint16Var, but accepts a shorthand letter that can be used after a single dash.
 | 
			
		||||
func (f *FlagSet) Uint16VarP(p *uint16, name, shorthand string, value uint16, usage string) {
 | 
			
		||||
	f.VarP(newUint16Value(value, p), name, shorthand, usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Uint16Var defines a uint flag with specified name, default value, and usage string.
 | 
			
		||||
// The argument p points to a uint  variable in which to store the value of the flag.
 | 
			
		||||
func Uint16Var(p *uint16, name string, value uint16, usage string) {
 | 
			
		||||
	CommandLine.VarP(newUint16Value(value, p), name, "", usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Uint16VarP is like Uint16Var, but accepts a shorthand letter that can be used after a single dash.
 | 
			
		||||
func Uint16VarP(p *uint16, name, shorthand string, value uint16, usage string) {
 | 
			
		||||
	CommandLine.VarP(newUint16Value(value, p), name, shorthand, usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Uint16 defines a uint flag with specified name, default value, and usage string.
 | 
			
		||||
// The return value is the address of a uint  variable that stores the value of the flag.
 | 
			
		||||
func (f *FlagSet) Uint16(name string, value uint16, usage string) *uint16 {
 | 
			
		||||
	p := new(uint16)
 | 
			
		||||
	f.Uint16VarP(p, name, "", value, usage)
 | 
			
		||||
	return p
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Uint16P is like Uint16, but accepts a shorthand letter that can be used after a single dash.
 | 
			
		||||
func (f *FlagSet) Uint16P(name, shorthand string, value uint16, usage string) *uint16 {
 | 
			
		||||
	p := new(uint16)
 | 
			
		||||
	f.Uint16VarP(p, name, shorthand, value, usage)
 | 
			
		||||
	return p
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Uint16 defines a uint flag with specified name, default value, and usage string.
 | 
			
		||||
// The return value is the address of a uint  variable that stores the value of the flag.
 | 
			
		||||
func Uint16(name string, value uint16, usage string) *uint16 {
 | 
			
		||||
	return CommandLine.Uint16P(name, "", value, usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Uint16P is like Uint16, but accepts a shorthand letter that can be used after a single dash.
 | 
			
		||||
func Uint16P(name, shorthand string, value uint16, usage string) *uint16 {
 | 
			
		||||
	return CommandLine.Uint16P(name, shorthand, value, usage)
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										88
									
								
								vendor/github.com/spf13/pflag/uint32.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										88
									
								
								vendor/github.com/spf13/pflag/uint32.go
									
									
									
										generated
									
									
										vendored
									
									
								
							@@ -1,88 +0,0 @@
 | 
			
		||||
package pflag
 | 
			
		||||
 | 
			
		||||
import "strconv"
 | 
			
		||||
 | 
			
		||||
// -- uint32 value
 | 
			
		||||
type uint32Value uint32
 | 
			
		||||
 | 
			
		||||
func newUint32Value(val uint32, p *uint32) *uint32Value {
 | 
			
		||||
	*p = val
 | 
			
		||||
	return (*uint32Value)(p)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (i *uint32Value) Set(s string) error {
 | 
			
		||||
	v, err := strconv.ParseUint(s, 0, 32)
 | 
			
		||||
	*i = uint32Value(v)
 | 
			
		||||
	return err
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (i *uint32Value) Type() string {
 | 
			
		||||
	return "uint32"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (i *uint32Value) String() string { return strconv.FormatUint(uint64(*i), 10) }
 | 
			
		||||
 | 
			
		||||
func uint32Conv(sval string) (interface{}, error) {
 | 
			
		||||
	v, err := strconv.ParseUint(sval, 0, 32)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return 0, err
 | 
			
		||||
	}
 | 
			
		||||
	return uint32(v), nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// GetUint32 return the uint32 value of a flag with the given name
 | 
			
		||||
func (f *FlagSet) GetUint32(name string) (uint32, error) {
 | 
			
		||||
	val, err := f.getFlagType(name, "uint32", uint32Conv)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return 0, err
 | 
			
		||||
	}
 | 
			
		||||
	return val.(uint32), nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Uint32Var defines a uint32 flag with specified name, default value, and usage string.
 | 
			
		||||
// The argument p points to a uint32 variable in which to store the value of the flag.
 | 
			
		||||
func (f *FlagSet) Uint32Var(p *uint32, name string, value uint32, usage string) {
 | 
			
		||||
	f.VarP(newUint32Value(value, p), name, "", usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Uint32VarP is like Uint32Var, but accepts a shorthand letter that can be used after a single dash.
 | 
			
		||||
func (f *FlagSet) Uint32VarP(p *uint32, name, shorthand string, value uint32, usage string) {
 | 
			
		||||
	f.VarP(newUint32Value(value, p), name, shorthand, usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Uint32Var defines a uint32 flag with specified name, default value, and usage string.
 | 
			
		||||
// The argument p points to a uint32  variable in which to store the value of the flag.
 | 
			
		||||
func Uint32Var(p *uint32, name string, value uint32, usage string) {
 | 
			
		||||
	CommandLine.VarP(newUint32Value(value, p), name, "", usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Uint32VarP is like Uint32Var, but accepts a shorthand letter that can be used after a single dash.
 | 
			
		||||
func Uint32VarP(p *uint32, name, shorthand string, value uint32, usage string) {
 | 
			
		||||
	CommandLine.VarP(newUint32Value(value, p), name, shorthand, usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Uint32 defines a uint32 flag with specified name, default value, and usage string.
 | 
			
		||||
// The return value is the address of a uint32  variable that stores the value of the flag.
 | 
			
		||||
func (f *FlagSet) Uint32(name string, value uint32, usage string) *uint32 {
 | 
			
		||||
	p := new(uint32)
 | 
			
		||||
	f.Uint32VarP(p, name, "", value, usage)
 | 
			
		||||
	return p
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Uint32P is like Uint32, but accepts a shorthand letter that can be used after a single dash.
 | 
			
		||||
func (f *FlagSet) Uint32P(name, shorthand string, value uint32, usage string) *uint32 {
 | 
			
		||||
	p := new(uint32)
 | 
			
		||||
	f.Uint32VarP(p, name, shorthand, value, usage)
 | 
			
		||||
	return p
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Uint32 defines a uint32 flag with specified name, default value, and usage string.
 | 
			
		||||
// The return value is the address of a uint32  variable that stores the value of the flag.
 | 
			
		||||
func Uint32(name string, value uint32, usage string) *uint32 {
 | 
			
		||||
	return CommandLine.Uint32P(name, "", value, usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Uint32P is like Uint32, but accepts a shorthand letter that can be used after a single dash.
 | 
			
		||||
func Uint32P(name, shorthand string, value uint32, usage string) *uint32 {
 | 
			
		||||
	return CommandLine.Uint32P(name, shorthand, value, usage)
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										88
									
								
								vendor/github.com/spf13/pflag/uint64.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										88
									
								
								vendor/github.com/spf13/pflag/uint64.go
									
									
									
										generated
									
									
										vendored
									
									
								
							@@ -1,88 +0,0 @@
 | 
			
		||||
package pflag
 | 
			
		||||
 | 
			
		||||
import "strconv"
 | 
			
		||||
 | 
			
		||||
// -- uint64 Value
 | 
			
		||||
type uint64Value uint64
 | 
			
		||||
 | 
			
		||||
func newUint64Value(val uint64, p *uint64) *uint64Value {
 | 
			
		||||
	*p = val
 | 
			
		||||
	return (*uint64Value)(p)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (i *uint64Value) Set(s string) error {
 | 
			
		||||
	v, err := strconv.ParseUint(s, 0, 64)
 | 
			
		||||
	*i = uint64Value(v)
 | 
			
		||||
	return err
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (i *uint64Value) Type() string {
 | 
			
		||||
	return "uint64"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (i *uint64Value) String() string { return strconv.FormatUint(uint64(*i), 10) }
 | 
			
		||||
 | 
			
		||||
func uint64Conv(sval string) (interface{}, error) {
 | 
			
		||||
	v, err := strconv.ParseUint(sval, 0, 64)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return 0, err
 | 
			
		||||
	}
 | 
			
		||||
	return uint64(v), nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// GetUint64 return the uint64 value of a flag with the given name
 | 
			
		||||
func (f *FlagSet) GetUint64(name string) (uint64, error) {
 | 
			
		||||
	val, err := f.getFlagType(name, "uint64", uint64Conv)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return 0, err
 | 
			
		||||
	}
 | 
			
		||||
	return val.(uint64), nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Uint64Var defines a uint64 flag with specified name, default value, and usage string.
 | 
			
		||||
// The argument p points to a uint64 variable in which to store the value of the flag.
 | 
			
		||||
func (f *FlagSet) Uint64Var(p *uint64, name string, value uint64, usage string) {
 | 
			
		||||
	f.VarP(newUint64Value(value, p), name, "", usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Uint64VarP is like Uint64Var, but accepts a shorthand letter that can be used after a single dash.
 | 
			
		||||
func (f *FlagSet) Uint64VarP(p *uint64, name, shorthand string, value uint64, usage string) {
 | 
			
		||||
	f.VarP(newUint64Value(value, p), name, shorthand, usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Uint64Var defines a uint64 flag with specified name, default value, and usage string.
 | 
			
		||||
// The argument p points to a uint64 variable in which to store the value of the flag.
 | 
			
		||||
func Uint64Var(p *uint64, name string, value uint64, usage string) {
 | 
			
		||||
	CommandLine.VarP(newUint64Value(value, p), name, "", usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Uint64VarP is like Uint64Var, but accepts a shorthand letter that can be used after a single dash.
 | 
			
		||||
func Uint64VarP(p *uint64, name, shorthand string, value uint64, usage string) {
 | 
			
		||||
	CommandLine.VarP(newUint64Value(value, p), name, shorthand, usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Uint64 defines a uint64 flag with specified name, default value, and usage string.
 | 
			
		||||
// The return value is the address of a uint64 variable that stores the value of the flag.
 | 
			
		||||
func (f *FlagSet) Uint64(name string, value uint64, usage string) *uint64 {
 | 
			
		||||
	p := new(uint64)
 | 
			
		||||
	f.Uint64VarP(p, name, "", value, usage)
 | 
			
		||||
	return p
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Uint64P is like Uint64, but accepts a shorthand letter that can be used after a single dash.
 | 
			
		||||
func (f *FlagSet) Uint64P(name, shorthand string, value uint64, usage string) *uint64 {
 | 
			
		||||
	p := new(uint64)
 | 
			
		||||
	f.Uint64VarP(p, name, shorthand, value, usage)
 | 
			
		||||
	return p
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Uint64 defines a uint64 flag with specified name, default value, and usage string.
 | 
			
		||||
// The return value is the address of a uint64 variable that stores the value of the flag.
 | 
			
		||||
func Uint64(name string, value uint64, usage string) *uint64 {
 | 
			
		||||
	return CommandLine.Uint64P(name, "", value, usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Uint64P is like Uint64, but accepts a shorthand letter that can be used after a single dash.
 | 
			
		||||
func Uint64P(name, shorthand string, value uint64, usage string) *uint64 {
 | 
			
		||||
	return CommandLine.Uint64P(name, shorthand, value, usage)
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										88
									
								
								vendor/github.com/spf13/pflag/uint8.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										88
									
								
								vendor/github.com/spf13/pflag/uint8.go
									
									
									
										generated
									
									
										vendored
									
									
								
							@@ -1,88 +0,0 @@
 | 
			
		||||
package pflag
 | 
			
		||||
 | 
			
		||||
import "strconv"
 | 
			
		||||
 | 
			
		||||
// -- uint8 Value
 | 
			
		||||
type uint8Value uint8
 | 
			
		||||
 | 
			
		||||
func newUint8Value(val uint8, p *uint8) *uint8Value {
 | 
			
		||||
	*p = val
 | 
			
		||||
	return (*uint8Value)(p)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (i *uint8Value) Set(s string) error {
 | 
			
		||||
	v, err := strconv.ParseUint(s, 0, 8)
 | 
			
		||||
	*i = uint8Value(v)
 | 
			
		||||
	return err
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (i *uint8Value) Type() string {
 | 
			
		||||
	return "uint8"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (i *uint8Value) String() string { return strconv.FormatUint(uint64(*i), 10) }
 | 
			
		||||
 | 
			
		||||
func uint8Conv(sval string) (interface{}, error) {
 | 
			
		||||
	v, err := strconv.ParseUint(sval, 0, 8)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return 0, err
 | 
			
		||||
	}
 | 
			
		||||
	return uint8(v), nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// GetUint8 return the uint8 value of a flag with the given name
 | 
			
		||||
func (f *FlagSet) GetUint8(name string) (uint8, error) {
 | 
			
		||||
	val, err := f.getFlagType(name, "uint8", uint8Conv)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return 0, err
 | 
			
		||||
	}
 | 
			
		||||
	return val.(uint8), nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Uint8Var defines a uint8 flag with specified name, default value, and usage string.
 | 
			
		||||
// The argument p points to a uint8 variable in which to store the value of the flag.
 | 
			
		||||
func (f *FlagSet) Uint8Var(p *uint8, name string, value uint8, usage string) {
 | 
			
		||||
	f.VarP(newUint8Value(value, p), name, "", usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Uint8VarP is like Uint8Var, but accepts a shorthand letter that can be used after a single dash.
 | 
			
		||||
func (f *FlagSet) Uint8VarP(p *uint8, name, shorthand string, value uint8, usage string) {
 | 
			
		||||
	f.VarP(newUint8Value(value, p), name, shorthand, usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Uint8Var defines a uint8 flag with specified name, default value, and usage string.
 | 
			
		||||
// The argument p points to a uint8 variable in which to store the value of the flag.
 | 
			
		||||
func Uint8Var(p *uint8, name string, value uint8, usage string) {
 | 
			
		||||
	CommandLine.VarP(newUint8Value(value, p), name, "", usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Uint8VarP is like Uint8Var, but accepts a shorthand letter that can be used after a single dash.
 | 
			
		||||
func Uint8VarP(p *uint8, name, shorthand string, value uint8, usage string) {
 | 
			
		||||
	CommandLine.VarP(newUint8Value(value, p), name, shorthand, usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Uint8 defines a uint8 flag with specified name, default value, and usage string.
 | 
			
		||||
// The return value is the address of a uint8 variable that stores the value of the flag.
 | 
			
		||||
func (f *FlagSet) Uint8(name string, value uint8, usage string) *uint8 {
 | 
			
		||||
	p := new(uint8)
 | 
			
		||||
	f.Uint8VarP(p, name, "", value, usage)
 | 
			
		||||
	return p
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Uint8P is like Uint8, but accepts a shorthand letter that can be used after a single dash.
 | 
			
		||||
func (f *FlagSet) Uint8P(name, shorthand string, value uint8, usage string) *uint8 {
 | 
			
		||||
	p := new(uint8)
 | 
			
		||||
	f.Uint8VarP(p, name, shorthand, value, usage)
 | 
			
		||||
	return p
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Uint8 defines a uint8 flag with specified name, default value, and usage string.
 | 
			
		||||
// The return value is the address of a uint8 variable that stores the value of the flag.
 | 
			
		||||
func Uint8(name string, value uint8, usage string) *uint8 {
 | 
			
		||||
	return CommandLine.Uint8P(name, "", value, usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Uint8P is like Uint8, but accepts a shorthand letter that can be used after a single dash.
 | 
			
		||||
func Uint8P(name, shorthand string, value uint8, usage string) *uint8 {
 | 
			
		||||
	return CommandLine.Uint8P(name, shorthand, value, usage)
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										168
									
								
								vendor/github.com/spf13/pflag/uint_slice.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										168
									
								
								vendor/github.com/spf13/pflag/uint_slice.go
									
									
									
										generated
									
									
										vendored
									
									
								
							@@ -1,168 +0,0 @@
 | 
			
		||||
package pflag
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"strconv"
 | 
			
		||||
	"strings"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// -- uintSlice Value
 | 
			
		||||
type uintSliceValue struct {
 | 
			
		||||
	value   *[]uint
 | 
			
		||||
	changed bool
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func newUintSliceValue(val []uint, p *[]uint) *uintSliceValue {
 | 
			
		||||
	uisv := new(uintSliceValue)
 | 
			
		||||
	uisv.value = p
 | 
			
		||||
	*uisv.value = val
 | 
			
		||||
	return uisv
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (s *uintSliceValue) Set(val string) error {
 | 
			
		||||
	ss := strings.Split(val, ",")
 | 
			
		||||
	out := make([]uint, len(ss))
 | 
			
		||||
	for i, d := range ss {
 | 
			
		||||
		u, err := strconv.ParseUint(d, 10, 0)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			return err
 | 
			
		||||
		}
 | 
			
		||||
		out[i] = uint(u)
 | 
			
		||||
	}
 | 
			
		||||
	if !s.changed {
 | 
			
		||||
		*s.value = out
 | 
			
		||||
	} else {
 | 
			
		||||
		*s.value = append(*s.value, out...)
 | 
			
		||||
	}
 | 
			
		||||
	s.changed = true
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (s *uintSliceValue) Type() string {
 | 
			
		||||
	return "uintSlice"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (s *uintSliceValue) String() string {
 | 
			
		||||
	out := make([]string, len(*s.value))
 | 
			
		||||
	for i, d := range *s.value {
 | 
			
		||||
		out[i] = fmt.Sprintf("%d", d)
 | 
			
		||||
	}
 | 
			
		||||
	return "[" + strings.Join(out, ",") + "]"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (s *uintSliceValue) fromString(val string) (uint, error) {
 | 
			
		||||
	t, err := strconv.ParseUint(val, 10, 0)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return 0, err
 | 
			
		||||
	}
 | 
			
		||||
	return uint(t), nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (s *uintSliceValue) toString(val uint) string {
 | 
			
		||||
	return fmt.Sprintf("%d", val)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (s *uintSliceValue) Append(val string) error {
 | 
			
		||||
	i, err := s.fromString(val)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return err
 | 
			
		||||
	}
 | 
			
		||||
	*s.value = append(*s.value, i)
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (s *uintSliceValue) Replace(val []string) error {
 | 
			
		||||
	out := make([]uint, len(val))
 | 
			
		||||
	for i, d := range val {
 | 
			
		||||
		var err error
 | 
			
		||||
		out[i], err = s.fromString(d)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			return err
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	*s.value = out
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (s *uintSliceValue) GetSlice() []string {
 | 
			
		||||
	out := make([]string, len(*s.value))
 | 
			
		||||
	for i, d := range *s.value {
 | 
			
		||||
		out[i] = s.toString(d)
 | 
			
		||||
	}
 | 
			
		||||
	return out
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func uintSliceConv(val string) (interface{}, error) {
 | 
			
		||||
	val = strings.Trim(val, "[]")
 | 
			
		||||
	// Empty string would cause a slice with one (empty) entry
 | 
			
		||||
	if len(val) == 0 {
 | 
			
		||||
		return []uint{}, nil
 | 
			
		||||
	}
 | 
			
		||||
	ss := strings.Split(val, ",")
 | 
			
		||||
	out := make([]uint, len(ss))
 | 
			
		||||
	for i, d := range ss {
 | 
			
		||||
		u, err := strconv.ParseUint(d, 10, 0)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			return nil, err
 | 
			
		||||
		}
 | 
			
		||||
		out[i] = uint(u)
 | 
			
		||||
	}
 | 
			
		||||
	return out, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// GetUintSlice returns the []uint value of a flag with the given name.
 | 
			
		||||
func (f *FlagSet) GetUintSlice(name string) ([]uint, error) {
 | 
			
		||||
	val, err := f.getFlagType(name, "uintSlice", uintSliceConv)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return []uint{}, err
 | 
			
		||||
	}
 | 
			
		||||
	return val.([]uint), nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// UintSliceVar defines a uintSlice flag with specified name, default value, and usage string.
 | 
			
		||||
// The argument p points to a []uint variable in which to store the value of the flag.
 | 
			
		||||
func (f *FlagSet) UintSliceVar(p *[]uint, name string, value []uint, usage string) {
 | 
			
		||||
	f.VarP(newUintSliceValue(value, p), name, "", usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// UintSliceVarP is like UintSliceVar, but accepts a shorthand letter that can be used after a single dash.
 | 
			
		||||
func (f *FlagSet) UintSliceVarP(p *[]uint, name, shorthand string, value []uint, usage string) {
 | 
			
		||||
	f.VarP(newUintSliceValue(value, p), name, shorthand, usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// UintSliceVar defines a uint[] flag with specified name, default value, and usage string.
 | 
			
		||||
// The argument p points to a uint[] variable in which to store the value of the flag.
 | 
			
		||||
func UintSliceVar(p *[]uint, name string, value []uint, usage string) {
 | 
			
		||||
	CommandLine.VarP(newUintSliceValue(value, p), name, "", usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// UintSliceVarP is like the UintSliceVar, but accepts a shorthand letter that can be used after a single dash.
 | 
			
		||||
func UintSliceVarP(p *[]uint, name, shorthand string, value []uint, usage string) {
 | 
			
		||||
	CommandLine.VarP(newUintSliceValue(value, p), name, shorthand, usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// UintSlice defines a []uint flag with specified name, default value, and usage string.
 | 
			
		||||
// The return value is the address of a []uint variable that stores the value of the flag.
 | 
			
		||||
func (f *FlagSet) UintSlice(name string, value []uint, usage string) *[]uint {
 | 
			
		||||
	p := []uint{}
 | 
			
		||||
	f.UintSliceVarP(&p, name, "", value, usage)
 | 
			
		||||
	return &p
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// UintSliceP is like UintSlice, but accepts a shorthand letter that can be used after a single dash.
 | 
			
		||||
func (f *FlagSet) UintSliceP(name, shorthand string, value []uint, usage string) *[]uint {
 | 
			
		||||
	p := []uint{}
 | 
			
		||||
	f.UintSliceVarP(&p, name, shorthand, value, usage)
 | 
			
		||||
	return &p
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// UintSlice defines a []uint flag with specified name, default value, and usage string.
 | 
			
		||||
// The return value is the address of a []uint variable that stores the value of the flag.
 | 
			
		||||
func UintSlice(name string, value []uint, usage string) *[]uint {
 | 
			
		||||
	return CommandLine.UintSliceP(name, "", value, usage)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// UintSliceP is like UintSlice, but accepts a shorthand letter that can be used after a single dash.
 | 
			
		||||
func UintSliceP(name, shorthand string, value []uint, usage string) *[]uint {
 | 
			
		||||
	return CommandLine.UintSliceP(name, shorthand, value, usage)
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user