本文整理匯總了Golang中github.com/driusan/bug/bugs.Bug.LoadBug方法的典型用法代碼示例。如果您正苦於以下問題:Golang Bug.LoadBug方法的具體用法?Golang Bug.LoadBug怎麽用?Golang Bug.LoadBug使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/driusan/bug/bugs.Bug
的用法示例。
在下文中一共展示了Bug.LoadBug方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: Get
func (m BugPageHandler) Get(r *http.Request, extras map[string]interface{}) (string, error) {
if r.URL.Path == "/issues" || r.URL.Path == "/issues/" {
return getBugList()
}
bugDir := string(bugs.GetRootDir()) + r.URL.Path
b := bugs.Bug{}
b.LoadBug(bugs.Directory(bugDir))
switch r.URL.Query().Get("format") {
case "json":
bJSON, _ := json.Marshal(b)
return string(bJSON), nil
default:
page := BugRenderer{Bug: b}
page.RootElement = "RBugPage"
page.Title = b.Title("")
page.JSFiles = []string{
// Bootstrap JS
//"https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js",
// React JS
"https://cdnjs.cloudflare.com/ajax/libs/react/0.14.3/react.js",
"https://cdnjs.cloudflare.com/ajax/libs/react/0.14.3/react-dom.js",
"/js/BugPage.js",
}
page.CSSFiles = []string{
"https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css",
"https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap-theme.min.css"}
return HTMLPageRenderer.Render(page), nil
}
}
示例2: 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")
}
示例3: Roadmap
func (a BugApplication) Roadmap() {
issues, _ := ioutil.ReadDir(string(bugs.GetRootDir()) + "/issues")
var bgs [](bugs.Bug)
for idx, _ := range issues {
b := bugs.Bug{}
b.LoadBug(bugs.Directory(bugs.GetRootDir() + "/issues/" + bugs.Directory(issues[idx].Name())))
bgs = append(bgs, b)
}
sort.Sort(BugListByMilestone(bgs))
fmt.Printf("# Roadmap for %s\n", bugs.GetRootDir().GetShortName().ToTitle())
milestone := ""
for i := len(bgs) - 1; i >= 0; i -= 1 {
b := bgs[i]
newMilestone := b.Milestone()
if milestone != newMilestone {
if newMilestone == "" {
fmt.Printf("\n## No milestone set:\n")
} else {
fmt.Printf("\n## %s:\n", newMilestone)
}
}
fmt.Printf("- %s\n", b.Title)
milestone = newMilestone
}
}
示例4: listTags
func listTags(files []os.FileInfo, args ArgumentList) {
b := bugs.Bug{}
for idx, _ := range files {
b.LoadBug(bugs.Directory(bugs.GetIssuesDir() + bugs.Directory(files[idx].Name())))
for _, tag := range args {
if b.HasTag(bugs.Tag(tag)) {
fmt.Printf("%s: %s\n", getBugName(b, idx), b.Title("tags"))
}
}
}
}
示例5: 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")
}
示例6: listTags
func listTags(files []os.FileInfo, args []string) {
hasTag := func(tags []string, tag string) bool {
for _, candidate := range tags {
if candidate == tag {
return true
}
}
return false
}
b := bugs.Bug{}
for idx, _ := range files {
b.LoadBug(bugs.Directory(bugs.GetRootDir() + "/issues/" + bugs.Directory(files[idx].Name())))
tags := b.StringTags()
for _, tag := range args {
if hasTag(tags, tag) {
fmt.Printf("Issue %d: %s (%s)\n", idx+1, b.Title, strings.Join(tags, ", "))
}
}
}
}