// ParseParamNameModifierAndPostFix parses a full parameter key and returns the parameter name,
// modifier, and postfix components.  For example, "foo:bar.baz" would return ["foo","bar","baz"].
324345
func ParseParamNameModifierAndPostFix(fullParam string) (param string, modifier string, postfix string) {
	param = fullParam
	if strings.Contains(fullParam, ".") {
		split := strings.SplitN(fullParam, ".", 2)
		param = split[0]
		postfix = split[1]
	}
	if strings.Contains(param, ":") {
		split := strings.SplitN(param, ":", 2)
		param = split[0]
		modifier = split[1]
	}
	return
}
868006
func findParamMember(value map[string]interface{}, key string) string {
	for actualKey := range value {
		if strings.ToLower(key) == strings.ToLower(actualKey) {
			return actualKey
		}
	}
	return ""
}
644649
func ReplaceParameter(s string, params interface{}, value interface{}) bool {
	if params == nil {
		return false
	}

	if paramsValue := reflect.ValueOf(params); paramsValue.Kind() == reflect.Slice {
		if paramsValueSliceLength := paramsValue.Len(); paramsValueSliceLength > 0 {

			if p := strings.SplitN(s, ".", 2); len(p) > 1 {
				index, err := strconv.ParseUint(p[0], 10, 64)

				if err != nil || paramsValueSliceLength <= int(index) {
					return false
				}

				return ReplaceParameter(p[1], params.([]interface{})[index], value)
			}
		}

		return false
	}

	if p := strings.SplitN(s, ".", 2); len(p) > 1 {
		if pValue, ok := params.(map[string]interface{})[p[0]]; ok {
			return ReplaceParameter(p[1], pValue, value)
		}
	} else {
		if _, ok := (*params.(*map[string]interface{}))[p[0]]; ok {
			(*params.(*map[string]interface{}))[p[0]] = value
			return true
		}
	}

	return false
}
1145693
func parseOptionParams(value string) (option, params string) {
	// Strip off the first component; use this as the option name.
	idx := strings.IndexRune(value, ',')

	if idx == -1 {
		option, params = value, ""
	} else {
		option, params = value[:idx], value[(idx+1):]
	}
	return
}
1339402
func ParseStringParam(paramString string, info SearchParamInfo) *StringParam {
	return &StringParam{info, unescape(paramString)}
}
779890
func trimSuffixAtMaxDepth(startPrefix, path, separator string, maxDepth uint) string {
	if maxDepth == 0 {
		return path
	}
	// Remove the requested prefix from consideration, maxDepth is
	// only considered for all other levels excluding the starting prefix.
	path = strings.TrimPrefix(path, startPrefix)
	pathComponents := strings.SplitAfter(path, separator)
	if len(pathComponents) >= int(maxDepth) {
		pathComponents = pathComponents[:maxDepth]
	}
	pathComponents = append([]string{startPrefix}, pathComponents...)
	return strings.Join(pathComponents, "")
}
75741
func ParamsStructFromJSON(value interface{}, shape *Shape, prefixPackageName bool) string {
	f := paramFiller{prefixPackageName: prefixPackageName}
	return util.GoFmt(f.paramsStructAny(value, shape))
}
58094
func PathTrimPrefix(s, prefix string) string {
	s = normalizePath(s)
	prefix = normalizePath(prefix)
	if s == prefix {
		return ""
	}
	if !strings.HasSuffix(prefix, "/") {
		prefix += "/"
	}
	return strings.TrimPrefix(s, prefix)
}
503889
func (c *xContext) Param(name string, defaults ...string) (value string) {
	l := len(c.pnames)
	for i, n := range c.pnames {
		if n == name && i < l {
			value = c.pvalues[i]
			break
		}
	}

	if len(value) == 0 && len(defaults) > 0 {
		return defaults[0]
	}
	return
}
928053
func ParseOrParam(paramStr []string, info SearchParamInfo) *OrParam {
	ors := make([]SearchParam, len(paramStr))
	for i := range paramStr {
		ors[i] = info.CreateSearchParam(paramStr[i])
	}
	return &OrParam{SearchParamInfo{Name: info.Name, Type: "or"}, ors}
}
848741
func parsePrefix(req *http.Request, b *structs.QueryOptions) {
	query := req.URL.Query()
	if prefix := query.Get("prefix"); prefix != "" {
		b.Prefix = prefix
	}
}
794537
func (operation *Operation) ParseParamComment(commentLine string) error {
	swaggerParameter := Parameter{}
	paramString := commentLine

	re := regexp.MustCompile(`([-\w]+)[\s]+([\w]+)[\s]+([\S.]+)[\s]+([\w]+)[\s]+"([^"]+)"`)

	if matches := re.FindStringSubmatch(paramString); len(matches) != 6 {
		return fmt.Errorf("Can not parse param comment \"%s\", skipped.", paramString)
	} else {
		typeName, err := operation.registerType(matches[3])
		if err != nil {
			return err
		}

		swaggerParameter.Name = matches[1]
		swaggerParameter.ParamType = matches[2]
		swaggerParameter.Type = typeName
		swaggerParameter.DataType = typeName
		requiredText := strings.ToLower(matches[4])
		swaggerParameter.Required = (requiredText == "true" || requiredText == "required")
		swaggerParameter.Description = matches[5]

		operation.Parameters = append(operation.Parameters, swaggerParameter)
	}

	return nil
}
110623
func stripOptionPrefix(optname string) (prefix string, name string, islong bool) {
	if strings.HasPrefix(optname, "--") {
		return "--", optname[2:], true
	} else if strings.HasPrefix(optname, "-") {
		return "-", optname[1:], false
	}

	return "", optname, false
}
337797
func RegisterPrefix(pref string, ns string) {
	Register(Namespace{Prefix: pref, Full: ns})
}
88254
func parseDefaultIfNameFromIPCmd(routeOut string) (string, error) {
	parsedLines := parseIfNameFromIPCmd(routeOut)
	for _, parsedLine := range parsedLines {
		if parsedLine[0] == "default" &&
			parsedLine[1] == "via" &&
			parsedLine[3] == "dev" {
			ifName := strings.TrimSpace(parsedLine[4])
			return ifName, nil
		}
	}

	return "", errors.New("No default interface found")
}
547054
func (node *VindexSpec) ParseParams() (string, map[string]string) {
	var owner string
	params := map[string]string{}
	for _, p := range node.Params {
		if p.Key.Lowered() == VindexOwnerStr {
			owner = p.Val
		} else {
			params[p.Key.String()] = p.Val
		}
	}
	return owner, params
}
430709
func valuePrefix(typeName string) string {
	if v, ok := refValueMap[typeName]; ok {
		return v
	}

	return strings.ToLower(typeName)
}