csv
Yasuhiro Matsumoto 2017-03-05 20:52:55 +09:00
parent a9d61d54c6
commit f9e79c0a39
2 changed files with 9 additions and 9 deletions

View File

@ -31,8 +31,8 @@ func main() {
} }
defer rows.Close() defer rows.Close()
for rows.Next() { for rows.Next() {
var id, full_name, description, html_url string var id, fullName, description, htmlURL string
rows.Scan(&id, &full_name, &description, &html_url) rows.Scan(&id, &fullName, &description, &htmlURL)
fmt.Printf("%s: %s\n\t%s\n\t%s\n\n", id, full_name, description, html_url) fmt.Printf("%s: %s\n\t%s\n\t%s\n\n", id, fullName, description, htmlURL)
} }
} }

View File

@ -9,11 +9,11 @@ import (
"github.com/mattn/go-sqlite3" "github.com/mattn/go-sqlite3"
) )
type GithubRepo struct { type githubRepo struct {
ID int `json:"id"` ID int `json:"id"`
FullName string `json:"full_name"` FullName string `json:"full_name"`
Description string `json:"description"` Description string `json:"description"`
HtmlURL string `json:"html_url"` HTMLURL string `json:"html_url"`
} }
type githubModule struct { type githubModule struct {
@ -40,7 +40,7 @@ func (m *githubModule) Connect(c *sqlite3.SQLiteConn, args []string) (sqlite3.VT
func (m *githubModule) DestroyModule() {} func (m *githubModule) DestroyModule() {}
type ghRepoTable struct { type ghRepoTable struct {
repos []GithubRepo repos []githubRepo
} }
func (v *ghRepoTable) Open() (sqlite3.VTabCursor, error) { func (v *ghRepoTable) Open() (sqlite3.VTabCursor, error) {
@ -55,7 +55,7 @@ func (v *ghRepoTable) Open() (sqlite3.VTabCursor, error) {
return nil, err return nil, err
} }
repos := make([]GithubRepo, 0) var repos []githubRepo
if err := json.Unmarshal(body, &repos); err != nil { if err := json.Unmarshal(body, &repos); err != nil {
return nil, err return nil, err
} }
@ -71,7 +71,7 @@ func (v *ghRepoTable) Destroy() error { return nil }
type ghRepoCursor struct { type ghRepoCursor struct {
index int index int
repos []GithubRepo repos []githubRepo
} }
func (vc *ghRepoCursor) Column(c *sqlite3.SQLiteContext, col int) error { func (vc *ghRepoCursor) Column(c *sqlite3.SQLiteContext, col int) error {
@ -83,7 +83,7 @@ func (vc *ghRepoCursor) Column(c *sqlite3.SQLiteContext, col int) error {
case 2: case 2:
c.ResultText(vc.repos[vc.index].Description) c.ResultText(vc.repos[vc.index].Description)
case 3: case 3:
c.ResultText(vc.repos[vc.index].HtmlURL) c.ResultText(vc.repos[vc.index].HTMLURL)
} }
return nil return nil
} }