🏒 Lucian Marin Played around with go language and martini. Displaying a template is so hard. You have to write it to a buffer then convert the buffer to string. Then tell martini to return the string as your page. It's so easy to do this with php, even python but they are slower. Oh well, we can't have speed and simplicity at the same time.
Login or register your account to reply
Nkrs Martini is not the idiomatic way to do it: it relies heavily on reflection which makes the code less safe and more error prone. The more idiomatic way is to make a template object, then call the Exec method on it while passing an http.ResponseWriter as the first argument, which saves you the trouble of making a temporary byte buffer and casting it to a string. There are other libraries that provide easy URL routing similar to what Martini is doing on top of this approach; Goji is my personal favorite (goji.io).
7y, 21w 1 reply
🏒 Lucian Marin I don't like Goji either. I think the best way is using the builtins: http.NewServeMux() and http.ListenAndServe(). I also found some explanations here: alexedwards.net/bl...
7y, 21w reply
Martijn Speed it up even more: write it all in assembly!
7y, 21w 2 replies
🏒 Lucian Marin Assembly doesn't understand web servers.
7y, 21w 1 reply