consistent order of variables and row scans
Ted Unangst tedu@tedunangst.com
Wed, 13 Nov 2019 11:00:25 -0500
3 files changed,
11 insertions(+),
11 deletions(-)
M
activity.go
→
activity.go
@@ -206,8 +206,8 @@ return donk
} func iszonked(userid int64, xid string) bool { - row := stmtFindZonk.QueryRow(userid, xid) var id int64 + row := stmtFindZonk.QueryRow(userid, xid) err := row.Scan(&id) if err == nil { return true@@ -235,8 +235,8 @@ if iszonked(user.ID, xid) {
log.Printf("already zonked: %s", xid) return false } - row := stmtFindXonk.QueryRow(user.ID, xid) var id int64 + row := stmtFindXonk.QueryRow(user.ID, xid) err := row.Scan(&id) if err == nil { return false@@ -1294,8 +1294,8 @@ if len(m) != 2 {
log.Printf("bad fish name: %s", name) return "", true } - row := stmtGetXonker.QueryRow(name, "fishname") var href string + row := stmtGetXonker.QueryRow(name, "fishname") err := row.Scan(&href) if err == nil { return href, true@@ -1399,8 +1399,8 @@ if ok {
obj = keyobj } keyname, ok := obj.GetString("id") - row := stmtGetXonker.QueryRow(keyname, "pubkey") var data string + row := stmtGetXonker.QueryRow(keyname, "pubkey") err := row.Scan(&data) if err == nil { return
M
fun.go
→
fun.go
@@ -494,8 +494,8 @@ return ""
} var allhandles = cache.New(cache.Options{Filler: func(xid string) (string, bool) { - row := stmtGetXonker.QueryRow(xid, "handle") var handle string + row := stmtGetXonker.QueryRow(xid, "handle") err := row.Scan(&handle) if err != nil { log.Printf("need to get a handle: %s", xid)@@ -581,8 +581,8 @@ return ki
} var zaggies = cache.New(cache.Options{Filler: func(keyname string) (*rsa.PublicKey, bool) { - row := stmtGetXonker.QueryRow(keyname, "pubkey") var data string + row := stmtGetXonker.QueryRow(keyname, "pubkey") err := row.Scan(&data) if err != nil { log.Printf("hitting the webs for missing pubkey: %s", keyname)
M
web.go
→
web.go
@@ -351,9 +351,9 @@ return
} log.Printf("updating honker follow: %s", who) + var x string db := opendatabase() row := db.QueryRow("select xid from honkers where xid = ? and userid = ? and flavor in ('dub', 'undub')", who, user.ID) - var x string err = row.Scan(&x) if err != sql.ErrNoRows { log.Printf("duplicate follow request: %s", who)@@ -367,10 +367,10 @@ }
go rubadubdub(user, j) case "Accept": log.Printf("updating honker accept: %s", who) + var name string db := opendatabase() row := db.QueryRow("select name from honkers where userid = ? and xid = ? and flavor in ('presub')", user.ID, who) - var name string err := row.Scan(&name) if err != nil { log.Printf("can't get honker name: %s", err)@@ -486,9 +486,9 @@ return
} ont := "#" + m[1] log.Printf("%s wants to follow %s", who, ont) + var x string db := opendatabase() row := db.QueryRow("select xid from honkers where name = ? and xid = ? and userid = ? and flavor in ('dub', 'undub')", ont, who, user.ID) - var x string err = row.Scan(&x) if err != sql.ErrNoRows { log.Printf("duplicate follow request: %s", who)@@ -1731,9 +1731,9 @@ return
} url = info.XID + var x string db := opendatabase() row := db.QueryRow("select xid from honkers where xid = ? and userid = ? and flavor in ('sub', 'unsub', 'peep')", url, u.UserID) - var x string err = row.Scan(&x) if err != sql.ErrNoRows { http.Error(w, "it seems you are already subscribed to them", http.StatusInternalServerError)@@ -1947,9 +1947,9 @@ }
func servefile(w http.ResponseWriter, r *http.Request) { xid := mux.Vars(r)["xid"] - row := stmtGetFileData.QueryRow(xid) var media string var data []byte + row := stmtGetFileData.QueryRow(xid) err := row.Scan(&media, &data) if err != nil { log.Printf("error loading file: %s", err)