Go standard packages examples repository

Back when I first started learning Go, I decided to try to power through a lot of Go’s standard package library.

Some examples I learnt from the Go package’s website, some from Googling around, but a lot I had to learn myself since there weren’t adequate resources back then, so in case anybody else wants to try to learn as much of Go’s standard package library as I went through back then, I hope that this helps anybody that wants to learn Go: https://github.com/radovskyb/go-packages.

I will eventually go through and make sure all of the errors have been checked and that the code in all of the examples are more properly documented and idiomatic, since most of it was just for a personal learning experience back then, so feel free to let me know if anything needs to be changed.

In the future, I’ll probably go through and post a few of my other folders containing large amounts of Go code and examples that I’ve worked on since I started learning Go, but for now I think the above should cover a lot for most beginners.


Update: All errors that needed handling should now be handled (unless I’ve missed anything).


Update: Added a small example for the go standard package which includes a few functions from the packages go/ast, go/token, go/parser and go/printer.

If anybody would like any other packages added, since there are still a handful that I haven’t touched on in the repository yet, or even if you would just like more complex examples for any of the other packages, feel free let me know so we can make Go even easier to learn :slight_smile:

Update: Added a tiny example for using the context package with context.WithCancel to show how to avoid leaking goroutines. I will soon add examples for context.WithTimeout and context.WithDeadline and context.WithValue etc.

As an aside, if anybody would ever like to contribute to go-packages, just submit a pull request :slight_smile:

I’m also considering changing the name to something more like go-packages-examples, any other ideas?

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.