Hacker News new | ask | show | jobs
by danielvf 2943 days ago
Yes. One of go's strengths is that there are very few tricks and the language is heavily biased towards easy reading over compact code.
2 comments

Until the day where you discover you need to keep track of the difference between a nil interface and a non-nil interface acquired on a nil pointer...
I'm also a Go noob. I tried writing a basic web server in Go yesterday to handle Twilio SMS callbacks. Trying to inspect the requests I was receiving was such a pain, I gave up and wrote the server with Sinatra. Am I missing something that's making this more difficult than it should be?
You were probably missing something but we all had to start someplace. :)

I'm not a Go expert by any stretch of the imagination and I can tell you that almost everything you would want to know about a given request is exposed through the request object passed to your handler if you are using the standard Go http stuff.

I love Go specifically for this purpose. I wrote a simple server doing exactly that with Twilio: https://github.com/dang3r/jenophone/
Thanks! I'll check it out.
`httputil.DumpRequest`[1] may have been helpful in this situation. If you're on a mainstream platform, the Delve debugger is fairly reasonable these days too.

[1]: https://golang.org/pkg/net/http/httputil/#DumpRequest

I'd say you were missing https://github.com/k0kubun/pp but the other tricky thing is that you can read a http.Request.Body only once unlike in Ruby. I usually use ioutil.ReadAll for that.
That's incorrect. Both languages require you to rewind the reader before you can read it a second time. You're probably just used to higher level frameworks like Sinatra or Rails that take care of it for you.