Last active
August 2, 2017 09:45
-
-
Save winks/c20b9c9e40101326148d00e35744b772 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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