diff options
| author | Vicent Marti <[email protected]> | 2013-03-05 20:53:04 +0100 |
|---|---|---|
| committer | Vicent Marti <[email protected]> | 2013-03-05 20:53:04 +0100 |
| commit | b1d50b70ea8c4be9c19fe91768d6653736660c4c (patch) | |
| tree | 56670245aa3f3379bc2cfd9baec097c9f8231b94 /blob.go | |
Initial commit
Diffstat (limited to 'blob.go')
| -rw-r--r-- | blob.go | 26 |
1 files changed, 26 insertions, 0 deletions
@@ -0,0 +1,26 @@ +package git + +/* +#cgo pkg-config: libgit2 +#include <git2.h> +#include <git2/errors.h> +*/ +import "C" +import ( + "unsafe" +) + +type Blob struct { + ptr *C.git_object +} + +func freeBlob(blob *Blob) { + C.git_object_free(blob.ptr) +} + +func (v *Blob) Contents() []byte { + size := C.int(C.git_blob_rawsize(v.ptr)) + buffer := unsafe.Pointer(C.git_blob_rawcontent(v.ptr)) + return C.GoBytes(buffer, size) +} + |
