如何在谷歌应用引擎的golang中使用束或引用自定义依赖

时间:2016-03-24 09:26:52

标签: google-app-engine go

目前我正在使用这一系列来进行npm样式类型构建,以及在我的web项目中使用符号链接,以便能够执行构建而无需从git存储库中提取。

例如,我的目录结构类似于以下

testapp / .vendor -controllers --user_controller.go -routers --router.go -楷模 --user.go server.go Bunchfile

所以在.vendor / src目录中

我也有

.vendor / SRC / example.com / TGO / testapp /路由器

因此,如果我不想在.vendor目录中复制我的文件夹,我将使用符号链接 - 这在我做的时候效果很好

ln -s~ / Documents / dev / go / testapp /〜/ Documents / dev / go / testapp / .vendor / src / example.com / tgo /

一堆建立

然而,对于谷歌应用引擎 - 试图看看这是否有效,还没有弄明白。

以下是server.go的代码

package main

import (
  "example.com/tgo/testapp/routers"
  "github.com/codegangsta/negroni"
  "net/http"
  "log"
)

func init(){
  //For Google App Engine
  //settings.Init()
  router :=  routers.InitRoutes()
  n := negroni.Classic()
  n.UseHandler(router)
  http.Handle("/", n)
}
func main() {
  router :=  routers.InitRoutes()
  n := negroni.Classic()
  n.UseHandler(router)
  log.Println("Listening......")
  http.ListenAndServe(":3001", n)

}

1 个答案:

答案 0 :(得分:0)

我实际上发现问题与在运行上传到App Engine之前分配$ GOPATH有关。

所以我只有一个脚本,将环境变量$ GOPATH设置为.vendor目录,然后运行goapp serve或goapp deploy,一切正常!

期待将所有内容移至应用引擎!