Solving the "undefined: sql.NullTime" Error in Golang on Heroku for North East Developers
Background: Modifying a LINE Bot and Replacing MongoDB with PostgreSQL
In a recent project, a developer from Northeast India was modifying a LINE Bot and replacing MongoDB, which is no longer supported by Heroku, with PostgreSQL. The goal was to add free PostgreSQL, but the developer encountered some problems.
Challenge: Using Go-PG with PostgreSQL on Heroku
The developer chose the Go-PG package for the project but found that it could compile locally but crash when deployed to Heroku. The error was related to the undefined `sql.NullTime`.
Solution: Upgrading Go Version to Go 1.13 or Higher
After researching the issue, the developer found that the solution was to upgrade the Go version to Go 1.13 or higher. The developer upgraded the local Go version to 1.17.2, but Heroku still used Go 1.12.
Workaround: Specifying Go Version in go.mod File
To force Heroku to use a newer version (> Go 1.12), the developer had to specify the Go version in the go.mod file. By changing the goVersion to Go 1.17, the developer was able to use the latest version of Go 1.17.2.
Relevance to North East Region and Broader Indian Context
The experience of this developer is relevant to North East developers who are using Golang and Heroku for their projects. It highlights the importance of understanding how Heroku works with Go modules and how to specify the Go version in the go.mod file to avoid errors.
Reflections and Future Directions
This incident serves as a reminder for developers to always double-check their dependencies and configurations when deploying their projects to Heroku. It also emphasizes the importance of staying updated with the latest versions of the tools and libraries they are using.
In the future, developers can expect to see more improvements in Go-PG and Heroku's support for Go modules, making it easier for developers to use PostgreSQL with Golang on Heroku.