-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathyml.go
More file actions
56 lines (45 loc) · 1.03 KB
/
yml.go
File metadata and controls
56 lines (45 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package main
import (
"encoding/json"
"fmt"
"io/ioutil"
"log"
"gopkg.in/yaml.v2"
)
type Config struct {
VerifyToken string `yaml:"verify_token"`
AccessToken string `yaml:"access_token"`
AppSecret string `yaml:"app_secret"`
}
func parseContentFile() string {
contentFile, err := ioutil.ReadFile("content.yml")
if err != nil {
log.Printf("Error open content file: %s\n\n", err)
}
er, _ := yaml.Marshal(contentFile)
if er != nil {
log.Printf("Couldnt marshal content file: %s\n\n", er)
}
return string(er)
}
func (c *Config) readYml() *Config {
yamlFile, err := ioutil.ReadFile("bot.config.yml")
if err != nil {
log.Printf("Error opening file: %s\n\n", err)
}
err = yaml.Unmarshal(yamlFile, c)
if err != nil {
log.Printf("Couldn't marsal config file: %s\n\n", err)
}
fmt.Printf("Here is the parsed content.yml: %s\n\n", c)
return c
}
func getToken() string {
var c Config
c.readYml()
v, err := json.Marshal(c)
if err != nil {
log.Printf("Error marsalling our json file: %s\n\n", err)
}
return string(v)
}