duanhe1903 2016-11-29 15:39
浏览 52

在Heroku中使用本地软件包的Revel应用

I am trying to deploy a revel app in heroku, in which I have this folder structure:

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

In app.go I try to include models and routes doing this:

import("base/app/models")

I am able to run app in local, and after I can use models.User. I had tried to make a lot of ways to import these local packages in heroku:

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

I don't remember now all attempts, but I am trying it for a long time and I don't know ho to do.

I am using locally go 1.6, and 1.4 when I push. And this is the trace that appears when I run 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'

It happens using import("base/app/models").

Any solution?? Thank you.

EDIT

I log into heroku bash (running heroku run bash) and I see the folder structure, and it is something like:

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 */

In this way I tried too import("base-test/app/models") and too including all path from root (trying absurd things).

I hope it helps to find a solution. Thanks.

  • 写回答

1条回答 默认 最新

  • douhuan1937 2016-11-30 15:00
    关注

    Ok!!! done!!

    Finally, the old name of the project was generating a problem. It seems that when I change the name of the heroku app, heroku doesn't change the name of the folder when it will be compiled... AND I need change too the content of the .godir file and set it as base-test (the old name).

    So now the imports I have looks like: import("base-test/app/models").

    Thank you everyone.

    评论

报告相同问题?

悬赏问题

  • ¥15 matlab(相关搜索:紧聚焦)
  • ¥15 基于51单片机的厨房煤气泄露检测报警系统设计
  • ¥15 路易威登官网 里边的参数逆向
  • ¥15 Arduino无法同时连接多个hx711模块,如何解决?
  • ¥50 需求一个up主付费课程
  • ¥20 模型在y分布之外的数据上预测能力不好如何解决
  • ¥15 processing提取音乐节奏
  • ¥15 gg加速器加速游戏时,提示不是x86架构
  • ¥15 python按要求编写程序
  • ¥15 Python输入字符串转化为列表排序具体见图,严格按照输入