sql-migrate icon indicating copy to clipboard operation
sql-migrate copied to clipboard

cannot cross compile with sqlite support

Open caseylucas opened this issue 7 years ago • 1 comments

First, thanks for sql-migrate. It's a great tool. We have been using it so far with success inside docker containers, but because sqlite can't cross compile, we've had to write custom mains (using sql-migrate in library form without sqlite included). Is there possibly some strategy (besides just forking and commenting out sqlite) that could be used to allow cross compiles of the main sql-migrate program when we don't need sqlite support. I'm compiling from mac. See also https://github.com/mattn/go-sqlite3/issues/384

Example of failed compile:

GOOS=linux GOARCH=amd64 go build -o casey-test sql-migrate/*.go
# github.com/mattn/go-sqlite3
../../mattn/go-sqlite3/sqlite3_go18.go:18: undefined: SQLiteConn
../../mattn/go-sqlite3/sqlite3_go18.go:26: undefined: SQLiteConn
../../mattn/go-sqlite3/sqlite3_go18.go:27: undefined: namedValue
../../mattn/go-sqlite3/sqlite3_go18.go:29: undefined: namedValue
../../mattn/go-sqlite3/sqlite3_go18.go:35: undefined: SQLiteConn
../../mattn/go-sqlite3/sqlite3_go18.go:36: undefined: namedValue
../../mattn/go-sqlite3/sqlite3_go18.go:44: undefined: SQLiteConn
../../mattn/go-sqlite3/sqlite3_go18.go:49: undefined: SQLiteConn
../../mattn/go-sqlite3/sqlite3_go18.go:54: undefined: SQLiteStmt
../../mattn/go-sqlite3/sqlite3_go18.go:63: undefined: SQLiteStmt
../../mattn/go-sqlite3/sqlite3_go18.go:36: too many errors

We don't actually use sqlite and if you comment out this line below, the cross compile works.

diff --git a/sql-migrate/config.go b/sql-migrate/config.go
index 6790606..76af76d 100644
--- a/sql-migrate/config.go
+++ b/sql-migrate/config.go
@@ -14,7 +14,7 @@ import (

        _ "github.com/go-sql-driver/mysql"
        _ "github.com/lib/pq"
-       _ "github.com/mattn/go-sqlite3"
+//     _ "github.com/mattn/go-sqlite3"
 )

 var dialects = map[string]gorp.Dialect{

caseylucas avatar May 31 '17 17:05 caseylucas

compilation does work after commenting out the import but the application doesn't run and throws error.

"forgot to import package"

rishi8313 avatar Oct 04 '17 08:10 rishi8313