Jor*_*dan 3 google-app-engine go
我在〜/ Applications/google_appengine中有我的appengine SDK
在Eclipse中,我有一个外部工具设置来运行开发服务器.它指出:
〜/应用/ google_appengine/dev_appserver.py
同样在Eclipse(Go Preferences)中,我将GOROOT设置为指向
〜/应用/ google_appengine/GOROOT
现在,我正在尝试为我的项目运行一些单元测试.如果我使用我的常规安装(不是appengine安装),我会收到此错误:
../../context/context.go:4:2: cannot find package "appengine" in any of:
/usr/local/go/src/pkg/appengine (from $GOROOT)
/Users/home/src/go/foodbox/src/appengine (from $GOPATH)
../../context/data.go:4:2: cannot find package "appengine/datastore" in any of:
/usr/local/go/src/pkg/appengine/datastore (from $GOROOT)
/Users/home/src/go/foodbox/src/appengine/datastore (from $GOPATH)
../../context/context.go:5:2: cannot find package "appengine/user" in any of:
/usr/local/go/src/pkg/appengine/user (from $GOROOT)
/Users/home/src/go/foodbox/src/appengine/user (from $GOPATH)
Run Code Online (Sandbox Code Playgroud)
如果我使用appengine go,我会得到这个:
load cmd/cgo: package cmd/cgo: no Go source files in /Users/home/Application/google_appengine/goroot/src/cmd/cgo
Run Code Online (Sandbox Code Playgroud)
看起来默认安装无法找到appengine包(我猜这并不奇怪).当我使用appengine go工具时,我不确定问题是什么.任何人都可以告诉我如何使这个工作?
谢谢!
值得一提的appengine/aetest
是,自1.8.6以来,该软件包现已包含在SDK中.请参阅文档.
基本上你appengine.Context
可以在测试中使用它,类似于icub3d/appenginetesting.
引用文档中的示例:
import (
"testing"
"appengine/aetest"
)
func TestMyFunction(t *testing.T) {
c, err := aetest.NewContext(nil)
if err != nil {
t.Fatal(err)
}
defer c.Close()
// Run code and tests requiring the appengine.Context using c.
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
1162 次 |
最近记录: |