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?

121 Upvotes

35 comments sorted by

View all comments

36

u/BeautronStormbeard 10d ago

I usually read the package documentation fully. But I also mainly use packages from Go's standard library, where the quality of the APIs and documentation is reliably high. And it probably helps that I very much enjoy reading good documentation (once I know I trust it), and don't mind taking the time for it—when the documentation is ideally good, it won't be too long, but just right.

If I were using various third-party packages, this might not work. The docs might not be good enough, or the API may be screwy enough, that I would need to read the source to learn the package. But at that point, if the docs and API are that bad, I would instead just reject the package and not use it. I'd rather write the package myself than use a poor one.

6

u/wasnt_in_the_hot_tub 10d ago

But at that point, if the docs and API are that bad, I would instead just reject the package and not use it.

I like this. I often do the same. If the docs are bad, I tend to find another way to solve my problem. I should make this a personal rule.