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:
1
go mod edit -go=1.19
This then means the go.mod file is updated to look like this:
1
2
3
4
5
6
7
module myproject
go 1.19
require (
... your packages ...
)
Heroku
To further this, if you’re deploying to Heroku, you can add a specific directive to the go.mod to set the Go version.
So it becomes this:
1
2
3
4
5
6
7
8
module myproject
// +heroku goVersion go1.19
go 1.19
require (
... your packages ...
)
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.
Update All Go Packages in Your Project
–
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.
Install Latest Version of Go (Linux/OSX)
–
This article describes how to install the latest version of Go (golang). It also helpfully updates itself by pulling the latest version numbers directly, so you don’t have to go and dig out the latest version each time they release a version (yay!) - just copy and paste away. For more info, try their installer docs.