If you want to update all dependencies and packages within your project then the simplest way is to use the go get command which handles it all for us. Go modules (go mod) will handle most of the versioning of these packages, so deploying and sharing the project will keep the same package versions.
We’ve added the command and explination below.
1
go get -u ./...
go get
This is the base command to get packages in Go.
-u
This flag says packages should update. We’ve added the official explination below.
The -u flag instructs get to update modules providing dependencies
of packages named on the command line to use newer minor or patch
releases when available.
Edd is a PHP and Go developer who enjoys blogging about his experiences, mostly about creating and coding new things he's working on and is a big beliver in open-source and Linux.
Deploy a Go App to Railway
–
After using Heroku for many years, I’ve recently taken a look into Railway as an alternative hosting platform for various side projects. These projects are often written in Go (of course!) so I thought I’d write a quick guide on how to setup a new project - the good news is, it’s easy!
1) Get an Account It’s easy to setup, the link on their home page will help you.
Get/Set HTTP Headers in Go Request
–
HTTP headers, we all need ’em 😉
Here’s how you can get and set these headers within your Go requests. These include request coming into your router handlers and requests you are sending out to other systems through net/http. This can be thought of as being the same as reading headers from a request and creating new ones.
First we’ll start with reading them from the request.
Change Go Version in Mod
–
Picking up an old Go project, we wanted to update the desired version it should run on (mainly so when we deployed to our live systems it would use this version too). To do this, we updated the version within the go.mod file - the file which keeps track of both versions and packages used by the project.
We used the command below: