英文:
Simple Application in Go using Google App Engine SDK
问题
当我按照Google开发者的教程使用Go语言和Go应用引擎SDK创建一个简单应用程序时,在运行以下命令时:
goapp serve
我收到以下错误信息:
Traceback (most recent call last):
File "/home/kamal/go_appengine/dev_appserver.py", line 82, in <module>
_run_file(__file__, globals())
File "/home/kamal/go_appengine/dev_appserver.py", line 78, in _run_file
execfile(_PATHS.script_file(script_name), globals_)
File "/home/kamal/go_appengine/google/appengine/tools/devappserver2/devappserver2.py", line 1001, in <module>
main()
File "/home/kamal/go_appengine/google/appengine/tools/devappserver2/devappserver2.py", line 994, in main
dev_server.start(options)
File "/home/kamal/go_appengine/google/appengine/tools/devappserver2/devappserver2.py", line 754, in start
options.config_paths)
File "/home/kamal/go_appengine/google/appengine/tools/devappserver2/application_configuration.py", line 632, in __init__
module_configuration = ModuleConfiguration(config_path)
File "/home/kamal/go_appengine/google/appengine/tools/devappserver2/application_configuration.py", line 97, in __init__
self._config_path)
File "/home/kamal/go_appengine/google/appengine/tools/devappserver2/application_configuration.py", line 316, in _parse_configuration
config, files = appinfo_includes.ParseAndReturnIncludePaths(f)
File "/home/kamal/go_appengine/google/appengine/api/appinfo_includes.py", line 81, in ParseAndReturnIncludePaths
appyaml = appinfo.LoadSingleAppInfo(appinfo_file)
File "/home/kamal/go_appengine/google/appengine/api/appinfo.py", line 1873, in LoadSingleAppInfo
listener.Parse(app_info)
File "/home/kamal/go_appengine/google/appengine/api/yaml_listener.py", line 226, in Parse
self._HandleEvents(self._GenerateEventParameters(stream, loader_class))
File "/home/kamal/go_appengine/google/appengine/api/yaml_listener.py", line 177, in _HandleEvents
raise yaml_errors.EventError(e, event_object)
google.appengine.api.yaml_errors.EventError: Unknown url handler type.
URLMap
auth_fail_action=redirect
static_dir=None
secure=default
http_headers=None
url=/.*
static_files=None
expiration=None
upload=None
api_endpoint=None
script=None
application_readable=None
position=None
login=optional
mime_type=None
require_matching_file=None
in "myapp/app.yaml", line 8, column 1
error while running dev_appserver.py: exit status 1
我不知道如何调试它。只需要一个提示就足够了。
另外,可能是因为我没有安装Web服务器吗?我需要安装Apache或Nginx来运行goapp serve
吗?还是Go语言自己处理服务器相关的事情?
英文:
When I follow Google-Developers' tutorial for creating a simple application in Go using App Engine SDK for Go, while running the command
goapp serve
I receive the following error:
Traceback (most recent call last):
File "/home/kamal/go_appengine/dev_appserver.py", line 82, in <module>
_run_file(__file__, globals())
File "/home/kamal/go_appengine/dev_appserver.py", line 78, in _run_file
execfile(_PATHS.script_file(script_name), globals_)
File "/home/kamal/go_appengine/google/appengine/tools/devappserver2/devappserver2.py", line 1001, in <module>
main()
File "/home/kamal/go_appengine/google/appengine/tools/devappserver2/devappserver2.py", line 994, in main
dev_server.start(options)
File "/home/kamal/go_appengine/google/appengine/tools/devappserver2/devappserver2.py", line 754, in start
options.config_paths)
File "/home/kamal/go_appengine/google/appengine/tools/devappserver2/application_configuration.py", line 632, in __init__
module_configuration = ModuleConfiguration(config_path)
File "/home/kamal/go_appengine/google/appengine/tools/devappserver2/application_configuration.py", line 97, in __init__
self._config_path)
File "/home/kamal/go_appengine/google/appengine/tools/devappserver2/application_configuration.py", line 316, in _parse_configuration
config, files = appinfo_includes.ParseAndReturnIncludePaths(f)
File "/home/kamal/go_appengine/google/appengine/api/appinfo_includes.py", line 81, in ParseAndReturnIncludePaths
appyaml = appinfo.LoadSingleAppInfo(appinfo_file)
File "/home/kamal/go_appengine/google/appengine/api/appinfo.py", line 1873, in LoadSingleAppInfo
listener.Parse(app_info)
File "/home/kamal/go_appengine/google/appengine/api/yaml_listener.py", line 226, in Parse
self._HandleEvents(self._GenerateEventParameters(stream, loader_class))
File "/home/kamal/go_appengine/google/appengine/api/yaml_listener.py", line 177, in _HandleEvents
raise yaml_errors.EventError(e, event_object)
google.appengine.api.yaml_errors.EventError: Unknown url handler type.
URLMap
auth_fail_action=redirect
static_dir=None
secure=default
http_headers=None
url=/.*
static_files=None
expiration=None
upload=None
api_endpoint=None
script=None
application_readable=None
position=None
login=optional
mime_type=None
require_matching_file=None
in "myapp/app.yaml", line 8, column 1
error while running dev_appserver.py: exit status 1
I don't know how to debug it. Just a hint would be sufficient.
Also, can it be because I have no web server installed? Do I have to install Apache or Nginx for goapp serve
or go handles the server stuff itself?
答案1
得分: 3
问题是在.yaml
文件的handlers
中的script
的缩进问题。
我最初是这样做的:
handlers:
- url: /.*
script: _go_app
而实际上应该是:
handlers:
- url: /.*
script: _go_app
现在它可以正常工作了!
英文:
The problem was indentation of script
in handlers
in .yaml
file.
I initially did it like this:
handlers:
- url: /.*
script: _go_app
While it should be:
handlers:
- url: /.*
script: _go_app
It works now!
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论