如何解决golang使用终端命令迁移未知驱动程序postgresql
当我尝试使用终端命令(migrate -path scripts -database "postgresql://postgres:postgres@localhost:5439/basename?sslmode=disable" -verbose down
)进行基础迁移时,出现错误:error: database driver: unknown driver postgresql (forgotten import?)
。如何解决?
解决方法
我认为您需要使用特定标签进行构建以添加特定驱动程序。
查看文档 https://github.com/golang-migrate/migrate/tree/master/cmd/migrate#with-go-toolchain
$ go get -u -d github.com/golang-migrate/migrate/cmd/migrate
$ cd $GOPATH/src/github.com/golang-migrate/migrate/cmd/migrate
$ git checkout $TAG # e.g. v4.1.0
$ go build -tags 'postgres' -ldflags="-X main.Version=$(git describe --tags)" -o $GOPATH/bin/migrate $GOPATH/src/github.com/golang-migrate/migrate/cmd/migrate
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。