Skip to content

Instantly share code, notes, and snippets.

@winks
Last active August 2, 2017 09:45
Show Gist options
  • Save winks/c20b9c9e40101326148d00e35744b772 to your computer and use it in GitHub Desktop.
Save winks/c20b9c9e40101326148d00e35744b772 to your computer and use it in GitHub Desktop.
package main
import "encoding/json"
import "strings"
import "fmt"
type Payload struct {
User string
}
func asdf() {
decoder := json.NewDecoder(strings.NewReader("{\"User\":\"asdf\"}"))
var p Payload
err := decoder.Decode(&p)
fmt.Printf("%s\n", err)
fmt.Printf("%s\n", p.User)
}
// %!s(<nil>)
// asdf
// http://imgur.com/a/8NqZf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment