_linters/src/honnef.co/go/tools/printf/printf.go
func ParseVerb(f string) (Verb, int, error) {
	if len(f) < 2 {
		return Verb{}, 0, ErrInvalid
	}
	const (
		flags = 1

		width      = 2
		widthStar  = 3
		widthIndex = 5

		dot       = 6
		prec      = 7
		precStar  = 8
		precIndex = 10

		verbIndex = 11
		verb      = 12
	)

	m := re.FindStringSubmatch(f)
	if m == nil {
		return Verb{}, 0, ErrInvalid
	}

	v := Verb{
		Letter: []rune(m[verb])[0],
		Flags:  m[flags],
		Raw:    m[0],
	}

	if m[width] != "" {
		// Literal width
		v.Width = Literal(atoi(m[width]))
	} else if m[widthStar] != "" {
		// Star width
		if m[widthIndex] != "" {
			v.Width = Star{atoi(m[widthIndex])}
		} else {
			v.Width = Star{-1}
		}
	} else {
		// Default width
		v.Width = Default{}
	}

	if m[dot] == "" {
		// default precision
		v.Precision = Default{}
	} else {
		if m[prec] != "" {
			// Literal precision
			v.Precision = Literal(atoi(m[prec]))
		} else if m[precStar] != "" {
			// Star precision
			if m[precIndex] != "" {
				v.Precision = Star{atoi(m[precIndex])}
			} else {
				v.Precision = Star{-1}
			}
		} else {
			// Zero precision
			v.Precision = Zero{}
		}
	}

	if m[verb] == "%" {
		v.Value = 0
	} else if m[verbIndex] != "" {
		v.Value = atoi(m[verbIndex])
	} else {
		v.Value = -1
	}

	return v, len(m[0]), nil
}
func ParseVerb(f string) (Verb, int, error) {
	if len(f) < 2 {
		return Verb{}, 0, ErrInvalid
	}
	const (
		flags = 1

		width      = 2
		widthStar  = 3
		widthIndex = 5

		dot       = 6
		prec      = 7
		precStar  = 8
		precIndex = 10

		verbIndex = 11
		verb      = 12
	)

	m := re.FindStringSubmatch(f)
	if m == nil {
		return Verb{}, 0, ErrInvalid
	}

	v := Verb{
		Letter: []rune(m[verb])[0],
		Flags:  m[flags],
		Raw:    m[0],
	}

	if m[width] != "" {
		// Literal width
		v.Width = Literal(atoi(m[width]))
	} else if m[widthStar] != "" {
		// Star width
		if m[widthIndex] != "" {
			v.Width = Star{atoi(m[widthIndex])}
		} else {
			v.Width = Star{-1}
		}
	} else {
		// Default width
		v.Width = Default{}
	}

	if m[dot] == "" {
		// default precision
		v.Precision = Default{}
	} else {
		if m[prec] != "" {
			// Literal precision
			v.Precision = Literal(atoi(m[prec]))
		} else if m[precStar] != "" {
			// Star precision
			if m[precIndex] != "" {
				v.Precision = Star{atoi(m[precIndex])}
			} else {
				v.Precision = Star{-1}
			}
		} else {
			// Zero precision
			v.Precision = Zero{}
		}
	}

	if m[verb] == "%" {
		v.Value = 0
	} else if m[verbIndex] != "" {
		v.Value = atoi(m[verbIndex])
	} else {
		v.Value = -1
	}

	return v, len(m[0]), nil
}
// ParseVerb parses the verb at the beginning of f.
// It returns the verb, how much of the input was consumed, and an error, if any.