forked from pydio/cells
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
93 lines (73 loc) · 1.7 KB
/
main.go
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
package main
import (
"fmt"
"os"
"strings"
"github.com/golang/protobuf/jsonpb"
"gopkg.in/yaml.v2"
"github.com/pydio/cells/common/proto/install"
)
var (
sampleJson = `
{
"ProxyConfig": {
"BindURL": "https://localhost:8080",
"ExternalURL": "https://localhost:8080",
"SelfSigned": {
"Hostnames": [
"localhost"
]
}
}
}
`
sampleYaml = `
installconfig:
proxyconfig:
bindurl: "https://localhost:8080"
externalurl": "https://localhost:8080",
selfsigned:
`
)
type test struct {
Field_One string
Field_Two string
}
func main() {
myTest := &test{
Field_One: "one",
Field_Two: "two",
}
out, err := yaml.Marshal(myTest)
fmt.Println(string(out))
os.Exit(0)
// m := jsonpb.Marshaler{}
// js, err := m.MarshalToString(msg)
// if err != nil {
// fmt.Println(err)
// return
// }
// fmt.Printf("json output ==> %v\n", js)
// err2 := yaml.Unmarshal([]byte(sampleJson), &iconf2)
// if err2 != nil {
// fmt.Println("Could not unmarshall YAML file, cause:", err2.Error())
// }
iconf := &install.InstallConfig{}
err = jsonpb.Unmarshal(strings.NewReader(sampleJson), iconf)
if err != nil {
fmt.Println(err.Error())
}
fmt.Println(iconf.GetProxyConfig().GetTLSConfig())
// iconf := &install.InstallConfig{}
// err := json.Unmarshal([]byte(sampleJson), iconf)
// if err != nil {
// fmt.Println("Could not unmarshall, cause:", err.Error())
// }
// fmt.Println(iconf.GetProxyConfig().GetTLSConfig())
// iconf2 := &install.InstallConfig{}
// err2 := yaml.Unmarshal([]byte(sampleJson), &iconf2)
// if err2 != nil {
// fmt.Println("Could not unmarshall YAML file, cause:", err2.Error())
// }
// fmt.Println(iconf2.GetProxyConfig().GetTLSConfig())
}