←back to thread

131 points apta | 9 comments | | HN request time: 1.036s | source | bottom
1. nemo1618 ◴[] No.9266433[source]

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_

replies(6): >>9266451 #>>9266492 #>>9266537 #>>9266549 #>>9266585 #>>9274007 #
2. QuercusMax ◴[] No.9266451[source]

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.

3. Cthulhu_ ◴[] No.9266492[source]

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.

4. zoips ◴[] No.9266537[source]

Kind of code golfing it: http://play.golang.org/p/s53zQrE0ei

replies(1): >>9266690 #
5. NateDad ◴[] No.9266549[source]

Yep, that's what I would have written.

6. ◴[] No.9266585[source]
7. sounds ◴[] No.9266690[source]

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.)

replies(1): >>9267323 #
8. NateDad ◴[] No.9267323{3}[source]

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.

9. he_the_great ◴[] No.9274007[source]

What happens when copy fails? Don't worry I already know.