Skip to content

Instantly share code, notes, and snippets.

@ledongthuc
Last active January 8, 2016 08:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ledongthuc/f452eb0d6dfe97d0b4de to your computer and use it in GitHub Desktop.
Save ledongthuc/f452eb0d6dfe97d0b4de to your computer and use it in GitHub Desktop.
package main
import (
"fmt"
"io"
"net/http"
_ "github.com/mattes/migrate/driver/postgres"
"github.com/mattes/migrate/migrate"
)
func main() {
driver := fmt.Sprintf("postgres://%s:%s@%s:%s/%s?sslmode=%s",
"culture_match_go_user", // Urname
"labsquadssf", // Password
"127.0.0.1", // Host
"5432", // Port
"testdatabase", // Database's name
"disable") // Support ssl
sqlPath := "./sql"
fmt.Println("Driver: ", driver)
version, err := migrate.Version(driver, sqlPath)
if err != nil {
fmt.Println(err.Error())
return
}
fmt.Println(version)
fmt.Println("Start server on http://localhost:9999")
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
io.WriteString(w, "Hello world!")
})
http.ListenAndServe(":9999", nil)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment