<p>Next week I'm doing a talk at a local Go users group, targeted at newbies. The idea is to demonstrate "writing a go project from scratch", in the span of ~45 minutes. </p>
<p>I thought of starting from a really blank workspace and writing the project live. But I might not risk it and just show the code evolving on slides, keeping a live version of it ready for live modifications on a separate window. </p>
<p>But anyway I'm wondering about a good project to demonstrate a taste of writing a functional Go application, that will be something beyond the obligatory "hello world http handler". I don't want to delve into more sophisticated things like advanced concurrency, but I do want it to be interesting.</p>
<p>Giving the time limit, here are a couple of ideas I had:</p>
<ol>
<li><p>A simple CRUD data store with an http API. I can also demonstrate the power of interfaces by abstracting the data store and then replace a map[] based implementation with a filesystem based one. And I can also demo the testing framework.</p></li>
<li><p>A very simple http load generator. I'm afraid it will be diving too deep into concurrency patterns for total newbies. </p></li>
</ol>
<p>I had a few more that weren't as interesting or too complicated for this.</p>
<p>If anyone has ideas for similar projects for this time limit, I'd love to hear them.</p>
<hr/>**评论:**<br/><br/>genesem: <pre><p>I think you would show them the ease of using the live-reload tools like gin-reload and\or maybe revel (which has built in live reload).
This might sounds strange, but using this tools gives to newcomers the feeling of usage server side script for programming and users will not afraid compiling nature of the go. </p></pre>dvirsky: <pre><p>Hmm... I was actually thinking about avoiding frameworks completely, and at most demonstrating a simple 3rd party go get for a very specific task (uuid generation perhaps?). </p></pre>IntellectualReserve: <pre><p>An app that pings every valid IPv4 address and logs which addresses respond within 100ms.</p>
<p>Should be a good excuse to use goroutines. </p></pre>baudvix: <pre><p>not the best idea. i had a quiet similar task as an assignment at my university. we did it only with 50.000 ipv4 addresses. after a few test runs my account was suspended, because i pinged some c&c servers. So be careful from where you run this program</p></pre>IntellectualReserve: <pre><p>Interesting. Thanks for sharing. </p></pre>dvirsky: <pre><p>heh, I'm doing this talk inside a Google campus (not in the US). Maybe not the best idea indeed :)</p></pre>baudvix: <pre><p>I'm not sure how much work it is, but the basic idea would be to write a simple http mpd client and make it accesible over the wlan.</p>
<p>add a few songs < 10 to the mpd library and let them add these to the queue.</p>
<p>now you can collect a few ideas how to improve this program. i.e. voting, add songs directly from youtube and co.</p>
<p>show them how to implement it with a concept like a priority queue and tell them, that they can do this on a raspberry pi and have their own home party queue. </p></pre>dvirsky: <pre><p>nice idea. one of my original ideas was a rudimentary web crawler, but with the html parsing it might be out of scope, this might be a simplified version of the same principle.</p></pre>asbjxrn: <pre><p>I just did a small POC that I thought was kinda cool. (I might be a bit biased :))</p>
<p>One tiny javascript snippets listening on a websocket and creating notifications when data comes in.
One server listening for incoming alerts and pushing json to the websockets.
One binary that can be used from commandline to send alerts to the http server. </p>
<p>Reasonably small setup and you have a small easily deployed binary that can be used by any script that needs to send alerts to a dashboard or something.</p>
<p>It can show off networking, http templates, json marshaling, channels etc.</p></pre>twek: <pre><p>The biggest problem I'm having with golang is figuring out the best practices for workspaces. Ie gopath and etc. Probably doesn't help that I'm using the intellij plugin and creating projects from scratch isn't well documented. </p></pre>dvirsky: <pre><p>yeah, last I've checked it doesn't play well with GOPATH, but maybe that's changed. I think I'm going to demonstrate it on LiteIDE, starting from a fresh GOPATH.</p></pre>twek: <pre><p>It seems to work ok if you follow the instructions on <a href="https://golang.org/doc/install" rel="nofollow">https://golang.org/doc/install</a> and make sure you install to /usr/local/go oh, and you MUST put </p>
<pre><code>export PATH=$PATH:/usr/local/go/bin
export GOPATH=<path to go path>
</code></pre>
<p>in your ~/.profile not ~/.bashrc</p></pre>
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889
- 请尽量让自己的回复能够对别人有帮助
- 支持 Markdown 格式, **粗体**、~~删除线~~、
`单行代码`
- 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
- 图片支持拖拽、截图粘贴等方式上传