Hey people,
I am coming from a JavaScript background (mostly Node) and fall in love with Go when I first experimented with it. As I developed my first API, it felt strange on many places, since I am still having a NodeJS mindset and it's hard to wrap my head around best practices in Go. My Code is on GitHub over here
https://github.com/gruberb/firemarksBackend, and I would like to ask a few questions:
- When I register a new user, I want to return the REST call with the just created one, but without the password. So I far I found that I should create a PrivateUser and a PublicUser model ( the one with password hash and one without it when it's getting exposed). Is this right? Is there a better way of doing this?
- It feels strange after reading a lot about interfaces and composition, to actually have models in Go. I tried to create models, but it feels like I am copying JavaScript with a different syntax. How would one create proper models in Go without having inheritance?
I would be happy to get pointed to some guidance (I've read a lot, but it still super hard to actually implement this exact type of application). Go web application examples are fullstack examples with serving HTML as well, what I want to use Go for is a web application backend (with Microservices in the end).
I appreciate you looking at my code and answer a few questions, or just point me in the right direction :)