func ParseID(s string) (ID, error) {
	s0 := s

	if s == "" {
		return ID{}, nil
	}

	var id ID

	if len(s)%2 == 1 {
		id.prefix = s[0]

		if id.prefix < 'g' || id.prefix > 'z' {
			return id, errors.Errorf("invalid content prefix")
		}

		s = s[1:]
	}

	if len(s) > 2*len(id.data) {
		return id, errors.Errorf("hash too long")
	}

	n, err := hex.Decode(id.data[:], []byte(s))
	if err != nil {
		return id, errors.Wrap(err, "invalid content hash")
	}

	if n == 0 {
		return id, errors.Errorf("id too short: %q", s0)
	}

	id.idLen = byte(n)

	return id, nil
}
// ParseID parses and validates the content ID.
ParseID parses and validates the content ID.
// ParseID parses and validates the content ID .
func ParseID(s string) (ID, error) {
	s0 := s
	if s == "" {
		return ID{}, nil
	}
	var id ID
	if len(s)%2 == 1 {
		id.prefix = s[0]
		if id.prefix < 'g' || id.prefix > 'z' {
			return id, errors.Errorf("invalid content prefix")
		}
		s = s[1:]
	}
	if len(s) > 2*len(id.data) {
		return id, errors.Errorf("hash too long")
	}
	n, err := hex.Decode(id.data[:], []byte(s))
	if err != nil {
		return id, errors.Wrap(err, "invalid content hash")
	}
	if n == 0 {
		return id, errors.Errorf("id too short: %q", s0)
	}
	id.idLen = byte(n)
	return id, nil
}
func ParseID ( s string ) ( ID , error ) { s0 := s if s == " " { return ID { } , nil } var id ID if len ( s ) % 2 == 1 { id . prefix = s [ 0 ] if id . prefix < 'g' || id . prefix > 'z' { return id , errors . Errorf ( " " ) } s = s [ 1 : ] } if len ( s ) > 2 * len ( id . data ) { return id , errors . Errorf ( " " ) } n , err := hex . Decode ( id . data [ : ] , [ ] byte ( s ) ) if err != nil { return id , errors . Wrap ( err , " " ) } if n == 0 { return id , errors . Errorf ( " " , s0 ) } id . idLen = byte ( n ) return id , nil }
ParseID parses and validates the content ID.
ParseID parses and validates the content ID .