Looking out for max values in integer-based columns in MySQL_MySQL
程序员文章站
2022-05-22 18:39:32
...
db,err:=sql.Open("mysql",fmt.Sprintf("%s:%s@tcp(%s:3306)/%s",mysqlUn,mysqlPw,hostToCheck,dbToCheck))
iferr!=nil{
fmt.Printf("Error connecting to MySQL on '%s': n",hostToCheck,err)
db.Close()
os.Exit(1)
}
//Checkconnectionisalive.
err=db.Ping()
iferr!=nil{
fmt.Printf("Unable to ping mysql at '%s': %sn",hostToCheck,err)
db.Close()
os.Exit(1)
}