func GetUserByID(id int) (*User, error) {
	user := User{}
	err := DB.QueryRow("select id, name from users where id=?", id).Scan(&user.ID, &user.Name)
	if err != nil {
		return &user, err
	}
	log.Printf("use db: %+v", DB)
	return &user, nil
}
GetUserByID returns a user
package user
import (
	"database/sql"
	"log"
	_ "github.com/go-sql-driver/mysql"  
)
type User struct {
	ID   int
	Name string
}
var DB *sql.DB
func init() {
	dsn := "root:@/testsql"
	db, err := sql.Open("mysql", dsn)
	if err != nil {
		panic(err)
	}
	DB = db
	log.Printf("init db: %+v", DB)
}