donglanfu5831 2014-09-27 16:43
浏览 90

使用本地软件包在Heroku上运行App

I'm trying to put a Go app on Heroku using the Go Buildpack, which is fine when it's something basic, but as soon as I do a local package it does not compile. Here's an example setup:

Structure

+ship
  +foo  
    foo.go
  main.go

main.go

package main

import (
  "os"
  "fmt"
  "net/http"
  "ship/foo"
)

func main() {
  foo.Bar()
  port := os.Getenv("PORT")
  http.HandleFunc("/", root)
  http.ListenAndServe(":" + port, nil)
}

func root(w http.ResponseWriter, r *http.Request) {
  fmt.Fprint(w, "Aloha, world!")
}

foo.go

package foo

func Bar() {}

Push

git push heroku master
Initializing repository, done.
Counting objects: 20, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (13/13), done.
Writing objects: 100% (20/20), 1.53 MiB | 586.00 KiB/s, done.
Total 20 (delta 2), reused 0 (delta 0)

-----> Fetching custom git buildpack... done
-----> Go app detected
-----> Installing go1.3.1... done
-----> Running: godep go install -tags heroku ./...
main.go:7:3: cannot find package "ship/foo" in any of:
    /app/tmp/cache/go1.3.1/go/src/pkg/ship/foo (from $GOROOT)
    /tmp/build_4b92e51c-3959-4ddb-8eff-90d72da70729/.heroku/g/src/_/Users/Daryl/Go/src/ship/Godeps/_workspace/src/ship/foo (from $GOPATH)
    /tmp/build_4b92e51c-3959-4ddb-8eff-90d72da70729/.heroku/g/src/ship/foo
godep: go exit status 1

 !     Push rejected, failed to compile Go app

Any idea what's going on here and how to go about it?

  • 写回答

2条回答 默认 最新

报告相同问题?

悬赏问题

  • ¥20 win11修改中文用户名路径
  • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
  • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计
  • ¥70 PlayWright在Java上连接CDP关联本地Chrome启动失败,貌似是Windows端口转发问题
  • ¥15 帮我写一个c++工程
  • ¥30 Eclipse官网打不开,官网首页进不去,显示无法访问此页面,求解决方法
  • ¥15 关于smbclient 库的使用
  • ¥15 微信小程序协议怎么写
  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害