Last active
January 8, 2016 08:30
-
-
Save ledongthuc/f452eb0d6dfe97d0b4de to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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