dongxi1680 2011-11-03 03:00
浏览 48
已采纳

如何在GAE中导入本地Go软件包

How to import local packages in Golang + GAE?

I wanna something like this:

app/
-app.yaml
-/my_app
--my_app.go
--/package1
---package1.go

Listing of my_app.go:

package my_app

import (
  "http"
  "./package1"
)

func init() {
  http.HandleFunc("/", package1.index)
}

Listing of package1.go:

package package1

import (
  "http"
  "fmt"
)

func index (w http.ResponseWriter, r * http.Request) {
  fmt.Fprint(w, "I'm index page =) ")
}

I this case I have an error like:

/path/to/project/my_app/my_app.go:5: can't find import: ./package1
2011/11/03 10:50:51 go-app-builder: Failed building app: failed running 6g: exit status 1

Thanks for help.

  • 写回答

2条回答 默认 最新

  • 普通网友 2011-11-03 11:23
    关注

    You either need to link or copy the packages to your application directory. The path relative to the root of the application directory should match the import path. To use package1, you should configure your app directory to look like this:

    app.yaml
    yourapp/yourapp.go
    package1/package1.go
    

    from https://groups.google.com/d/msg/golang-nuts/coEvrWIJGTs/75GzcefKVcIJ

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 乌班图ip地址配置及远程SSH
  • ¥15 怎么让点阵屏显示静态爱心,用keiluVision5写出让点阵屏显示静态爱心的代码,越快越好
  • ¥15 PSPICE制作一个加法器
  • ¥15 javaweb项目无法正常跳转
  • ¥15 VMBox虚拟机无法访问
  • ¥15 skd显示找不到头文件
  • ¥15 机器视觉中图片中长度与真实长度的关系
  • ¥15 fastreport table 怎么只让每页的最下面和最顶部有横线
  • ¥15 java 的protected权限 ,问题在注释里
  • ¥15 这个是哪里有问题啊?