google-app-engine - 为什么 goapp test 在/tmp 中寻找文件?

标签 google-app-engine go

我正在尝试让测试在我的本地开发机器上运行 Cloud SDK 版本是:159.0.0

我读过的所有内容都说我不应该更改 GOROOT,所以我不确定如何解决这个问题。

$/Users/bryan/google-cloud-sdk/platform/google_appengine/goroot/bin/goapp 测试

go: cannot find GOROOT directory: /tmp/go_sdk887571938/appengine/go_appengine/goroot

bryan@Bryans-MacBook 周四 6 月 15 日 10:22:37 ~/go/src/skincarereview

$ 去环境

GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/bryan/go/"
GORACE=""
GOROOT="/usr/local/go"
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GO15VENDOREXPERIMENT="1"
CC="clang"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fno-common"
CXX="clang++"
CGO_ENABLED="1"

bryan@Bryans-MacBook 周四 6 月 15 日 10:22:57 ~/go/src/skincarereview

$ ls ~/google-cloud-sdk

total 408
drwxr-xr-x  30 bryan  staff    1020 Jun 14 20:31 .install
-rw-r--r--   1 bryan  staff     980 Jun 14 20:30 LICENSE
-rw-r--r--   1 bryan  staff     673 Jun 14 20:30 README
-rw-r--r--   1 bryan  staff  162673 Jun 14 20:30 RELEASE_NOTES
-rw-r--r--   1 bryan  staff       8 Jun 14 20:30 VERSION
drwxr-xr-x  10 bryan  staff     340 Jun 14 20:30 bin
-rw-r--r--   1 bryan  staff    2734 Jun 14 20:30 completion.bash.inc
-rw-r--r--   1 bryan  staff    2083 Jun 14 20:30 completion.zsh.inc
drwxr-xr-x   3 bryan  staff     102 Jun 14 20:30 help
-rwxr-xr-x   1 bryan  staff    1581 Jun 14 20:30 install.bat
-rwxr-xr-x   1 bryan  staff    3471 Jun 14 20:30 install.sh
drwxr-xr-x  10 bryan  staff     340 Jun 14 20:30 lib
-rw-r--r--   1 bryan  staff     308 Jun 14 20:30 path.bash.inc
-rw-r--r--   1 bryan  staff    1210 Jun 14 20:30 path.fish.inc
-rw-r--r--   1 bryan  staff      31 Jun 14 20:30 path.zsh.inc
drwxr-xr-x   6 bryan  staff     204 Jun 14 20:30 platform
-rw-r--r--   1 bryan  staff      40 Jun 14 20:30 properties

bryan@Bryans-MacBook 6 月 15 日星期四 10:24:22 ~/go/src/skincarereview

$ find/-name goroot 2>/dev/null

/Users/bryan/google-cloud-sdk/platform/google_appengine/goroot

bryan@Bryans-MacBook 周四 6 月 15 日 10:28:43 ~/go/src/skincarereview

$回显$PATH

/Users/bryan/google-cloud-sdk/bin:/Users/bryan/go/src/:/Users/bryan/google-cloud-sdk/platform/google_appengine/goroot/bin/:/Users/bryan/google-cloud-sdk/bin/:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/go/bin

查看 main.go 的第 155 行,我认为这是抛出错误的地方,但我没有看到“goroot”的设置位置。

if fi, err := os.Stat(goroot); err != nil || !fi.IsDir() {
    fmt.Fprintf(os.Stderr, "go: cannot find GOROOT directory: %v\n", goroot)
    os.Exit(2)
}

最佳答案

您可以尝试关注 recommendation of this answer :

If your install is messed up beyond reason (happened to me once), just remove the cloud SDK and any references to it in your $PATH. Also completely uninstall the regular Go installation.

Then start from scratch. Install Go, unpack google-cloud-sdk, run installer (add to $PATH if needed), gcloud components install app-engine-go.
Voila.

正如在同一个答案中提到的,您没有在任何地方设置 GOROOTit is set for you .

关于google-app-engine - 为什么 goapp test 在/tmp 中寻找文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44592333/

相关文章:

python - 如何使用 python 的 GAE 开发服务器测试台模拟文件上传到 blobstore

google-app-engine - 谷歌应用程序引擎启动器不会部署应用程序: says application does not exist

string - 为什么简单的 Go 应用程序占用大量内存

go - 类型、接口(interface)和指针

regex - 转到正则表达式通配符以获取没有周围文本的标签

azure - 上传 Blob 时可以设置访问层吗?如果是,那么该怎么做呢?

java - 尝试在 GAE 开发环境中使用 restFB 时出错

java - 如何使用 Google App Engine 邮件服务发送电子邮件?

python - gqlQuery 返回对象,想要键列表

variables - 如何通过连接两个字符串来创建动态变量名