Is it practical to use Go for making autoinstall scripts like for example https://github.com/Kerwood/Rtorrent-Auto-Install/blob/master/Rtorrent-Auto-Install-4.0.0-Debian-Wheezy? Go as alternative to shell script. Worth it?
评论:
natefinch:
bobbafeftta:I think so. Checkout https://magefile.org - a makefile replacement using Go. Bash is ugly and the error handling is particularly atrocious. Error handling is Go's strength... you always know what commands can fail, and so it's easy to see where your script might fail and so you are forced to think about what to do in that situation.
An install script in go will definitely be a larger number of lines than it would be in bash... but it'll be a lot easier to read, and probably a lot less prone to bugs, since there's a lot less magic.
deusmetallum:Error handling is Go's strength... you always know what commands can fail
First time I've heard go's error handling summarised like this, I like it.
paul2048:Problem with using go for an install script is that it'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's nothing at the destination already.
With a bash script, at least most of that checking is done for you, and you're bringing tools together, rather than reinventing all of the tools.
You're getting downvoted but 1/ shell scripts are transparent 2/ shell scripts are simpler because that's what they were made for.
