util/promlint/promlint.go
func metricUnits(m string) (unit string, base string, ok bool) {
	ss := strings.Split(m, "_")

	for _, u := range baseUnits {
		// Also check for "no prefix".
		for _, p := range append(unitPrefixes, "") {
			for _, s := range ss {
				// Attempt to explicitly match a known unit with a known prefix,
				// as some words may look like "units" when matching suffix.
				//
				// As an example, "thermometers" should not match "meters", but
				// "kilometers" should.
				if s == p+u {
					return p + u, u, true
				}
			}
		}
	}

	return "", "", false
}
func metricUnits(m string) (unit string, base string, ok bool) {
	ss := strings.Split(m, "_")

	for _, u := range baseUnits {
		// Also check for "no prefix".
		for _, p := range append(unitPrefixes, "") {
			for _, s := range ss {
				// Attempt to explicitly match a known unit with a known prefix,
				// as some words may look like "units" when matching suffix.
				//
				// As an example, "thermometers" should not match "meters", but
				// "kilometers" should.
				if s == p+u {
					return p + u, u, true
				}
			}
		}
	}

	return "", "", false
}
func metricUnits ( m string ) ( unit string , base string , ok bool ) { ss := strings . Split ( m , " " ) for _ , u := range baseUnits { // Also check for "no prefix". for _ , p := range append ( unitPrefixes , " " ) { for _ , s := range ss { // Attempt to explicitly match a known unit with a known prefix, // as some words may look like "units" when matching suffix. // // As an example, "thermometers" should not match "meters", but // "kilometers" should. if s == p + u { return p + u , u , true } } } } return " " , " " , false }
// metricUnits attempts to detect known unit types used as part of a metric name,
// e.g. "foo_bytes_total" or "bar_baz_milligrams".
metricUnits attempts to detect known unit types used as part of a metric name e . g . foo_bytes_total or bar_baz_milligrams .