
Ask HN: Is there a project based book or course on Go for writing web APIs? - lignux
I am in the process of learning go and i think something like Michael Hartl&#x27;s Rails Tutorial would fit nicely for me right now. I&#x27;ve looked at usegolang.com but i am not sure it has emphasis on API&#x27;s. Any suggestions?
======
petercooper
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/](https://buildsaasappingo.com/)

~~~
dstpierre
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...](https://store.dominicstpierre.com/build-saas-apps-in-
go?coupon=TWITRLIMITED25)

------
ryanstreur
In [https://www.manning.com/books/go-web-
programming](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!

~~~
totalthrowaway
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.

~~~
naikrovek
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.

~~~
freehunter
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?

~~~
naikrovek
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.

------
sequence7
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/](https://lets-go.alexedwards.net/)

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

------
bndw
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](https://github.com/gin-gonic/gin)

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

~~~
PhilippGille
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](https://github.com/go-chi/chi) or gorilla/mux.

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

~~~
biomcgary
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.

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

------
ValentineC
I like Asta Xie's "Build Web Application with Golang" GitBook:
[https://astaxie.gitbooks.io/build-web-application-with-
golan...](https://astaxie.gitbooks.io/build-web-application-with-golang/en/)

(Repo: [https://github.com/astaxie/build-web-application-with-
golang](https://github.com/astaxie/build-web-application-with-golang))

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

------
navd
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](https://github.com/ardanlabs/service)

------
dustinmr
I got an email about this book the other day:
[https://gumroad.com/l/kjHSa](https://gumroad.com/l/kjHSa)

From the writer of this blog:
[https://www.thepolyglotdeveloper.com/](https://www.thepolyglotdeveloper.com/)

------
segmondy
[https://gowebexamples.com/](https://gowebexamples.com/)

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

------
PhilippGille
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...](https://astaxie.gitbooks.io/build-web-application-with-golang/en/)

~~~
gen220
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.

------
tmaly
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](https://vluxe.io/golang-router.html)

For an example

