Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Go build fails in docker with error "no buildable Go source files" #51

Closed
namratachaudhary opened this issue Jun 11, 2018 · 6 comments
Closed

Comments

@namratachaudhary
Copy link

namratachaudhary commented Jun 11, 2018

At the point in dockerfile where the command is

RUN go get -v -t  .
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o bin/app

The build fails with error

go build github.com/golang-migrate/migrate/database/postgres: no buildable Go source files in /go/src/github.com/golang-migrate/migrate/database/postgres
The command '/bin/sh -c CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o bin/app' returned a non-zero code: 1

In main.go, I'm using this , like

import (
         "github.com/golang-migrate/migrate"
	 "github.com/golang-migrate/migrate/database/postgres"
)

func main() {
         // conn is a local variable, initalized in `init()`
	driver, err := postgres.WithInstance(conn.DB(), &postgres.Config{})
	m, err := migrate.NewWithDatabaseInstance(
		"file://migrations",
		"postgres",
		driver,
	)

        if err = m.Up(); err != nil && err.Error() != "no change" {
		m.Down()
		panic(err)
	}
}
@dhui
Copy link
Member

dhui commented Jun 11, 2018

It looks like you're using your own Dockerfile, not the one in migrate since that one uses go get -v ./...

The master branch of migrate now uses dep, so I'd use that instead. e.g. dep ensure -vendor-only If you need to pin to a released version of migrate, you'll need to wait for the next version which will officially support dep (and provide a docker image for the CLI).

@namratachaudhary
Copy link
Author

Hey @dhui
I'm trying to use it as a package, and not cli, in which case go get -v should work, right? I even tried using dep by enforcing master in Gopkg.toml

[[constraint]]
  branch = "master"
  name = "github.com/golang-migrate/migrate"

But the go build still fails. Is there any other way around this?

@dhui
Copy link
Member

dhui commented Jun 11, 2018

go get and dep should work. Do you have any errors running go get or dep ensure?

Do you have more info for your build/compile errors? My guess is that the build issues are internal to your project/code as migrate is building fine in TravisCI.

@namratachaudhary
Copy link
Author

I changed the dep installation to via-curl , and it worked.
No idea what changed, but this seems to be working fine.
Maybe I'll debug more and post findings.

Thanks a lot 😄

@dhui dhui closed this as completed Jun 18, 2018
@dmmulroy
Copy link

dmmulroy commented Oct 2, 2018

@namratachaudhary did you ever figure out what was happening? I'm having this same issue on our jenkins server but not locally.

@dhui
Copy link
Member

dhui commented Oct 3, 2018

@dmmulroy migrate currently uses modules to manage it dependencies. You'll need to run Go 1.11 to use that. I'd pin to v3.5.3 for module support as the future of modules in migrate is up in the air

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants