本文整理汇总了Golang中github.com/amkimian/pmfs/fs.RootFileSystem.GetBlock方法的典型用法代码示例。如果您正苦于以下问题:Golang RootFileSystem.GetBlock方法的具体用法?Golang RootFileSystem.GetBlock怎么用?Golang RootFileSystem.GetBlock使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/amkimian/pmfs/fs.RootFileSystem
的用法示例。
在下文中一共展示了RootFileSystem.GetBlock方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: blockGetFunc
// The block get Func retrieves a block given a range
// Parameters are
// start (optional) the start block (inclusive)
// end (optional) the end block (inclusive)
// tag (optional) the tag of the version to do this for
// Basically the function retrieves the route given the tag version (or default root)
// and then filters the block names given the start and end.
// The return data is a list structure containing the key (block name) and the value (the value of the block)
func blockGetFunc(w http.ResponseWriter, r *http.Request, filesys *fs.RootFileSystem) {
fileNode, dirNode, err := filesys.GetFileOrDirectory(r.URL.Path, false)
if err != nil {
writeError(w, err)
} else if dirNode != nil {
writeError(w, errors.New("Cannot do this to a directory"))
} else {
// We have a filenode...
blockStructure, err := filesys.GetBlock(fileNode, getFormValue(r, "tag", ""), getFormValue(r, "start", ""), getFormValue(r, "end", ""))
if err != nil {
writeError(w, err)
} else {
var b []byte
b, err = json.MarshalIndent(blockStructure, "", " ")
fmt.Fprintf(w, "%v", string(b))
}
}
}