예제 #1
0
파일: mysql_test.go 프로젝트: xyliuke/plan9
func Test_Mysql(t *testing.T) {
	db, err := sql.Open("mysql", "root:123456@/plan9")
	defer db.Close()
	if err == nil {
		log.I_COM("connect to db success")

		result, result_err := db.Exec("insert into user(id, mobile, name) values(11,'11', '11')")
		if result_err == nil {
			log.I_COM(result.RowsAffected())
		}

		rows, row_err := db.Query("select * from user")
		defer rows.Close()

		if row_err == nil {
			for rows.Next() {
				var id int
				var mobile1 string
				var name string
				rows.Scan(&id, &mobile1, &name)
				log.I_COM(id, mobile1, name)
			}
		}
	}
}
예제 #2
0
파일: main.go 프로젝트: xyliuke/plan9
func main() {

	log.I_COM(os.Args)
	if len(os.Args) <= 1 {
		log.E_COM("command error, can not find config file")
	} else {
		id, jsonObject := getIdentity(os.Args[1])
		log.I_COM("identity is", id)
		if "connection_server" == id {
			log.I_COM("run connection server")
			go func() {
				result, cs := connection.ParseConnectionServerConfig(jsonObject)
				if result {
					connection.NewConnectionServer(cs).Run()
				} else {
					log.E_COM("read connection config error")
				}
			}()
		} else if "route_server" == id {
			log.I_COM("run route server")
			go func() {
				rs := route.PaserRouteServerConfig(jsonObject)
				route.NewRouteServer(rs).Run()
			}()
		}
	}

	ch := make(chan int)
	<-ch
}