Hacker News new | past | comments | ask | show | jobs | submit login
Ask HN: Is there a project based book or course on Go for writing web APIs?
131 points by lignux on Aug 15, 2019 | hide | past | favorite | 31 comments
I am in the process of learning go and i think something like Michael Hartl's Rails Tutorial would fit nicely for me right now. I've looked at usegolang.com but i am not sure it has emphasis on API's. Any suggestions?



I saw this recommended on HN the other day which covers that ground. Have not done it myself so this is a pointer rather than a recommendation: https://buildsaasappingo.com/


Hi, I'm Dominic the author of Build SaaS apps in Go, thank you for sharing the book website. If there's any questions please do not hesitate to ask. Here's a 25% discount direct buy link if that can help.

https://store.dominicstpierre.com/build-saas-apps-in-go?coup...


That url...


Thanks, great suggestions in this thread. I ended up buying this


In https://www.manning.com/books/go-web-programming, they start with server-side rendered views and then dedicate the whole last part of the book to web services. It's pretty good!


At first I thought book was in Slovenian or something, until I realized there was some DOM level decryption happening. I simultaneously wanted to open it up to figure out how it worked and close the page because it was so broken and counter to the supposedly simple idea of displaying words on a page that it infuriated me.

I hope the book is good, but I guess I'll never know.


They have something like a 5-minute per-24h free preview of the entire book. It confused me too, the first time I came back to a tab I’d left open for a book I wanted to check out. Ultimately I wasn’t able to get a good idea of the book quality, so I never purchased a book from them, but maybe it works for some people.


Why is it infuriating? It gives you a preview before you have to purchase the book. What's wrong with that? If anything, it's better than some publishers.


What do you mean you'll never know? Your parent comment said it was pretty good. A single data point is not authoritative, but it shows a pretty solid trend toward "pretty good."

You already know the book is pretty good, you just wanted to complain about DRM, I suspect. I hope that's not the case.


Eating rotten carrots is pretty good.

A single data point is not authoritative, but my comment shows a pretty solid trend toward "pretty good." I expect you'll run out to go find some rotten carrots to eat now?


It's funny that you think that reading a book of unknown quality and eating a rotten carrot, which is guaranteed to be rotten, are comfortable in any way whatsoever.


I'm working through Let's Go! by Alex Edwards right now, it's not specifically focussed on APIs but the book guides you through building a web application in Go. My experience so far has been very positive.

https://lets-go.alexedwards.net/


well the structure is so so and everything is in package main in every file in every project.


If you're coming from Ruby, you might like Gin[0].

I'd also recommend learning to write web APIs with the standard library so you know the primitives. Writing Web Applications[1] on golang.org covers the basics.

[0] https://github.com/gin-gonic/gin

[1] https://golang.org/doc/articles/wiki


I've had a bad experience with Gin and when asking about alternatives in a local Go meetup I was given the advice to use https://github.com/go-chi/chi or gorilla/mux.


Could you go into more detail about this? I'm using Gin currently and would like to avoid any potential landmines if possible.


I've used Gin for several small to medium projects without too much difficulty. I think Gin is a good way to learn quickly since its ecosystem introduces you to a lot of the pieces you will need. Personally, I don't do enough web development to grow out of it, since my web related projects are not a primary focus.

One thing to note is that Gin's Context is not the standard context.Context, which some find problematic. Most (vocal?) Gophers prefer sticking with the standard library and Gorilla.


It's true that Gin's Context is different from context.Context, but I don't see how that's inherently problematic.


I didn't like Gin because they don't let you use whatever routes you want. Something like /:category/:product and /user/:name (notice no ":") is not admissible because ":category" in the first route clashes with "user" in the second route (wtf?)


I've definitely been bitten by this and the work around is pretty hacky.


It's not super helpful to recommend alternatives without providing any reasoning. I've used all of the above and Gin has been fine for me for standard HTTP APIs. The exception is web sockets, but you can use gorilla/mux in conjunction with with Gin for that.


chi is nice in that it is just a router, not a whole framework. It uses the existing http middleware idioms from the standard library. If you want to route some incoming requests by url to handlers in go code, chi is pretty reasonable.

context: working in large org building backend services that speak to other backend services via various crappy http / rest / soap APIs.



https://github.com/quii/learn-go-with-tests is a great resource. It has some relevant sections to writing Web APIs.


Not a tutorial but here's a project that goes over the architecture of building one using best practices. You may not need everything in it (so take from it what you will), but it should be helpful:

https://github.com/ardanlabs/service


I got an email about this book the other day: https://gumroad.com/l/kjHSa

From the writer of this blog: https://www.thepolyglotdeveloper.com/



Excellent thread! Thanks all. Also in the process of getting GOing on Go. >:) (Yes, I am a geeky pun guy)


Haven't read through it myself, but I think it's noteworthy and it wasn't mentioned here yet:

https://astaxie.gitbooks.io/build-web-application-with-golan...


Second this, I've used this as a resource for ramping up medium-experience web developers in Go. It's great because it sticks to the `net/http` basics, and is fairly concise and blunt.


If you really want to get a good understanding of Go and web, I would work through building your own router see:

https://vluxe.io/golang-router.html

For an example




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: