heroku - 在 heroku 中使用本地包 Revel 应用程序

标签 heroku go import revel

我正在尝试在 heroku 中部署一个 revel 应用程序,其中我有以下文件夹结构:

+Base
    +app
        +controllers
            -app.go
        +views
        +models
            -user.go
        +routes
    +conf
    +public
    +test
    .godir

app.go 中,我尝试包含执行此操作的模型和路由:

import("base/app/models")

我可以在本地运行应用程序,然后我可以使用 models.User。我尝试了很多方法来在 heroku 中导入这些本地包:

import("../models")
import("../models/user")
import("./app/models")
import("./base/app/models")

我现在不记得所有的尝试了,但我尝试了很长时间,但我不知道该怎么做。

我本地用的是go 1.6,push的时候用的是1.4。这是我运行 git push heroku master

时出现的痕迹
Counting objects: 93, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (86/86), done.
Writing objects: 100% (93/93), 11.68 KiB | 0 bytes/s, done.
Total 93 (delta 50), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote: 
remote: -----> Revel app detected
remote: -----> Using go1.4
remote: -----> Running: go get -tags heroku ./...
remote: can't load package: /tmp/build_02574263f0810eec437968b2e73f635d/.go/src/base/app/controllers/gorp.go:10:2: local import "../models" in non-local package
remote:  !     Push rejected, failed to compile Revel app.
remote: 
remote:  !     Push failed
remote: Verifying deploy...
remote: 
remote: !   Push rejected to ndc-console.
remote: 
To https://git.heroku.com/ndc-console.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/ndc-console.git'

它发生在使用import("base/app/models")

有什么办法吗??谢谢。

编辑

我登录到 heroku bash(运行 heroku run bash),我看到了文件夹结构,它是这样的:

bin
dev
more...
app /*This is the base folder*/
    app
        controllers
        views
        models
        routes
    config
    public
    .go /*this is the GOPATH*/

        src
            github.com
            golang.org
            gopkg.in
            base-test /* This name is because I change the original name, from base-test to base... */
            /* IS IT IMPORTANT? */
            /* Inside this folder the app is duplicated */

通过这种方式,我也尝试了 import("base-test/app/models") 并且也尝试了从 root 开始的所有路径(尝试荒谬的事情)。

希望对解决问题有所帮助。谢谢。

最佳答案

好的!!!完毕!!

最后,项目的旧名称产生了问题。似乎当我更改 heroku 应用程序的名称时,heroku 在编译时不会更改文件夹的名称......而且我也需要更改 .godir 文件的内容并将其设置为 base-test(旧名称)。

所以现在我的导入看起来像:import("base-test/app/models")

谢谢大家

关于heroku - 在 heroku 中使用本地包 Revel 应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40869842/

相关文章:

unit-testing - 我怎么知道我在 "go test"内运行

python - 在 python 中的文件之间共享 header ?

mysql - 将主 auto_increment 值为零的表导入到 mariadb

django - 如何将django-cookiecutter制作的多个Docker镜像推送到Heroku?

java - heroku 使用什么版本的 Maven?

go - 如何比较 GoLang 中的字符串?

go - 如何等待多个 goroutine 完成?

java - 如何测试我的Android应用程序是否正在接收数据?

Heroku 不从不同的分支部署

python - 在浏览器中将 PUT 上传到 S3 时忽略内容类型?