Avatar ·

How to properly update third-party packages in Go: a guide for beginners

Hello everyone! I just started learning Go and encountered a problem with updating third-party packages. The documentation mentions `go get -u`, but I'm not sure I'm doing everything correctly. I have a project where I use the `github.com/gin-gonic/gin` package for a web server. I installed it via `go get github.com/gin-gonic/gin`. Now I want to update it to the latest version because there's a bug in the old version. I tried running `go get -u github.com/gin-gonic/gin`, but after that some functions in my code stopped working — apparently due to API changes. Question: how to properly update packages without breaking the project? Do I need to update all dependencies at once or only specific ones? How to roll back an update if something goes wrong? And what to do with `go.mod` and `go.sum` after updating?