本文整理汇总了Golang中gopkg/in/src-d/go-git/v4/plumbing.Object.Writer方法的典型用法代码示例。如果您正苦于以下问题:Golang Object.Writer方法的具体用法?Golang Object.Writer怎么用?Golang Object.Writer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gopkg/in/src-d/go-git/v4/plumbing.Object
的用法示例。
在下文中一共展示了Object.Writer方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: ApplyDelta
// ApplyDelta writes to taget the result of applying the modification deltas in delta to base.
func ApplyDelta(target, base plumbing.Object, delta []byte) error {
r, err := base.Reader()
if err != nil {
return err
}
w, err := target.Writer()
if err != nil {
return err
}
src, err := ioutil.ReadAll(r)
if err != nil {
return err
}
dst := PatchDelta(src, delta)
target.SetSize(int64(len(dst)))
if _, err := w.Write(dst); err != nil {
return err
}
return nil
}
示例2: Encode
// Encode transforms a Tag into a plumbing.Object.
func (t *Tag) Encode(o plumbing.Object) error {
o.SetType(plumbing.TagObject)
w, err := o.Writer()
if err != nil {
return err
}
defer checkClose(w, &err)
if _, err = fmt.Fprintf(w,
"object %s\ntype %s\ntag %s\ntagger ",
t.Target.String(), t.TargetType.Bytes(), t.Name); err != nil {
return err
}
if err = t.Tagger.Encode(w); err != nil {
return err
}
if _, err = fmt.Fprint(w, "\n\n"); err != nil {
return err
}
if _, err = fmt.Fprint(w, t.Message); err != nil {
return err
}
return err
}
示例3: fillRegularObjectContent
func (d *Decoder) fillRegularObjectContent(obj plumbing.Object) (uint32, error) {
w, err := obj.Writer()
if err != nil {
return 0, err
}
_, crc, err := d.s.NextObject(w)
return crc, err
}
示例4: Encode
// Encode transforms a Blob into a plumbing.Object.
func (b *Blob) Encode(o plumbing.Object) error {
w, err := o.Writer()
if err != nil {
return err
}
defer checkClose(w, &err)
r, err := b.Reader()
if err != nil {
return err
}
defer checkClose(r, &err)
_, err = io.Copy(w, r)
o.SetType(plumbing.BlobObject)
return err
}