zzh@ZZHPC:/zdata/MyPrograms/Go/aaa/Ch05/05_04$ go run httpd.go
# command-line-arguments
./httpd.go:15:9: undefined: DB
./httpd.go:58:16: undefined: NewDB
zzh@ZZHPC:/zdata/MyPrograms/Go/aaa/Ch05/05_04$ go run *.go
2023/09/08 23:29:15 error: sql: unknown driver "postgres" (forgotten import?)
exit status 1
zzh@ZZHPC:/zdata/MyPrograms/Go/aaa/Ch05/05_04$ go get github.com/lib/pq
go: downloading github.com/lib/pq v1.10.9
go: added github.com/lib/pq v1.10.9
Two files contain "package main", one file can't call the other file's things. To resolve the first error, you must go run *.go.
To resolve the second error, first run 'go get github.com/lib/pq', then add '_ "github.com/lib/pq"' in import.
标签:github,undefined,lib,Go,pq,command,arguments,go,com From: https://www.cnblogs.com/zhangzhihui/p/17688759.html