Closed GoogleCodeExporter closed 9 years ago
Note that I have the same error message on Windows 7 64 bit
go version go1.1.2 windows/amd64
Original comment by bigras.b...@gmail.com
on 22 Aug 2013 at 8:14
Are you sure you didn't change any source files? Please, provide output of "hg
st" and "hg id". Thank you.
Alex
Original comment by alex.bra...@gmail.com
on 23 Aug 2013 at 2:24
I just tested on a second Linux server.
Note that I had to set a GOPATH and do `go get` because `go test` wasn't able
to find odbc/api.
$ go test
column.go:8:2: cannot find package "code.google.com/p/odbc/api" in any of:
/usr/local/go/src/pkg/code.google.com/p/odbc/api (from $GOROOT)
($GOPATH not set)
$ go test
warning: building out-of-date packages:
code.google.com/p/odbc/api
code.google.com/p/odbc
installing these packages with 'go test -i' will speed future tests.
panic: sql: Register called twice for driver odbc
goroutine 1 [running]:
database/sql.Register(0x81481d8, 0x4, 0x1834f680, 0x8205060)
/usr/local/go/src/pkg/database/sql/sql.go:31 +0xe1
_/home/bbigras/t/odbc.init·1()
/home/bbigras/t/odbc/driver.go:74 +0x72
_/home/bbigras/t/odbc.init()
/home/bbigras/t/odbc/mssql_test.go:864 +0x1610
main.init()
_/home/bbigras/t/odbc/_test/_testmain.go:34 +0x3e
goroutine 2 [syscall]:
goroutine 3 [runnable]:
exit status 2
FAIL _/home/bbigras/t/odbc 0.054s
$ hg st
$ hg id
e76d703f5f45 tip
Original comment by bigras.b...@gmail.com
on 23 Aug 2013 at 2:40
I think you didn't setup your environment properly. What is the full path to
odbc directory? Also tell me what is GOPATH set to. Thank you.
Alex
Original comment by alex.bra...@gmail.com
on 26 Aug 2013 at 2:14
I tested on another computer running XP with go version go1.1.2 windows/386.
Here's what I did:
C:\>d:
D:\>mkdir odbc
D:\>cd odbc
D:\odbc>hg clone https://code.google.com/p/odbc/
destination directory: odbc
requesting all changes
adding changesets
adding manifests
adding file changes
added 19 changesets with 62 changes to 31 files
updating to branch default
31 files updated, 0 files merged, 0 files removed, 0 files unresolved
D:\odbc>mkdir GOPATH
D:\odbc>set GOPATH=d:\odbc\GOPATH
D:\odbc>cd GOPATH
D:\odbc\GOPATH>cd ..
D:\odbc>cd odbc
D:\odbc\odbc>go test
column.go:8:2: cannot find package "code.google.com/p/odbc/api" in any of:
C:\Go\src\pkg\code.google.com\p\odbc\api (from $GOROOT)
d:\odbc\GOPATH\src\code.google.com\p\odbc\api (from $GOPATH)
D:\odbc\odbc>go get
go install: no install location for directory D:\odbc\odbc outside GOPATH
D:\odbc\odbc>go test
warning: building out-of-date packages:
code.google.com/p/odbc/api
code.google.com/p/odbc
installing these packages with 'go test -i' will speed future tests.
panic: sql: Register called twice for driver odbc
goroutine 1 [running]:
database/sql.Register(0x505c38, 0x4, 0x10f11ec0, 0x5c7c20)
C:/Users/ADMINI~1/AppData/Local/Temp/2/bindist465310315/go/src/pkg/database/sql/sql.go:31 +0xe3
_/D_/odbc/odbc.init┬À1()
D:/odbc/odbc/driver.go:74 +0x74
_/D_/odbc/odbc.init()
D:/odbc/odbc/mssql_test.go:864 +0x1612
main.init()
C:/DOCUME~1/bbigras/LOCALS~1/Temp/go-build059931739/_/D_/odbc/odbc/_test
/_testmain.go:34 +0x40
exit status 2
FAIL _/D_/odbc/odbc 0.438s
Original comment by bigras.b...@gmail.com
on 26 Aug 2013 at 2:46
> Here's what I did:
>
> C:\>d:
>
> D:\>mkdir odbc
>
> D:\>cd odbc
>
> D:\odbc>hg clone https://code.google.com/p/odbc/
> destination directory: odbc
> requesting all changes
> adding changesets
> adding manifests
> adding file changes
> added 19 changesets with 62 changes to 31 files
> updating to branch default
> 31 files updated, 0 files merged, 0 files removed, 0 files unresolved
Now you have odbc package installed in d:\odbc\odbc directory.
> D:\odbc>mkdir GOPATH
>
> D:\odbc>set GOPATH=d:\odbc\GOPATH
Now you have GOPATH environment set to d:\odbc\GOPATH directory.
> D:\odbc>cd GOPATH
>
> D:\odbc\GOPATH>cd ..
>
> D:\odbc>cd odbc
>
> D:\odbc\odbc>go test
> column.go:8:2: cannot find package "code.google.com/p/odbc/api" in any of:
> C:\Go\src\pkg\code.google.com\p\odbc\api (from $GOROOT)
> d:\odbc\GOPATH\src\code.google.com\p\odbc\api (from $GOPATH)
This fails because Go is trying to build package in your CURRENT directory
(d:\odbc\odbc). The package imports (amongst many other things)
"code.google.com/p/odbc/api" package (see for example column.go file). It looks
for that package in 2 locations: GOROOT - it is not there, GOPATH (you set it
to d:\odbc\GOPATH) - it is completely empty. So Go stops and complains.
> D:\odbc\odbc>go get
> go install: no install location for directory D:\odbc\odbc outside GOPATH
This downloads (and installs) ALL MISSING packages used by package in your
CURRENT directory (d:\odbc\odbc). It downloads "code.google.com/p/odbc/api"
package into your GOPATH (into d:\odbc\GOPATH\src\code.google.com\p\odbc\api
directory). code.google.com/p/odbc gets downloaded as well, becuase it is part
of the same repository.
So now you have 2 same odbc packages, but in 2 different locations - one inside
GOPATH in d:\odbc\GOPATH\src\code.google.com\p\odbc and the other is in your
current directory.
> D:\odbc\odbc>go test
> warning: building out-of-date packages:
> code.google.com/p/odbc/api
> code.google.com/p/odbc
> installing these packages with 'go test -i' will speed future tests.
>
> panic: sql: Register called twice for driver odbc
>
> goroutine 1 [running]:
> database/sql.Register(0x505c38, 0x4, 0x10f11ec0, 0x5c7c20)
>
C:/Users/ADMINI~1/AppData/Local/Temp/2/bindist465310315/go/src/pkg/database/sql/
sql.go:31 +0xe3
> _/D_/odbc/odbc.init┬À1()
> D:/odbc/odbc/driver.go:74 +0x74
> _/D_/odbc/odbc.init()
> D:/odbc/odbc/mssql_test.go:864 +0x1612
> main.init()
>
C:/DOCUME~1/bbigras/LOCALS~1/Temp/go-build059931739/_/D_/odbc/odbc/_test
> /_testmain.go:34 +0x40
> exit status 2
> FAIL _/D_/odbc/odbc 0.438s
This will build test, but will include both odbc packages. It includes package
in current directory because that is what Go command does with current directry
files. It includes package in d:\odbc\GOPATH\src\code.google.com\p\odbc,
because you refer to it in your program.
So it is a mess. Don't do that. You should always work inside of %GOPATH%\src
directory. Just like that:
go command is in my PATH, but no GO environment variables are set:
C:\>go version
go version devel +c3bf615ba223 Tue Aug 27 14:33:05 2013 +1000 windows/386
C:\>set | find "GO"
C:\>
Lets set GOPATH:
C:\>set GOPATH=c:\b
C:\>
and download code.google.com/p/odbc package into new created workspace defined
by GOPATH:
C:\>go get -v code.google.com/p/odbc
code.google.com/p/odbc (download)
code.google.com/p/odbc/api
code.google.com/p/odbc
C:\>
Lets change to odbc package directory and run test:
C:\>cd %GOPATH%\src\code.google.com\p\odbc\
C:\b\src\code.google.com\p\odbc>go test -mssrv=MYSRV -msdb=MYDB -msuser=MYUSER
-mspass=MYPASS -v -run=MS
=== RUN TestMSSQLCreateInsertDelete
--- PASS: TestMSSQLCreateInsertDelete (0.31 seconds)
=== RUN TestMSSQLTransactions
--- PASS: TestMSSQLTransactions (0.13 seconds)
=== RUN TestMSSQLTypes
--- PASS: TestMSSQLTypes (0.08 seconds)
=== RUN TestMSSQLIntAfterText
--- PASS: TestMSSQLIntAfterText (0.00 seconds)
=== RUN TestMSSQLStmtAndRows
--- PASS: TestMSSQLStmtAndRows (0.03 seconds)
=== RUN TestMSSQLIssue5
--- PASS: TestMSSQLIssue5 (0.28 seconds)
=== RUN TestMSSQLDeleteNonExistent
--- PASS: TestMSSQLDeleteNonExistent (0.02 seconds)
PASS
ok code.google.com/p/odbc 0.984s
C:\b\src\code.google.com\p\odbc>
I hope it helps.
Alex
Alex
Original comment by alex.bra...@gmail.com
on 27 Aug 2013 at 5:44
Original issue reported on code.google.com by
bigras.b...@gmail.com
on 21 Aug 2013 at 8:38