Skip to content

Instantly share code, notes, and snippets.

@derlin
Created October 26, 2016 16:40
Show Gist options
  • Save derlin/3c6b1c82dbae858c14d1b5d46f9c6468 to your computer and use it in GitHub Desktop.
Save derlin/3c6b1c82dbae858c14d1b5d46f9c6468 to your computer and use it in GitHub Desktop.
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