func parseUintBytes(s []byte, base int, bitSize int) (n uint64, err error) {
	var cutoff, maxVal uint64

	if bitSize == 0 {
		bitSize = int(strconv.IntSize)
	}

	s0 := s
	switch {
	case len(s) < 1:
		err = strconv.ErrSyntax
		return n, &strconv.NumError{Func: "ParseUint", Num: string(s0), Err: err}

	case 2 <= base && base <= 36:
		// valid base; nothing to do

	case base == 0:
		// Look for octal, hex prefix.
		switch {
		case s[0] == '0' && len(s) > 1 && (s[1] == 'x' || s[1] == 'X'):
			base = 16
			s = s[2:]
			if len(s) < 1 {
				err = strconv.ErrSyntax
				return n, &strconv.NumError{Func: "ParseUint", Num: string(s0), Err: err}
			}
		case s[0] == '0':
			base = 8
		default:
			base = 10
		}

	default:
		err = errors.New("invalid base " + strconv.Itoa(base))
		return n, &strconv.NumError{Func: "ParseUint", Num: string(s0), Err: err}
	}

	n = 0
	cutoff = cutoff64(base)
	maxVal = 1<<uint(bitSize) - 1

	for i := 0; i < len(s); i++ {
		var v byte
		d := s[i]
		switch {
		case '0' <= d && d <= '9':
			v = d - '0'
		case 'a' <= d && d <= 'z':
			v = d - 'a' + 10
		case 'A' <= d && d <= 'Z':
			v = d - 'A' + 10
		default:
			n = 0
			err = strconv.ErrSyntax
			return n, &strconv.NumError{Func: "ParseUint", Num: string(s0), Err: err}
		}
		if int(v) >= base {
			n = 0
			err = strconv.ErrSyntax
			return n, &strconv.NumError{Func: "ParseUint", Num: string(s0), Err: err}
		}

		if n >= cutoff {
			// n*base overflows
			n = 1<<64 - 1
			err = strconv.ErrRange
			return n, &strconv.NumError{Func: "ParseUint", Num: string(s0), Err: err}
		}
		n *= uint64(base)

		n1 := n + uint64(v)
		if n1 < n || n1 > maxVal {
			// n+v overflows
			n = 1<<64 - 1
			err = strconv.ErrRange
			return n, &strconv.NumError{Func: "ParseUint", Num: string(s0), Err: err}
		}
		n = n1
	}

	return n, nil
}
func parseUintBytes(s []byte, base int, bitSize int) (n uint64, err error) {
	var cutoff, maxVal uint64

	if bitSize == 0 {
		bitSize = int(strconv.IntSize)
	}

	s0 := s
	switch {
	case len(s) < 1:
		err = strconv.ErrSyntax
		return n, &strconv.NumError{Func: "ParseUint", Num: string(s0), Err: err}

	case 2 <= base && base <= 36:
		

	case base == 0:
		
		switch {
		case s[0] == '0' && len(s) > 1 && (s[1] == 'x' || s[1] == 'X'):
			base = 16
			s = s[2:]
			if len(s) < 1 {
				err = strconv.ErrSyntax
				return n, &strconv.NumError{Func: "ParseUint", Num: string(s0), Err: err}
			}
		case s[0] == '0':
			base = 8
		default:
			base = 10
		}

	default:
		err = errors.New("invalid base " + strconv.Itoa(base))
		return n, &strconv.NumError{Func: "ParseUint", Num: string(s0), Err: err}
	}

	n = 0
	cutoff = cutoff64(base)
	maxVal = 1<<uint(bitSize) - 1

	for i := 0; i < len(s); i++ {
		var v byte
		d := s[i]
		switch {
		case '0' <= d && d <= '9':
			v = d - '0'
		case 'a' <= d && d <= 'z':
			v = d - 'a' + 10
		case 'A' <= d && d <= 'Z':
			v = d - 'A' + 10
		default:
			n = 0
			err = strconv.ErrSyntax
			return n, &strconv.NumError{Func: "ParseUint", Num: string(s0), Err: err}
		}
		if int(v) >= base {
			n = 0
			err = strconv.ErrSyntax
			return n, &strconv.NumError{Func: "ParseUint", Num: string(s0), Err: err}
		}

		if n >= cutoff {
			
			n = 1<<64 - 1
			err = strconv.ErrRange
			return n, &strconv.NumError{Func: "ParseUint", Num: string(s0), Err: err}
		}
		n *= uint64(base)

		n1 := n + uint64(v)
		if n1 < n || n1 > maxVal {
			
			n = 1<<64 - 1
			err = strconv.ErrRange
			return n, &strconv.NumError{Func: "ParseUint", Num: string(s0), Err: err}
		}
		n = n1
	}

	return n, nil
}
func parseUintBytes ( s [ ] byte , base int , bitSize int ) ( n uint64 , err error ) { var cutoff , maxVal uint64 if bitSize == 0 { bitSize = int ( strconv . IntSize ) } s0 := s switch { case len ( s ) < 1 : err = strconv . ErrSyntax return n , & strconv . NumError { Func : " " , Num : string ( s0 ) , Err : err } case 2 <= base && base <= 36 : // valid base; nothing to do case base == 0 : // Look for octal, hex prefix. switch { case s [ 0 ] == '0' && len ( s ) > 1 && ( s [ 1 ] == 'x' || s [ 1 ] == 'X' ) : base = 16 s = s [ 2 : ] if len ( s ) < 1 { err = strconv . ErrSyntax return n , & strconv . NumError { Func : " " , Num : string ( s0 ) , Err : err } } case s [ 0 ] == '0' : base = 8 default : base = 10 } default : err = errors . New ( " " + strconv . Itoa ( base ) ) return n , & strconv . NumError { Func : " " , Num : string ( s0 ) , Err : err } } n = 0 cutoff = cutoff64 ( base ) maxVal = 1 << uint ( bitSize ) - 1 for i := 0 ; i < len ( s ) ; i ++ { var v byte d := s [ i ] switch { case '0' <= d && d <= '9' : v = d - '0' case 'a' <= d && d <= 'z' : v = d - 'a' + 10 case 'A' <= d && d <= 'Z' : v = d - 'A' + 10 default : n = 0 err = strconv . ErrSyntax return n , & strconv . NumError { Func : " " , Num : string ( s0 ) , Err : err } } if int ( v ) >= base { n = 0 err = strconv . ErrSyntax return n , & strconv . NumError { Func : " " , Num : string ( s0 ) , Err : err } } if n >= cutoff { // n*base overflows n = 1 << 64 - 1 err = strconv . ErrRange return n , & strconv . NumError { Func : " " , Num : string ( s0 ) , Err : err } } n *= uint64 ( base ) n1 := n + uint64 ( v ) if n1 < n || n1 > maxVal { // n+v overflows n = 1 << 64 - 1 err = strconv . ErrRange return n , & strconv . NumError { Func : " " , Num : string ( s0 ) , Err : err } } n = n1 } return n , nil }
// parseUintBytes is like strconv.ParseUint, but using a []byte.
parseUintBytes is like strconv . ParseUint but using a [] byte .