2018-03-31 05:25:27 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"bufio"
|
2018-04-22 12:33:56 +00:00
|
|
|
"database/sql"
|
2018-03-31 05:25:27 +00:00
|
|
|
"fmt"
|
|
|
|
"os"
|
|
|
|
"runtime/debug"
|
|
|
|
|
|
|
|
"../query_gen/lib"
|
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
scanner := bufio.NewScanner(os.Stdin)
|
|
|
|
|
|
|
|
// Capture panics instead of closing the window at a superhuman speed before the user can read the message on Windows
|
|
|
|
defer func() {
|
|
|
|
r := recover()
|
|
|
|
if r != nil {
|
|
|
|
fmt.Println(r)
|
|
|
|
debug.PrintStack()
|
|
|
|
pressAnyKey(scanner)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}()
|
|
|
|
|
|
|
|
err := patcher(scanner)
|
|
|
|
if err != nil {
|
|
|
|
fmt.Println(err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func pressAnyKey(scanner *bufio.Scanner) {
|
|
|
|
fmt.Println("Please press enter to exit...")
|
|
|
|
for scanner.Scan() {
|
|
|
|
_ = scanner.Text()
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func patcher(scanner *bufio.Scanner) error {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
/*func eachUserQuick(handle func(int)) error {
|
|
|
|
stmt, err := qgen.Builder.Select("users").Orderby("uid desc").Limit(1).Prepare()
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
var topID int
|
|
|
|
err := stmt.QueryRow(topID)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
for i := 1; i <= topID; i++ {
|
|
|
|
err = handle(i)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}*/
|
|
|
|
|
2018-04-07 05:27:25 +00:00
|
|
|
func eachUser(handle func(int) error) error {
|
|
|
|
acc := qgen.Builder.Accumulator()
|
2018-04-22 12:33:56 +00:00
|
|
|
err := acc.Select("users").Each(func(rows *sql.Rows) error {
|
2018-03-31 05:25:27 +00:00
|
|
|
var uid int
|
|
|
|
err := rows.Scan(&uid)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2018-04-22 12:33:56 +00:00
|
|
|
return handle(uid)
|
|
|
|
})
|
|
|
|
return err
|
2018-03-31 05:25:27 +00:00
|
|
|
}
|