Skip to content

Instantly share code, notes, and snippets.

@grapswiz
Last active December 16, 2015 02:39
Show Gist options
  • Select an option

  • Save grapswiz/5364076 to your computer and use it in GitHub Desktop.

Select an option

Save grapswiz/5364076 to your computer and use it in GitHub Desktop.
Read config json file sample for gae/go
application: gotwiggle
version: 1
runtime: go
api_version: go1
handlers:
- url: /.*
script: _go_app
{
"Token": "ff",
"Secret": "fff"
}
package twitterSample
import (
"io/ioutil"
"encoding/json"
)
type Credentials struct {
Token string
Secret string
}
func loadFile(fileName string) ([]byte, error) {
body, err := ioutil.ReadFile(fileName)
if err != nil {
return nil, err
}
return body, nil
}
func loadCredentials() (*Credentials, error) {
body, err := loadFile("config.json")
if err != nil {
return nil, err
}
var c Credentials
err = json.Unmarshal(body, &c)
if err != nil {
return nil, err
}
return &c, nil
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment