MCPcopy Create free account
hub / github.com/libgit2/git2go / Write

Method Write

blob.go:116–131  ·  view source on GitHub ↗

Implement io.Writer

(p []byte)

Source from the content-addressed store, hash-verified

114
115// Implement io.Writer
116func (stream *BlobWriteStream) Write(p []byte) (int, error) {
117 header := (*reflect.SliceHeader)(unsafe.Pointer(&p))
118 ptr := (*C.char)(unsafe.Pointer(header.Data))
119 size := C.size_t(header.Len)
120
121 runtime.LockOSThread()
122 defer runtime.UnlockOSThread()
123
124 ecode := C._go_git_writestream_write(stream.ptr, ptr, size)
125 runtime.KeepAlive(stream)
126 if ecode < 0 {
127 return 0, MakeGitError(ecode)
128 }
129
130 return len(p), nil
131}
132
133func (stream *BlobWriteStream) Free() {
134 runtime.SetFinalizer(stream, nil)

Callers

nothing calls this directly

Calls 1

MakeGitErrorFunction · 0.85

Tested by

no test coverage detected