Exemple #1
0
func OidFromString(str string) *Oid {
	oid := new(Oid)
	cstr := C.CString(str)
	defer C.free(unsafe.Pointer(cstr))
	length := C.size_t(len(str))
	C.git_oid_fromstrn(oid.git_oid, cstr, length)
	return oid
}
Exemple #2
0
func NewOidFromString(from string) (*Oid, error) {
	oid := NewOid()
	cfrom := C.CString(from)
	defer C.free(unsafe.Pointer(cfrom))

	n := len(from)
	if n > _GIT_OID_HEXSZ {
		n = _GIT_OID_HEXSZ
	}
	err := gitError(C.git_oid_fromstrn(oid.oid, cfrom, C.size_t(n)))
	if err != nil {
		return nil, err
	}
	return oid, nil
}