Hi Everyone. I've been trying out Go for small projects for a month now, but when looking at my code I'm under the impression that I'm not using efficient patterns and making the most out of what Go gives (forgetting to use pointers, scarcely using anonymous functions).
I'm looking for an inspiration based on well-known Go projects which are not as huge and complex as e.g. moby and perhaps not as low-level as the ones in standard lib. If they are well documented that would be a plus. Resources like blogs where someone way smarter than me goes from 0 to something more than main package script would be awesome too. If you have a project like that I'd love to see it too!
评论:
leaf_bebop:
shovelpost:Standard libraries.
but when looking at my code I'm under the impression that I'm not using efficient patterns and making the most out of what Go gives (forgetting to use pointers, scarcely using anonymous functions).
Read Effective Go many times.
Read CodeReviewComments.
Use tools like
golint
,go vet
and gometalinter.Post specific examples of things you are not sure about so we can help.
Don't worry and just keep coding.
zacgarby:Don't worry and just keep coding.
This. Premature optimization is never a good thing. If your code works correctly and runs without unreasonable delay, who cares what it looks like under the hood? Tons and tons of ugly code out there making $$$$$$$$$.
qu33ksilver:Most of the standard libraries aren't that low level.
pom_bear:forgetting to use pointers
A lot of people that using pointers makes your program "cool" and you feel like a real "software engineer".
In practice, pointers do not give the best performance always. Run
gcflags="-m -m"
and see for yourself. Sometimes, it is better to put things on stack. The stack is fast and cache-friendly. As always YMMV.
s-kostyaev:Not sure if this is exactly what you're asking for but check out gophercises.com
peterbourgon:https://github.com/cweill/gotests for example.
I think https://github.com/oklog/oklog is quite well-done and easy to read, but I’m definitely biased.
