mofury
mofury

Reputation: 725

How to deploy Go apps with internal package to Heroku using `dep`

I am using Heroku's Golang buildpack to deploy a simple web app with the following structure

my-app/
    handler/
        user.go
        session.go
    vendor/
        github.com/
        golang.org/
    main.go
    Gopkg.toml
    Gopkg.lock

Inside my main file, I imported my own handler package

import (
    "fmt"
    "net/http"
    "my-app/handler"
)

Heroku was not able to run go install on my project due the following error:

----> Using go1.9.3
----> Running: go install -v -tags heroku . 
----> cannot find package "my-app/handler" in any of: ... 

I can run go install and my-app without any problem locally. It seems to me that heroku does not recognize my internal project package.

I am using dep and I have the following configurations in my Gopkg.toml:

[metadata.heroku]
root-package = "github.com/mygithub/my-app"
go-version = "go1.9.3"
install = ["."]
ensure = "false"

What else do I need to do to deploy a Go app with internal package? Thanks.

Upvotes: 3

Views: 1131

Answers (1)

Frits
Frits

Reputation: 106

Try to set the root package to just the name of the project without the domain

[metadata.heroku] root-package = "my-app" go-version = "go1.9.2" install = [ "./..." ]

Upvotes: 4

Related Questions