本文整理匯總了Golang中github.com/driusan/bug/bugs.Bug.ViewBug方法的典型用法代碼示例。如果您正苦於以下問題:Golang Bug.ViewBug方法的具體用法?Golang Bug.ViewBug怎麽用?Golang Bug.ViewBug使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/driusan/bug/bugs.Bug
的用法示例。
在下文中一共展示了Bug.ViewBug方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: List
func (a BugApplication) List(args []string) {
issues, _ := ioutil.ReadDir(string(bugs.GetRootDir()) + "/issues")
// No parameters, print a list of all bugs
if len(args) == 0 {
for idx, issue := range issues {
var dir bugs.Directory = bugs.Directory(issue.Name())
fmt.Printf("Issue %d: %s\n", idx+1, dir.ToTitle())
}
return
}
// There were parameters, so show the full description of each
// of those issues
b := bugs.Bug{}
for i, length := 0, len(args); i < length; i += 1 {
idx, err := strconv.Atoi(args[i])
if err != nil {
listTags(issues, args)
return
}
if idx > len(issues) || idx < 1 {
fmt.Printf("Invalid issue number %d\n", idx)
continue
}
if err == nil {
b.LoadBug(bugs.Directory(bugs.GetRootDir() + "/issues/" + bugs.Directory(issues[idx-1].Name())))
b.ViewBug()
if i < length-1 {
fmt.Printf("\n--\n\n")
}
}
}
fmt.Printf("\n")
}
示例2: List
func (a BugApplication) List(args ArgumentList) {
issues, _ := ioutil.ReadDir(string(bugs.GetIssuesDir()))
var wantTags bool = false
if args.HasArgument("--tags") {
wantTags = true
}
// No parameters, print a list of all bugs
if len(args) == 0 || (wantTags && len(args) == 1) {
for idx, issue := range issues {
if issue.IsDir() != true {
continue
}
var dir bugs.Directory = bugs.GetIssuesDir() + bugs.Directory(issue.Name())
b := bugs.Bug{dir}
if wantTags == false {
fmt.Printf("Issue %d: %s\n", idx+1, b.Title(""))
} else {
fmt.Printf("Issue %d: %s\n", idx+1, b.Title("tags"))
}
}
return
}
// There were parameters, so show the full description of each
// of those issues
b := bugs.Bug{}
for i, length := 0, len(args); i < length; i += 1 {
idx, err := strconv.Atoi(args[i])
if err != nil {
listTags(issues, args)
return
}
if idx > len(issues) || idx < 1 {
fmt.Printf("Invalid issue number %d\n", idx)
continue
}
if err == nil {
b.LoadBug(bugs.Directory(bugs.GetIssuesDir() + bugs.Directory(issues[idx-1].Name())))
b.ViewBug()
if i < length-1 {
fmt.Printf("\n--\n\n")
}
}
}
fmt.Printf("\n")
}