summaryrefslogtreecommitdiff
path: root/blob.go
diff options
context:
space:
mode:
Diffstat (limited to 'blob.go')
-rw-r--r--blob.go26
1 files changed, 26 insertions, 0 deletions
diff --git a/blob.go b/blob.go
new file mode 100644
index 0000000..91064b1
--- /dev/null
+++ b/blob.go
@@ -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)
+}
+