*sql.DB func setupDB(driver, dsn string) error { var err error DB, err = sql.Open(driver, dsn) return err } func UserHandler(w http.ResponseWriter, r *http.Request) { var name string DB.QueryRow("SELECT name FROM user WHERE id = ?", 1).Scan(&name) fmt.Fprintf(w, "hello, %s\n", name) }