diff options
| author | Felix Hanley <felix@userspace.com.au> | 2017-06-18 05:53:42 +0000 |
|---|---|---|
| committer | Felix Hanley <felix@userspace.com.au> | 2017-06-18 05:53:42 +0000 |
| commit | 30fc93f11537789824eeb24bde212a57e43ecb01 (patch) | |
| tree | e83e685519c704adb97e34ea1bdef9ab6b8d484f /db.go | |
| parent | 3e3fa4064fcaf43cd87ddbfc457097bacb697fc5 (diff) | |
| download | dhtsearch-30fc93f11537789824eeb24bde212a57e43ecb01.tar.gz dhtsearch-30fc93f11537789824eeb24bde212a57e43ecb01.tar.bz2 | |
Add user configuration and more exported variables
Diffstat (limited to 'db.go')
| -rw-r--r-- | db.go | 26 |
1 files changed, 1 insertions, 25 deletions
@@ -8,7 +8,6 @@ import ( type database struct { *sqlx.DB - debug bool } func newDB(dsn string) (*database, error) { @@ -23,28 +22,5 @@ func newDB(dsn string) (*database, error) { return nil, err } torrentsTotal.Set(int64(count)) - return &database{d, false}, nil -} - -func createTag(tag string) (tagId int, err error) { - if DB.debug { - fmt.Printf("Writing tag %s\n", tag) - } - - err = DB.QueryRow("select id from tags where name = $1", tag).Scan(&tagId) - if err == nil { - if DB.debug { - fmt.Printf("Found existing tag %s\n", tag) - } - } else { - err = DB.QueryRow("insert into tags (name) values ($1) returning id", tag).Scan(&tagId) - if err != nil { - fmt.Println(err) - return -1, err - } - if DB.debug { - fmt.Printf("Created new tag %s\n", tag) - } - } - return tagId, nil + return &database{d}, nil } |
