mirror of
https://github.com/gopl-zh/gopl-zh.github.com.git
synced 2025-09-13 23:21:38 +00:00
good good study, day day up!
This commit is contained in:
52
vendor/gopl.io/ch4/issueshtml/main.go
generated
vendored
Normal file
52
vendor/gopl.io/ch4/issueshtml/main.go
generated
vendored
Normal file
@@ -0,0 +1,52 @@
|
||||
// Copyright © 2016 Alan A. A. Donovan & Brian W. Kernighan.
|
||||
// License: https://creativecommons.org/licenses/by-nc-sa/4.0/
|
||||
|
||||
// See page 115.
|
||||
|
||||
// Issueshtml prints an HTML table of issues matching the search terms.
|
||||
package main
|
||||
|
||||
import (
|
||||
"log"
|
||||
"os"
|
||||
|
||||
"gopl.io/ch4/github"
|
||||
)
|
||||
|
||||
//!+template
|
||||
import "html/template"
|
||||
|
||||
var issueList = template.Must(template.New("issuelist").Parse(`
|
||||
<h1>{{.TotalCount}} issues</h1>
|
||||
<table>
|
||||
<tr style='text-align: left'>
|
||||
<th>#</th>
|
||||
<th>State</th>
|
||||
<th>User</th>
|
||||
<th>Title</th>
|
||||
</tr>
|
||||
{{range .Items}}
|
||||
<tr>
|
||||
<td><a href='{{.HTMLURL}}'>{{.Number}}</td>
|
||||
<td>{{.State}}</td>
|
||||
<td><a href='{{.User.HTMLURL}}'>{{.User.Login}}</a></td>
|
||||
<td><a href='{{.HTMLURL}}'>{{.Title}}</a></td>
|
||||
</tr>
|
||||
{{end}}
|
||||
</table>
|
||||
`))
|
||||
|
||||
//!-template
|
||||
|
||||
//!+
|
||||
func main() {
|
||||
result, err := github.SearchIssues(os.Args[1:])
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
if err := issueList.Execute(os.Stdout, result); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
//!-
|
Reference in New Issue
Block a user