Skip to content

Instantly share code, notes, and snippets.

@blizzarddreams
Last active August 29, 2015 14:15
Show Gist options
  • Select an option

  • Save blizzarddreams/acd71fa41bcf5bd8159e to your computer and use it in GitHub Desktop.

Select an option

Save blizzarddreams/acd71fa41bcf5bd8159e to your computer and use it in GitHub Desktop.
package main
type Bot struct {
User string `json:"user"`
Nick string `json:"nick"`
Server string `json:"server"`
Port string `json:"port"`
Channels []string `json:"channels"`
Symbol string `json:"symbol"`
}
{
"user": "test",
"nick": "test",
"server": "test.net",
"port": "6667",
"channels": ["#foo"],
"symbol": "$"
}
package main
import (
"bufio"
"encoding/json"
"fmt"
"io/ioutil"
"net"
"net/textproto"
"strings"
)
func main() {
file, err := ioutil.ReadFile("./config.json")
if err != nil {
panic(err)
}
bot := &Bot{}
json.Unmarshal([]byte(file), &bot)
fmt.Println(string(bot.user))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment