Gosubs is an roject aimed at developing and simulating a subscription system for user subscriptions with delivers content via email, with each message formatted as a PDF for a professional and easily accessible presentation.
In this project I want to really know how concurrency works in go with goroutine (and what’s the benefit of it) by building a dummy “subscription” system. This project makes me know that concurrency is very good for process that takes time. I simulate the long process in generating pdf to make a comparison. Something like this
func generateManualPDF(user data.User, plan data.Plan) *gofpdf.Fpdf {
// ... pdf setup
time.Sleep(5 * time.Second)
// the rest of code
}
Lesson learned:
- Dont ever use concurrency as first approach. Synchronous code is more readable and easy to refactor
- Use it very carefully because concurrency tools (sync.Waitgroup, channels, etc) has many traps & gotchas
Never use templates for frontendjust kidding. Templates is good, just need more setup and boilerplate code
Also this is my first time using mailhog as email server. It’s a great tool for mocking email server.
List of libraries that i used