Tag: 走路

docker中的Golang错误

在构build我的应用程序时,我在Docker中遇到了一个奇怪的错误: ./main.go:31:9: cannot use db (type *"github.com/khwerhahn/somerepo/vendor/github.com/jinzhu/gorm".DB) as type *"app/vendor/github.com/jinzhu/gorm".DB in argument to Migrate The command '/bin/sh -c go-wrapper install' returned a non-zero code: 2 有人可以提示我进入正确的方向,因为本地的应用程序运行得很好。 它只是在docker集装箱内。 我用glide来pipe理依赖关系。 Dockerfile: FROM golang:1.9 WORKDIR /go/src/app COPY . . RUN go-wrapper download RUN go-wrapper install CMD ["go-wrapper", "run"] ////编辑这是我的结构看起来如何。 Glidepipe理供应商文件夹。 dockerbuild设rest。

连接时Gorm + Docker错误

我试图用Docker连接到我的postgresql数据库: package main import ( "fmt" "log" "github.com/jinzhu/gorm" _ "github.com/jinzhu/gorm/dialects/postgres" ) type Product struct { gorm.Model Code string Price uint } var db *gorm.DB func init() { connection := fmt.Sprintf("host=db sslmode=disable user=dnz-dev password=dnz-dev") db, err := gorm.Open("postgres", connection) if err != nil { log.Fatalln(err) } defer db.Close() } func main() { // Migrate the schema […]