本文整理匯總了Golang中github.com/omeid/slurp.C.Infof方法的典型用法代碼示例。如果您正苦於以下問題:Golang C.Infof方法的具體用法?Golang C.Infof怎麽用?Golang C.Infof使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/omeid/slurp.C
的用法示例。
在下文中一共展示了C.Infof方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: Concat
// Concatenates all the files from the input channel
// and passes them to output channel with the given name.
func Concat(c *slurp.C, name string) slurp.Stage {
return func(files <-chan slurp.File, out chan<- slurp.File) {
var (
size int64
bigfile = new(bytes.Buffer)
)
for f := range files {
c.Infof("Adding %s to %s", f.Path, name)
n, err := bigfile.ReadFrom(f)
if err != nil {
c.Error(err)
return
}
bigfile.WriteRune('\n')
size += n + 1
f.Close()
}
fi := slurp.FileInfo{}
fi.SetSize(size)
fi.SetName(name)
out <- slurp.File{
Reader: bigfile,
Dir: "",
Path: name,
FileInfo: fi,
}
}
}
示例2: Build
// A build stage creates a new build and adds all the files coming through the channel to
// the Build and returns the result of Build as a File on the output channel.
func Build(c *slurp.C, config Config) slurp.Stage {
return func(in <-chan slurp.File, out chan<- slurp.File) {
b := cache{config, make(map[string]*bytes.Buffer)}
for file := range in {
path, _ := filepath.Rel(file.Dir, file.Path)
path = filepath.ToSlash(path)
c.Infof("Adding %s", path)
buff := new(bytes.Buffer)
_, err := buff.ReadFrom(file)
if err != nil {
c.Error(err)
}
b.Files[path] = buff
file.Close() //Close files AFTER we have build our package.
}
buff := new(bytes.Buffer)
err := cacheTemplate.Execute(buff, b)
if err != nil {
c.Error(err)
return
}
sf := slurp.File{
Reader: buff,
Path: b.Name,
}
sf.FileInfo.SetName(b.Name)
sf.FileInfo.SetSize(int64(buff.Len()))
out <- sf
}
}
示例3: List
//For The Glory of Debugging.
func List(c *slurp.C) slurp.Stage {
return func(files <-chan slurp.File, out chan<- slurp.File) {
for f := range files {
s, err := f.Stat()
if err != nil {
c.Error("Can't get File Stat name.")
} else {
c.Infof("slurp.File: %+v Name: %s", f, s.Name())
}
out <- f
}
}
}