英文:
grave in the Go Language
问题
json:
标签在Go语言中的使用方法,我经过一段时间的研究终于明白了。然而,我遇到了两个标签,我还不太了解,并且似乎找不到相关的文档。
这两个标签都与REST API服务有关,完整的代码可以在这里找到-> code.google.com
root:
标签用于什么?
gorest.RestService `root:"/orders-service/" consumes:"application/json" produces:"application/json"`
method:
标签是如何工作的?
userDetails gorest.EndPoint `method:"GET" path:"/users/{Id:int}" output:"User"`
我不知道是否有人有任何链接到一个网站或文档,可以更详细地解释这个问题,从示例中我可以学到足够的知识来使用它。然而,我真的很想完全理解它。
谢谢你的时间!
英文:
After looking around for a while I was able to understand how the json:
tags are used in the Go language. However two tags I have come across I'm still lost on, and can't seem to find documentation on it.
Both pertain to a REST api service and the full code can be found here-> code.google.com
What is the root:
tag used for
gorest.RestService `root:"/orders-service/" consumes:"application/json" produces:"application/json"`
as well how does the method:
tag work?
userDetails gorest.EndPoint `method:"GET" path:"/users/{Id:int}" output:"User"`
I didn't know if anyone had any links to a site or document that might explain this more, from the examples I can learn enough to use it. However, I would really like to fully understand it.
Thanks for your time!
答案1
得分: 6
标签只是字符串,它们本身没有任何意义。
库可以使用反射来检查结构字段并解释它们的标签。请参阅reflect.StructTag
。
在你的情况下,gorest
在_服务_上解析以下标签:
- root
- consumes
- produces
以及在_端点_上解析以下标签:
- realm
- method
- path
- output
- input
- role
- postdata
它们的含义在gorest
的文档中有描述。
英文:
Tags are nothing but strings, they don't have any meaning per-se.
Libraries can use reflection to introspect struct fields and interpret their tags. See reflect.StructTag
.
In your case, gorest
parses the following tags on Services:
- root
- consumes
- produces
and these on Endpoints:
- realm
- method
- path
- output
- input
- role
- postdata
Their meaning is described in gorest
's documentation.
答案2
得分: 1
这些是gorest标签。请参阅gorest维基 http://code.google.com/p/gorest/wiki/GettingStarted
英文:
These are gorest tags. See gorest wiki http://code.google.com/p/gorest/wiki/GettingStarted
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论