广告联盟

2019-05-05  本文已影响0人  小小爱笑

http://www.google.cn

http://union.baidu.com/customerLogin.html?fromu=http%3A%2F%2Funion.baidu.com%2F

package main

import (
    "flag"
    "fmt"
    "github.com/ligenhw/goshare/store"
    "log"
    "os"
)

var (
    drop bool
    file string
)

func init() {
    flag.BoolVar(&drop, "drop", false, "drop goshare db")
    flag.StringVar(&file, "file", "../../script/schema.sql", "db schema sql file")

    log.SetFlags(0)
    log.SetPrefix(os.Args[0] + ": ")
}

func usage() {
    fmt.Fprintf(os.Stderr, "usage: %s [OPTION]... [FILE]\n", os.Args[0])
    fmt.Fprint(os.Stderr, `
Init the goshare db schema.
eg: init --drop
`)
    flag.PrintDefaults()
}

func main() {
    flag.Usage = usage
    flag.Parse()

    fmt.Println(drop, file)

    r, err := store.Db.Query("show DATABASES")
    if err != nil {
        fmt.Println(r.Next())
        fmt.Println(r.Columns())
    }
}
上一篇下一篇

猜你喜欢

热点阅读