<p>make sure the attributes are capitalized or they won't be published... I understand that this is a convention of the language, but I failed to understand it early enough today! My output (cgo, ffi, ruby) would simply come back as a slice of empty maps :)</p>
<pre><code>// good
type WeightedWord struct {
Text string
Weight int
}
//bad
type WeightedWord struct {
text string
weight int
}
</code></pre>
<hr/>**评论:**<br/><br/>jamra06: <pre><pre><code>type WeightedWord struct {
Text string `json:"text"`
Weight int `json:"weight"`
}
</code></pre>
<p>This will get you what you were looking for originally.</p></pre>mekdigital: <pre><p>that's a neat trick learn! thanks</p></pre>XANi_: <pre><p>RTFM, there are few more useful options like <code>omitempty</code></p></pre>mekdigital: <pre><p>I need to tag my post with "SUPA-NOOB" :D</p></pre>XANi_: <pre><p>golang has REALLY nice doc tools, you can point your browser to <a href="https://godoc.org/any/webpage/hosting/repo" rel="nofollow">https://godoc.org/any/webpage/hosting/repo</a> and get a doc for package</p>
<p>It also have very nice feature of "verifiable examples" where (when you name and document it correctly) example code is ran during <code>go test</code> so it is very hard to accidentally break example code when changing other parts of your codebase</p></pre>mekdigital: <pre><p>OH NO MORE THINGS TO LEARN ®</p></pre>XANi_: <pre><p>It never ends</p></pre>elusivegopher: <pre><p>Really? RTFM just because he doesn't know about struct tags?</p>
<p>Seems a bit harsh for one of today's <a href="https://xkcd.com/1053/" rel="nofollow">10,000</a>.</p></pre>XANi_: <pre><p>What is wrong with reading the fine manual ?</p>
<p>I've found out few useful things in json module thanks to that, for example that you can tell it to parse only "first" level of json into <code>map[string]json.RawMessage</code> which is very handy if you have to interact with <a href="https://doc.powerdns.com/md/authoritative/backend-remote/" rel="nofollow">certain types of api</a></p>
<blockquote>
<p>Seems a bit harsh for one of today's 10,000.</p>
</blockquote>
<p>That XKCD is ...not relevant in any way.</p>
<p>If you use API and dont bother to even gloss over documentation you will eventually hurt yourself, or everyone involved</p></pre>xkcd_transcriber: <pre><p><a href="http://imgs.xkcd.com/comics/ten_thousand.png" rel="nofollow">Image</a></p>
<p><a href="http://m.xkcd.com/1053/" rel="nofollow">Mobile</a></p>
<p><strong>Title:</strong> Ten Thousand</p>
<p><strong>Title-text:</strong> Saying 'what kind of an idiot doesn't know about the Yellowstone supervolcano' is so much more boring than telling someone about the Yellowstone supervolcano for the first time.</p>
<p><a href="http://www.explainxkcd.com/wiki/index.php/1053#Explanation" rel="nofollow">Comic Explanation</a></p>
<p><strong>Stats:</strong> This comic has been referenced 6140 times, representing 6.2372% of referenced xkcds.</p>
<hr/>
<p><sup><a href="http://www.xkcd.com" rel="nofollow">xkcd.com</a></sup> <sup>|</sup> <sup><a href="http://www.reddit.com/r/xkcd/" rel="nofollow">xkcd sub</a></sup> <sup>|</sup> <sup><a href="http://www.reddit.com/r/xkcd_transcriber/" rel="nofollow">Problems/Bugs?</a></sup> <sup>|</sup> <sup><a href="http://xkcdref.info/statistics/" rel="nofollow">Statistics</a></sup> <sup>|</sup> <sup><a href="http://reddit.com/message/compose/?to=xkcd_transcriber&subject=ignore%20me&message=ignore%20me" rel="nofollow">Stop Replying</a></sup> <sup>|</sup> <sup><a href="http://reddit.com/message/compose/?to=xkcd_transcriber&subject=delete&message=delete%20t1_cznisgk" rel="nofollow">Delete</a></sup></p></pre>
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889
- 请尽量让自己的回复能够对别人有帮助
- 支持 Markdown 格式, **粗体**、~~删除线~~、
`单行代码`
- 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
- 图片支持拖拽、截图粘贴等方式上传