Comment by nemo1618
11 years ago
IMO, the author's "copy data to stdout" example betrays a lack of language understanding. Here's a more idiomatic version: http://play.golang.org/p/ZWatRuj3Q_
11 years ago
IMO, the author's "copy data to stdout" example betrays a lack of language understanding. Here's a more idiomatic version: http://play.golang.org/p/ZWatRuj3Q_
Plus given Go's focus on external dependencies, a common task like reading commandline parameters can (and should) be done with a library that solved that problem for you already - don't reinvent the wheel, and such.
Thanks! I'm just learning go (started last night), but I couldn't believe there wasn't a better way. It felt like a straw man example.
Kind of code golfing it: http://play.golang.org/p/s53zQrE0ei
That's definitely shorter, but I would hope that isn't considered the most shining example of non-obfuscated code. :)
(For code golf, though, it's just fine.)
It's actually very simple code, if you're at all familiar with go. That's probably what I would have written just by sitting down at the computer to do so for work.
Yep, that's what I would have written.
What happens when copy fails? Don't worry I already know.