Hacker News new | ask | show | jobs
by icey 4850 days ago
I had the same problems when I first started learning the language, and while I'm certain I've got a lot more to learn I found that making a habit of reading lots of source code made a huge difference.

After a little while you start thinking about "can this code be clearer? Are the intentions obvious?" and that makes the code much easier to write.

Go is incredibly easy to refactor, so instead of worrying about being exactly right, you can focus on "is this easy to reason about?". My experience has been that this process will get you very close to idiomatic code on its own.

1 comments

I'm not so much frustrated about being exactly right at a high level, since I am experienced enough with other languages to get the general architecture down correctly. It's more like "How do you declare a slice of channels of channels of ints? Do you make() it or not? If you want to pass a channel, do you pass a pointer or not? How do you pass and reference a pointer? Do you use make in the outermost scope? How do you iterate over a channel but still handle a close?"

It's stuff like that, things I already know how to do in other languages but whose syntax eludes me in Go. I think all I can do is power through it until I gain some familiarity, though. Good thing the people in the IRC channel are amazingly helpful.