<p>Hello, I just whipped up a simple port of Github's <a href="https://github.com/github/scientist" rel="nofollow">Scientist</a> and with heavy inspiration from the python port <a href="https://github.com/joealcorn/laboratory" rel="nofollow">Laboratory</a> (<a href="https://www.reddit.com/r/Python/comments/4615o4/package_for_carefully_refactoring_critical_paths/" rel="nofollow">here's the reddit post</a>). I call it <a href="https://github.com/lmas/labassistant" rel="nofollow">LabAssistant</a>. It's a really lightweight port, so it lacks most of the features found in the other projects. If it works any good for some future work of mine I'll go ahead and implement the other features too (pull requests works great too :D ).</p>
<p>It was mostly made for fun and to scratch an itch, but there's one or two projects of mine I need to do some refactoring on so I thought it would be interesting to try this new approach.</p>
<p>I'm posting <a href="https://github.com/lmas/labassistant" rel="nofollow">LabAssistant</a> to this sub mostly for fun too (I rarely advertise my own work), to see how that would affect the project, and for getting any sweet criticism on my code in general. I would gladly like to be shown any other alternative too!</p>
<p>Newb edit: Of course it helps if you post the actual link, dummy.</p>
<p>Edit2: formatting</p>
<hr/>**评论:**<br/><br/>dgryski: <pre><p>You should fix the layout of the repository so that the source code is at the top-level, and the example is in a sub-directory.</p>
<p>That way, <code>go get</code> will work as expected.</p>
<p>For more info, <a href="https://golang.org/doc/code.html#Organization" rel="nofollow">https://golang.org/doc/code.html#Organization</a></p></pre>giant_pollo: <pre><p>Thanks. I was afraid someone would comment on that. I've never been a fan of that official project layout, makes things feel too cluttered in the root directory for me. But I'll go fix it just for you :D</p></pre>010a: <pre><p>You need to go with that layout if you're writing a library (meaning no <code>main</code> function).</p>
<p>If you're writing an app, you can do whatever you want. </p></pre>giant_pollo: <pre><p>Could you explain why it's needed for libraries? I get it that it's good idea to follow the usual conventions when making a public library, but besides having a barely longer and less comfortable import path (with the <code>/src</code> at the end), I don't see any bigger problems with my original layout. The go tools still work just fine for me?</p>
<p>I have a faint memory of trying to research why, but I think I never found any good reasons and decided to just go with my own approach anyway.</p></pre>RandNho: <pre><p>To use a library, you include it by path and call functions with library name as prefix. </p>
<p>And your library isn't called src.</p></pre>giant_pollo: <pre><p>That's why the <a href="https://golang.org/ref/spec#Package_clause" rel="nofollow"><code>package</code></a> keyword exist, right? It shouldn't matter which directory the library files are stored in, as long as you import the correct path where they are found. </p>
<p>I'm sorry, I might be thick headed or something but I still don't see the need to keep the source files in the root dir.</p>
<p>Edit: fixed the link.</p></pre>barsonme: <pre><p><code>goimports</code> breaks if the package's name is not the same as the last segment of the import path, and it's annoying. Renaming a package import (e.g., <code>foo "github.com/user/bar</code>) is annoying as well.</p></pre>giant_pollo: <pre><p>Hmm alright, that makes more sense. I personally haven't had any problems with the go tools, so I wasn't entirely sure my old layout was messing up something for someone else.</p>
<p>In any case, thanks for helping out guys.</p></pre>barsonme: <pre><p>you're welcome. hope i didn't sound mean with all the 'annoyings', lol.</p></pre>XANi_: <pre><p>You might want to read a bit how godoc and templates work.</p>
<p>You can do neat tricks with it, like code template that gets compiled and checked with normal tests (and included in relevant docs section), so if you accidentally break it <code>go test</code> will catch it</p></pre>giant_pollo: <pre><p>I'm familiar with godoc and have used templates a lot for my web apps.</p>
<p>Didn't know you could test the code examples in the docs though, thanks! Also, is that a friendly wink at me to get started on the tests sooner? ;)</p></pre>XANi_: <pre><p>Look at <a href="http://goconvey.co/" rel="nofollow">http://goconvey.co/</a> especially if you use 2 monitors.</p>
<p>You just run it and it automatically runs test whenever any file on disk changes. It has also few nice builtins to make writing tests easier, like a bunch of asserts for various data types.</p></pre>giant_pollo: <pre><p>Yep, I've used it in the past. It's pretty sweet, but I remember having had troubles getting a coverage report from it. It's probably easier to use now a days.</p></pre>
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889
- 请尽量让自己的回复能够对别人有帮助
- 支持 Markdown 格式, **粗体**、~~删除线~~、
`单行代码`
- 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
- 图片支持拖拽、截图粘贴等方式上传