Golang News http://golangnews.com Jobs, Code, Videos and News for Go hackers - everything about the go programming language Sun, 04 Feb 2018 20:23:00 +0000 Custom JSON unmarshaler for a GraphQL client In this post, I will tell a story of how I had to build a custom JSON unmarshaler for the needs of a GraphQL client library in Go. I'll start with the history of how everything started, build motivation for why a custom JSON marshaler was truly needed, and then describe how it was implemented. This is going to be a long journey, so strap yourself in, and here we go! 7 points posted by kenny https://dmitri.shuralyov.com/blog/25 3124 Fri, 19 Jan 2018 19:43:00 +0000 Running gofmt in Browser with 10 Lines of Code #gopherjs <p>I saw a message in <a href="https://golang.org/help/#slack" rel="nofollow" style="color: rgb(2, 117, 216);">Gophers Slack</a>&nbsp;#general chat that stood out to me:</p><blockquote style="margin: 0px 0px 16px; padding-right: 15px; padding-left: 15px; color: rgb(119, 119, 119); border-left-width: 4px; border-left-color: rgb(221, 221, 221); font-family: Go; font-size: 16px;"> <p>but running <code style="tab-size: 4; font-family: &quot;Go Mono&quot;; font-size: 13.6px; padding: 0.2em 0px; margin: 0px; background-color: rgba(0, 0, 0, 0.04); border-radius: 3px;">gofmt</code>&nbsp;in the browser is, um, hard</p></blockquote> <p>The context was that they had a 100%-client-side JavaScript application that produced some Go code, but the Go code wasn't <code style="tab-size: 4; font-family: &quot;Go Mono&quot;; font-size: 13.6px; padding: 0.2em 0px; margin: 0px; background-color: rgba(0, 0, 0, 0.04); border-radius: 3px;">gofmt</code>ed.</p> <p>"Wait a minute, that's not hard," I thought. "It's trivial! Getting <code style="tab-size: 4; font-family: &quot;Go Mono&quot;; font-size: 13.6px; padding: 0.2em 0px; margin: 0px; background-color: rgba(0, 0, 0, 0.04); border-radius: 3px;">gofmt</code>&nbsp;to run in the browser? I bet I could do it in 10 lines of code!"</p> 7 points posted by kenny https://dmitri.shuralyov.com/blog/24 2456 Wed, 02 Aug 2017 19:37:00 +0000 Rendering a Triangle with Apple's Metal API, using Go 4 points posted by kenny https://dmitri.shuralyov.com/blog/26 4144 Sun, 22 Sep 2019 09:54:00 +0000 Using method values to get rid of global variables 3 points posted by gopher https://dmitri.shuralyov.com/blog/19 2242 Tue, 23 May 2017 13:10:00 +0000