google-app-engine - 如何在 golang 中为 Google App Engine 使用 bunch 或引用自定义依赖项

标签 google-app-engine go

目前,我正在使用这群人来进行 npm 样式类型的构建,并在我的 Web 项目中使用符号链接(symbolic link),以便能够在无需从 git 存储库中拉取的情况下进行构建。

例如我的目录结构如下

测试应用/ 。小贩 - Controller --user_controller.go -路由器 --router.go -楷模 --user.go 服务器.go 束文件

所以在 .vendor/src 目录中

我也有

.vendor/src/example.com/tgo/testapp/routers

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

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

群去构建

但是对于 Google App Engine - 试图看看这是否可行,但还没有弄清楚。

这是 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)

}

最佳答案

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

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

期待将所有内容移至 App Engine!

关于google-app-engine - 如何在 golang 中为 Google App Engine 使用 bunch 或引用自定义依赖项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36196819/

相关文章:

google-app-engine - "goapp build"工作,但 "appcfg.py update"只是 "can' t 找到导入“......?

android - 将 Google App Engine 工具安装到 Eclipse (ADT)

戈朗 : Wait x amount of time before looping again without starting new goroutine

mongodb - Golang revel+mgo - 当结构变量具有小写名称时不返回数据

在包中定义的方法中调用的 Goroutine 不运行

java - ClassNotFoundException - ResteasyBootstrap

google-app-engine - Go编程如何创建表单模板?

Golang Dockerfile : Unable to find packages in docker build but runs normally

memory - 如何将内存地址(如 0xc20803a000)转换为字符串?戈朗

python - Paypal与谷歌应用引擎-python集成