What would you like to see in a fake data generator?

polaris · · 1112 次点击    
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
<p>I just recently built a fake data generator and wanted to know if their was anything that i missed that you guys would like me to add. <a href="http://godoc.org/github.com/brianvoe/gofakeit" rel="nofollow">http://godoc.org/github.com/brianvoe/gofakeit</a></p> <hr/>**评论:**<br/><br/>hariharan-uno: <pre><p>Just a suggestion. I think it would be nice if you make a folder <code>fake</code> inside the project and change the package name to <code>fake</code>. It would result in nice way (spoken english) of specifying things such as <code>fake.Name()</code> or <code>fake.Address()</code>.</p></pre>brianvoe: <pre><p>Ya i thought about that too. But to me it didnt stand out. But i agree. When i use it i just alias it to fake. import fake &#34;github.com/brianvoe/gofakeit&#34;</p></pre>TerriblementeCruel: <pre><p>That&#39;s nice! I would add UUID and SSN.</p></pre>brianvoe: <pre><p>Thanks. So it does have a UniqueId() and for ssn you could do Numerify(&#34;###-##-####&#34;). And that would replace # with random numbers. </p></pre>TerriblementeCruel: <pre><p>By UUID I mean <a href="http://en.wikipedia.org/wiki/Universally_unique_identifier" rel="nofollow">this</a>. It&#39;s useful for mocking data for DBs like Cassandra (UUIDv1 I believe) etc.</p></pre>autowikibot: <pre><h5> </h5> <h6> </h6> <h4> </h4> <p><a href="https://en.wikipedia.org/wiki/Universally%20unique%20identifier" rel="nofollow"><strong>Universally unique identifier</strong></a>: <a href="#sfw" rel="nofollow"></a> </p> <hr/> <blockquote> <p>A <strong>universally unique identifier</strong> (<strong>UUID</strong>) is an identifier standard used in <a href="https://en.wikipedia.org/wiki/Software" rel="nofollow">software</a> construction. A UUID is simply a 128-bit value. The meaning of each bit is defined by any of several variants.</p> <p>For human-readable display, many systems use a canonical format using hexadecimal text with inserted hyphen characters. For example:</p> <blockquote> <p><strong>de305d54-75b4-431b-adb2-eb6b9e546014</strong></p> </blockquote> </blockquote> <hr/> <p><sup>Interesting:</sup> <a href="https://en.wikipedia.org/wiki/Globally_unique_identifier" rel="nofollow"><sup>Globally</sup> <sup>unique</sup> <sup>identifier</sup></a> <sup>|</sup> <a href="https://en.wikipedia.org/wiki/Unique_identifier" rel="nofollow"><sup>Unique</sup> <sup>identifier</sup></a> <sup>|</sup> <a href="https://en.wikipedia.org/wiki/Rich_Salz" rel="nofollow"><sup>Rich</sup> <sup>Salz</sup></a> <sup>|</sup> <a href="https://en.wikipedia.org/wiki/Digital_object_identifier" rel="nofollow"><sup>Digital</sup> <sup>object</sup> <sup>identifier</sup></a> </p> <p><sup>Parent</sup> <sup>commenter</sup> <sup>can</sup> <a href="/message/compose?to=autowikibot&amp;subject=AutoWikibot%20NSFW%20toggle&amp;message=%2Btoggle-nsfw+cs2m2js" rel="nofollow"><sup>toggle</sup> <sup>NSFW</sup></a> <sup>or<a href="#or" rel="nofollow"></a></sup> <a href="/message/compose?to=autowikibot&amp;subject=AutoWikibot%20Deletion&amp;message=%2Bdelete+cs2m2js" rel="nofollow"><sup>delete</sup></a><sup>.</sup> <sup>Will</sup> <sup>also</sup> <sup>delete</sup> <sup>on</sup> <sup>comment</sup> <sup>score</sup> <sup>of</sup> <sup>-1</sup> <sup>or</sup> <sup>less.</sup> <sup>|</sup> <a href="http://www.np.reddit.com/r/autowikibot/wiki/index" rel="nofollow"><sup>FAQs</sup></a> <sup>|</sup> <a href="http://www.np.reddit.com/r/autowikibot/comments/1x013o/for_moderators_switches_commands_and_css/" rel="nofollow"><sup>Mods</sup></a> <sup>|</sup> <a href="http://www.np.reddit.com/r/autowikibot/comments/1ux484/ask_wikibot/" rel="nofollow"><sup>Magic</sup> <sup>Words</sup></a></p></pre>brianvoe: <pre><p>Ya I think i can do that. Ill put it on my list of todos.</p></pre>newimprovedoriginal: <pre><p>everything from chance.js</p></pre>brianvoe: <pre><p>Ya that looks like a great package. Ill definitely see if i can grab anything i missed. Thanks.</p></pre>dchapes: <pre><p>My first thought when seeing the title was to ask about <a href="https://golang.org/pkg/testing/quick/#Generator" rel="nofollow"><code>quick.Generator</code></a> support; but that wouldn&#39;t make sense with your API. Instead, perhaps include an example that mentioned <code>testing/quick</code> and implements <code>quick.Generator</code> on a simple larger type (e.g. you could show a &#34;Person&#34; struct with name, e-mail, etc fields could implementing <code>Generator</code> by calling <code>Name()</code>, <code>Email()</code>, etc functions to set individual fields).</p> <p>That actually does bring up an important issue. You should provide a way of using an alternate RNG instead of only using the global locking random source. Providing duplicate functions that take a <code>*rand.Rand</code> (or <code>rand.Source</code>?) argument may be too cumbersome. Perhaps use a package variable that callers can set?</p></pre>brianvoe: <pre><p>I like that idea. If someone one wanted a group of data i could populate a struct of information to return back to them. Person, Contact Info, Address, etc...</p> <p>Can you think of any other groups i can put together?</p> <p>In regards to your rand comment can you better explain? I wasnt able to follow.</p></pre>dchapes: <pre><blockquote> <p>In regards to your rand comment can you better explain? I wasnt able to follow.</p> </blockquote> <p>You seem to get your random numbers from a <a href="https://github.com/brianvoe/gofakeit/blob/3086b2457944092f58611b22afb958ec864fec35/misc.go#L49" rel="nofollow">call to <code>rand.Intn</code></a>. That uses the <code>rand</code> package&#39;s default source. That source is shared by all other uses of the basic <code>rand</code> functions (and does locking to allow to for concurrent use).</p> <p>This in inflexible in several ways. E.g. I can&#39;t substitute a different random number generator. I can&#39;t generate a repeatable series of fake data in a goroutine concurrent with other users of rand. Etc.</p> <p>That&#39;s why, as an example, <code>quick.Generator</code> takes a <code>*rand.Rand</code> argument to allow callers to provide their own RNG.</p></pre>bear1728: <pre><p>Have you seen other collections of similar sample data? You might consider incorporating those or adding to them. For example I saw one the other day: <a href="https://github.com/dariusk/corpora" rel="nofollow">https://github.com/dariusk/corpora</a></p> <p>They have foods for example which I didn&#39;t see in your API. There is also a great database of food/nutritional information at the USDA website.</p></pre>brianvoe: <pre><p>Haha food seems a little bit off the beaten path but if i have a solid data list to go off of i guess i would add anything. Just curious how far i go down that road. Cause you could do farm animals, types of birds, insects, mammals, cars, etc.. thats could get crazy.</p></pre>

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

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