Health tracking API in Go

Several people have been talking about Go for a while. I’ve never felt the need to learn it, but today one video caught my attention. A sudden wave of FOMO caught me, and I decided to try and learn it via a quick project.

Considering how much the health world inspires me — and yes, I’ll still be working on Healti in the future — I thought it would be nice to build a health-related API to just get my hands dirty with this technology.

Go is praised as an easy-to-read language, with strong concurrency support, and of course static typing. Its syntax looks a bit different compared to the other popular languages I know, but I agree with its readability. Not being used to dealing with memory, I didn’t find the pointer notations and operators that straightforward, but still kind of easy to catch up on.

That said, I had the pleasure to use some of the integrated modules from the (rich) standard library, GORM to interact with the database, Gin as the backend framework, Gorilla for the WebSocket implementation, and GoDotEnv for environment variables management.

As of now, these are the features the project has:

  • user registration and authentication
  • health-related journaling
  • exercise and nutrition logging (to be added)
  • WebSocket-based reminders (to be completed)

While, since it is a backend project, these are the available endpoints:

  • /register, /login (for registration and authentication)
  • /journal, /journal/entries, journal/:id (for journaling operations)
  • /exercise/entries, /exercise/:id (for exercise logging, to be added)
  • /nutrition/entries, /nutrition/:id (for nutrition logging, to be added)
  • /reminders, /reminder/:id (for reminders, to be added)

You can check out the complete code at github.com/vtfrc/go-health.

While this is just a quick experiment, I’ll add the remaining pieces. I tend to lean towards batteries-included frameworks, but I like Go and I’m definitely going to keep learning it.