json tags validation

agolangf · · 704 次点击    
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
<p>Hey , </p> <p>im using go-endpoints In the struct usage example , they used the endpoints:&#34;req&#34;` tag </p> <p><a href="https://github.com/GoogleCloudPlatform/go-endpoints#usage" rel="nofollow">go-endpoints</a></p> <p>that suppose to be a mandatory field ?</p> <p>I tried to pass an empty value to a field with the endpoints:req tag and <strong>i didn&#39;t get any error</strong></p> <p>What will be the best way to valid mandatory fields ?</p> <p>i can do something like that but it must be a nicer solution</p> <pre><code> if len(subscriptionToken) == 0 { return endpoints.NewAPIError(&#34;subscriptionToken is empty&#34;, &#34;subscriptionToken is empty&#34;, 400) } </code></pre> <p>these anyone has an experience with endpoints and tag validation ? </p> <p>Also im looking for alternative library to use in case the endpoints one won&#39;t work , which package you recommend ?</p> <hr/>**评论:**<br/><br/>ninja_uzumaki: <pre><p>I think you would get more answers if you provide a link to go-endpoints and give more context into your problem.</p></pre>

入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889

704 次点击  
加入收藏 微博
暂无回复
添加一条新回复 (您需要 登录 后才能回复 没有账号 ?)
  • 请尽量让自己的回复能够对别人有帮助
  • 支持 Markdown 格式, **粗体**、~~删除线~~、`单行代码`
  • 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
  • 图片支持拖拽、截图粘贴等方式上传