Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/google-app-engine/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Google app engine 在GAE下使用http.Server时运行时死机_Google App Engine_Go_Runtime Error - Fatal编程技术网

Google app engine 在GAE下使用http.Server时运行时死机

Google app engine 在GAE下使用http.Server时运行时死机,google-app-engine,go,runtime-error,Google App Engine,Go,Runtime Error,我的代码在这里: 为什么在浏览器中输入“”时会显示以下错误 错误: the runtime process gave a bad HTTP response: '' 2014/05/14 13:07:50 http: panic serving 127.0.0.1:59525: runtime error: invalid memory address or nil pointer dereference goroutine 3 [running]: net/http.func·009()

我的代码在这里:

为什么在浏览器中输入“”时会显示以下错误

错误:

the runtime process gave a bad HTTP response: ''

2014/05/14 13:07:50 http: panic serving 127.0.0.1:59525: runtime error: invalid memory address or nil pointer dereference
goroutine 3 [running]:
net/http.func·009()
    /tmp/appengine/go_appengine/goroot/src/pkg/net/http/server.go:1093 +0xae
runtime.panic(0x646520, 0x94ba48)
    /tmp/appengine/go_appengine/goroot/src/pkg/runtime/panic.c:248 +0x106
xflight.Download(0x7fcade6926b8, 0xc21000f6e0, 0xc21005ea90)
    xflight/xflight.go:21 +0x132
net/http.HandlerFunc.ServeHTTP(0x71b6e8, 0x7fcade6926b8, 0xc21000f6e0, 0xc21005ea90)
    /tmp/appengine/go_appengine/goroot/src/pkg/net/http/server.go:1220 +0x40
net/http.(*ServeMux).ServeHTTP(0xc21001e630, 0x7fcade6926b8, 0xc21000f6e0, 0xc21005ea90)
    /tmp/appengine/go_appengine/goroot/src/pkg/net/http/server.go:1496 +0x163
appengine_internal.handleFilteredHTTP(0x7fcade6926b8, 0xc21000f6e0, 0xc21005ea90)
    /tmp/appengine/go_appengine/goroot/src/pkg/appengine_internal/api_dev.go:98 +0x2e2
net/http.HandlerFunc.ServeHTTP(0x6fe040, 0x7fcade6926b8, 0xc21000f6e0, 0xc21005ea90)
    /tmp/appengine/go_appengine/goroot/src/pkg/net/http/server.go:1220 +0x40
net/http.serverHandler.ServeHTTP(0xc21000b640, 0x7fcade6926b8, 0xc21000f6e0, 0xc21005ea90)
    /tmp/appengine/go_appengine/goroot/src/pkg/net/http/server.go:1597 +0x16e
net/http.(*conn).serve(0xc210058380)
    /tmp/appengine/go_appengine/goroot/src/pkg/net/http/server.go:1167 +0x7b7
created by net/http.(*Server).Serve
    /tmp/appengine/go_appengine/goroot/src/pkg/net/http/server.go:1644 +0x28b

无法在应用程序引擎中使用默认http客户端。您需要在此处使用URL获取服务

示例:

您不能在应用程序引擎中使用默认http客户端。您需要在此处使用URL获取服务
示例:

示例中缺少func main()

顺便说一句,在
func Download()
-使用
string
而不是
variable
,如果转到
http://127.0.0.1:8080/download
-您总是会得到“resp”。

在您的示例中,func main()丢失


顺便说一句,在
func Download()
-使用
string
而不是
variable
,如果转到
http://127.0.0.1:8080/download
-你总是会得到“resp”。

谢谢你,这对我有点帮助。但是如何实际显示响应(本例中为html)?现在,当我这样做的时候,它只是给了我一些奇怪的文本:你直接打印身体,它将作为一个内存地址输出。您应该将正文中的数据复制到响应中。@SmiglowiecX这是另一个问题
resp.Body
是一个
io.Reader
界面(像流一样思考),@Logiraptor为您提供了答案。谢谢您,它帮了我一点忙。但是如何实际显示响应(本例中为html)?现在,当我这样做的时候,它只是给了我一些奇怪的文本:你直接打印身体,它将作为一个内存地址输出。您应该将正文中的数据复制到响应中。@SmiglowiecX这是另一个问题
resp.Body
是一个
io.Reader
界面(将其视为一条流),@Logiraptor为您提供了答案。