(s string)
| 217 | } |
| 218 | |
| 219 | func NewOid(s string) (*Oid, error) { |
| 220 | if len(s) > C.GIT_OID_HEXSZ { |
| 221 | return nil, errors.New("string is too long for oid") |
| 222 | } |
| 223 | |
| 224 | o := new(Oid) |
| 225 | |
| 226 | slice, err := hex.DecodeString(s) |
| 227 | if err != nil { |
| 228 | return nil, err |
| 229 | } |
| 230 | |
| 231 | if len(slice) != 20 { |
| 232 | return nil, &GitError{"invalid oid", ErrorClassNone, ErrorCodeGeneric} |
| 233 | } |
| 234 | |
| 235 | copy(o[:], slice[:20]) |
| 236 | return o, nil |
| 237 | } |
| 238 | |
| 239 | func (oid *Oid) String() string { |
| 240 | return hex.EncodeToString(oid[:]) |
no outgoing calls
searching dependent graphs…