Created
October 26, 2016 16:40
-
-
Save derlin/3c6b1c82dbae858c14d1b5d46f9c6468 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
import ( | |
"io/ioutil" | |
"encoding/json" | |
) | |
struct Something { | |
i int `json:"i"` | |
s string `json:"name"` | |
} | |
func readFromFile(filename string) []byte { | |
raw, err := ioutil.ReadFile(filename) | |
if err != nil { | |
// do something | |
} | |
return raw | |
} | |
func decode(bs []byte) Something { | |
var s Something | |
json.Unmarshal(bs, &s) | |
return s | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment