Autoinstall scripts in Go

polaris · · 499 次点击    
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
<p>Is it practical to use Go for making autoinstall scripts like for example <a href="https://github.com/Kerwood/Rtorrent-Auto-Install/blob/master/Rtorrent-Auto-Install-4.0.0-Debian-Wheezy" rel="nofollow">https://github.com/Kerwood/Rtorrent-Auto-Install/blob/master/Rtorrent-Auto-Install-4.0.0-Debian-Wheezy</a>? Go as alternative to shell script. Worth it?</p> <hr/>**评论:**<br/><br/>natefinch: <pre><p>I think so. Checkout <a href="https://magefile.org" rel="nofollow">https://magefile.org</a> - a makefile replacement using Go. Bash is ugly and the error handling is particularly atrocious. Error handling is Go&#39;s strength... you always know what commands can fail, and so it&#39;s easy to see where your script might fail and so you are forced to think about what to do in that situation.</p> <p>An install script in go will definitely be a larger number of lines than it would be in bash... but it&#39;ll be a lot easier to read, and probably a lot less prone to bugs, since there&#39;s a lot less magic.</p></pre>bobbafeftta: <pre><blockquote> <p>Error handling is Go&#39;s strength... you always know what commands can fail</p> </blockquote> <p>First time I&#39;ve heard go&#39;s error handling summarised like this, I like it.</p></pre>deusmetallum: <pre><p>Problem with using go for an install script is that it&#39;s very long winded. For instance, if you wanted to do a cp or mv, you have to write a lot of code to check the files exist, and that there&#39;s nothing at the destination already.</p> <p>With a bash script, at least most of that checking is done for you, and you&#39;re bringing tools together, rather than reinventing all of the tools.</p></pre>paul2048: <pre><p>You&#39;re getting downvoted but 1/ shell scripts are transparent 2/ shell scripts are simpler because that&#39;s what they were made for.</p></pre>

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

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