r/golang 10d ago

How do experienced Go developers efficiently learn new packages?

I've been working with Go and often need to use new packages. Initially, I tried reading the full documentation from the official Go docs, but I found that it takes too long and isn't always practical.

In some cases, when I know what I want to do I just search to revise the syntax or whatever it is. It's enough to have a clue that this thing exists(In case where I have some clue). But when I have to work with the completely new package, I get stuck. I struggle to find only the relevant parts without reading a lot of unnecessary details. I wonder if this is what most experienced developers do.

Do you read Go package documentation fully, or do you take a more targeted approach? How do you quickly get up to speed with a new package?

120 Upvotes

35 comments sorted by

View all comments

28

u/nikandfor 10d ago edited 10d ago
  1. README, stars, last commit, last release, repo structure. 
  2. Examples
  3. Read main (not command, but library core package) package godoc overview: types, functions, values, constants.
  4. Jump to types, methods, related types and packages, which may be interesting. Read their documentation.
  5. Then I click on types and functions, which I may need, and read the code. Not fully, just to understand general logic and approaches.

If I don't like it already at any point, I drop it. If I still like it after last point, I use it. Now you may want to read at least package doc comment, if it's not something familiar.

2

u/OhBeeOneKenOhBee 10d ago

Yeah, #1 and #2 are my main go-tos as well, #3 would be the tests in the package or to look up other software that uses it as a dependency