本文整理汇总了Golang中github.com/akavel/rsrc/binutil.Writer类的典型用法代码示例。如果您正苦于以下问题:Golang Writer类的具体用法?Golang Writer怎么用?Golang Writer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Writer类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: writeCoff
// copied from github.com/akavel/rsrc
// LICENSE: MIT
// Copyright 2013-2014 The rsrc Authors. (https://github.com/akavel/rsrc/blob/master/AUTHORS)
func writeCoff(coff *coff.Coff, fnameout string) error {
out, err := os.Create(fnameout)
if err != nil {
return err
}
defer out.Close()
w := binutil.Writer{W: out}
// write the resulting file to disk
binutil.Walk(coff, func(v reflect.Value, path string) error {
if binutil.Plain(v.Kind()) {
w.WriteLE(v.Interface())
return nil
}
vv, ok := v.Interface().(binutil.SizedReader)
if ok {
w.WriteFromSized(vv)
return binutil.WALK_SKIP
}
return nil
})
if w.Err != nil {
return fmt.Errorf("Error writing output file: %s", w.Err)
}
return nil
}
示例2: Walk
// Walk writes the data buffer with hexidecimal data from the structs
func (vi *VersionInfo) Walk() {
// Create a buffer
var b bytes.Buffer
w := binutil.Writer{W: &b}
// Write to the buffer
binutil.Walk(vi.Structure, func(v reflect.Value, path string) error {
if binutil.Plain(v.Kind()) {
w.WriteLE(v.Interface())
}
return nil
})
vi.Buffer = b
}
示例3: writeCoffTo
func writeCoffTo(w io.WriteCloser, coff *coff.Coff) error {
bw := binutil.Writer{W: w}
// write the resulting file to disk
binutil.Walk(coff, func(v reflect.Value, path string) error {
if binutil.Plain(v.Kind()) {
bw.WriteLE(v.Interface())
return nil
}
vv, ok := v.Interface().(binutil.SizedReader)
if ok {
bw.WriteFromSized(vv)
return binutil.WALK_SKIP
}
return nil
})
err := bw.Err
if closeErr := w.Close(); closeErr != nil && err == nil {
err = closeErr
}
return err
}