From b282761292e7c51e4ac8e8daac16ec54f7ea5619 Mon Sep 17 00:00:00 2001 From: OTER Date: Thu, 15 Sep 2016 22:40:03 +0300 Subject: [PATCH] Fix .exe postfix issue on Windows platform. --- migrate.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/migrate.go b/migrate.go index a32cc8e..22bfac3 100644 --- a/migrate.go +++ b/migrate.go @@ -23,6 +23,7 @@ import ( "strconv" "strings" "time" + "runtime" ) var cmdMigrate = &Command{ @@ -145,8 +146,12 @@ func migrateRefresh(currpath, driver, connStr string) { // migrate generates source code, build it, and invoke the binary who does the actual migration func migrate(goal, currpath, driver, connStr string) { - dir := path.Join(currpath, "database", "migrations") - binary := "m" + dir := path.Join(currpath, "database", "migrations") + postfix := "" + if runtime.GOOS == "windows" { + postfix = ".exe" + } + binary := "m" + postfix source := binary + ".go" // connect to database db, err := sql.Open(driver, connStr)