Compare commits
No commits in common. "4454bd800e8f81ef23abe1080d6c1d1f53ba5759" and "d2aba08773a15b33abd320eb62b50b076b309b91" have entirely different histories.
4454bd800e
...
d2aba08773
63
dict/dict.go
63
dict/dict.go
@ -1,63 +0,0 @@
|
|||||||
package dict
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"strings"
|
|
||||||
)
|
|
||||||
|
|
||||||
type Dict map[string]interface{}
|
|
||||||
|
|
||||||
func New() Dict {
|
|
||||||
return make(Dict)
|
|
||||||
}
|
|
||||||
|
|
||||||
func IsDict(a interface{}) bool {
|
|
||||||
_, ok := a.(Dict)
|
|
||||||
return ok
|
|
||||||
}
|
|
||||||
|
|
||||||
func (d Dict) HasKey(key string) bool {
|
|
||||||
_, ok := d[key]
|
|
||||||
return ok
|
|
||||||
}
|
|
||||||
|
|
||||||
func (d Dict) Print() {
|
|
||||||
pp, err := d.DumpJsonStrIndent("", " ")
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
fmt.Println(pp)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (d Dict) GetValue(path string) Dict {
|
|
||||||
var value Dict
|
|
||||||
current := make(Dict)
|
|
||||||
g := make(Dict)
|
|
||||||
current.CopyFrom(d)
|
|
||||||
keys := strings.Split(path, ".")
|
|
||||||
lastIndex := len(keys) - 1
|
|
||||||
for i, key := range keys {
|
|
||||||
if current.HasKey("globals") {
|
|
||||||
g.MergeWith(current["globals"].(Dict))
|
|
||||||
current.SoftMergeWith(g)
|
|
||||||
}
|
|
||||||
if !current.HasKey(key) {
|
|
||||||
value = nil
|
|
||||||
break
|
|
||||||
}
|
|
||||||
v := current[key]
|
|
||||||
if i == lastIndex {
|
|
||||||
if vv, ok := v.(Dict); ok {
|
|
||||||
vv.SoftMergeWith(g)
|
|
||||||
value = vv
|
|
||||||
} else {
|
|
||||||
value = Dict{"value": v}
|
|
||||||
}
|
|
||||||
break
|
|
||||||
}
|
|
||||||
if IsDict(v) {
|
|
||||||
current = v.(Dict)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return value
|
|
||||||
}
|
|
@ -1,41 +0,0 @@
|
|||||||
---
|
|
||||||
- name: "test 1"
|
|
||||||
arg1:
|
|
||||||
globals:
|
|
||||||
domain: "main.sample.net"
|
|
||||||
nginx:
|
|
||||||
globals:
|
|
||||||
http_port: 80
|
|
||||||
https_port: 443
|
|
||||||
redirect_to_https: true
|
|
||||||
acme_challange: true
|
|
||||||
http_port: 8888
|
|
||||||
sites:
|
|
||||||
globals:
|
|
||||||
domain: "exmaple.com"
|
|
||||||
rate_limit:
|
|
||||||
zone: "mylimit"
|
|
||||||
burst: 20
|
|
||||||
cdn:
|
|
||||||
subdomain: "cdn"
|
|
||||||
root: "/srv/public/cdn"
|
|
||||||
www:
|
|
||||||
subdomain: "www"
|
|
||||||
domain: "mywebsite.com"
|
|
||||||
redirect_to_https: false
|
|
||||||
http2: true
|
|
||||||
https_port: 8443
|
|
||||||
rate_limit:
|
|
||||||
burst: 70
|
|
||||||
arg2: "nginx.sites.www"
|
|
||||||
result:
|
|
||||||
subdomain: "www"
|
|
||||||
domain: "mywebsite.com"
|
|
||||||
redirect_to_https: false
|
|
||||||
http2: true
|
|
||||||
https_port: 8443
|
|
||||||
rate_limit:
|
|
||||||
zone: "mylimit"
|
|
||||||
burst: 70
|
|
||||||
http_port: 80
|
|
||||||
acme_challange: true
|
|
2
go.mod
2
go.mod
@ -2,4 +2,4 @@ module git.behzadan.ir/reza/GoDict
|
|||||||
|
|
||||||
go 1.22.0
|
go 1.22.0
|
||||||
|
|
||||||
require gopkg.in/yaml.v3 v3.0.1
|
require gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||||
|
1
go.sum
1
go.sum
@ -1,4 +1,3 @@
|
|||||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
|
|
||||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||||
|
17
internal/dict/dict.go
Normal file
17
internal/dict/dict.go
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
package dict
|
||||||
|
|
||||||
|
type Dict map[string]interface{}
|
||||||
|
|
||||||
|
func New() Dict {
|
||||||
|
return make(Dict)
|
||||||
|
}
|
||||||
|
|
||||||
|
func IsDict(a interface{}) bool {
|
||||||
|
_, ok := a.(Dict)
|
||||||
|
return ok
|
||||||
|
}
|
||||||
|
|
||||||
|
func (d Dict) HasKey(key string) bool {
|
||||||
|
_, ok := d[key]
|
||||||
|
return ok
|
||||||
|
}
|
@ -6,9 +6,9 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestCopy(t *testing.T) {
|
func TestCopy(t *testing.T) {
|
||||||
originalDict, err := LoadYaml("test_data/dict2.yaml")
|
originalDict, err := loadYaml("test_data/dict2.yaml")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("LoadYaml() returned an error: %v", err)
|
t.Fatalf("loadYaml() returned an error: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
newDict1 := Dict{}
|
newDict1 := Dict{}
|
||||||
@ -31,9 +31,9 @@ func TestCopy(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestCopyFrom(t *testing.T) {
|
func TestCopyFrom(t *testing.T) {
|
||||||
originalDict, err := LoadYaml("test_data/dict2.yaml")
|
originalDict, err := loadYaml("test_data/dict2.yaml")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("LoadYaml() returned an error: %v", err)
|
t.Fatalf("loadYaml() returned an error: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
newDict1 := Dict{}
|
newDict1 := Dict{}
|
||||||
@ -56,9 +56,9 @@ func TestCopyFrom(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestCopyTo(t *testing.T) {
|
func TestCopyTo(t *testing.T) {
|
||||||
originalDict, err := LoadYaml("test_data/dict2.yaml")
|
originalDict, err := loadYaml("test_data/dict2.yaml")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("LoadYaml() returned an error: %v", err)
|
t.Fatalf("loadYaml() returned an error: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
newDict1 := Dict{}
|
newDict1 := Dict{}
|
@ -6,8 +6,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestSoftMerge(t *testing.T) {
|
func TestSoftMerge(t *testing.T) {
|
||||||
testCases := []dictDictToDictTestCase{}
|
testCases := loadDictDictToDictTestCases("test_data/soft_merge_cases.yaml")
|
||||||
loadYamlFile("test_data/soft_merge_cases.yaml", &testCases)
|
|
||||||
for _, testCase := range testCases {
|
for _, testCase := range testCases {
|
||||||
SoftMerge(&testCase.Dict1, testCase.Dict2)
|
SoftMerge(&testCase.Dict1, testCase.Dict2)
|
||||||
if !reflect.DeepEqual(testCase.Dict1, testCase.Result) {
|
if !reflect.DeepEqual(testCase.Dict1, testCase.Result) {
|
||||||
@ -17,8 +16,7 @@ func TestSoftMerge(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestSoftMergeWith(t *testing.T) {
|
func TestSoftMergeWith(t *testing.T) {
|
||||||
testCases := []dictDictToDictTestCase{}
|
testCases := loadDictDictToDictTestCases("test_data/soft_merge_cases.yaml")
|
||||||
loadYamlFile("test_data/soft_merge_cases.yaml", &testCases)
|
|
||||||
for _, testCase := range testCases {
|
for _, testCase := range testCases {
|
||||||
testCase.Dict1.SoftMergeWith(testCase.Dict2)
|
testCase.Dict1.SoftMergeWith(testCase.Dict2)
|
||||||
if !reflect.DeepEqual(testCase.Dict1, testCase.Result) {
|
if !reflect.DeepEqual(testCase.Dict1, testCase.Result) {
|
||||||
@ -28,8 +26,7 @@ func TestSoftMergeWith(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestMerge(t *testing.T) {
|
func TestMerge(t *testing.T) {
|
||||||
testCases := []dictDictToDictTestCase{}
|
testCases := loadDictDictToDictTestCases("test_data/merge_cases.yaml")
|
||||||
loadYamlFile("test_data/merge_cases.yaml", &testCases)
|
|
||||||
for _, testCase := range testCases {
|
for _, testCase := range testCases {
|
||||||
Merge(&testCase.Dict1, testCase.Dict2)
|
Merge(&testCase.Dict1, testCase.Dict2)
|
||||||
if !reflect.DeepEqual(testCase.Dict1, testCase.Result) {
|
if !reflect.DeepEqual(testCase.Dict1, testCase.Result) {
|
||||||
@ -39,8 +36,7 @@ func TestMerge(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestMergeWith(t *testing.T) {
|
func TestMergeWith(t *testing.T) {
|
||||||
testCases := []dictDictToDictTestCase{}
|
testCases := loadDictDictToDictTestCases("test_data/merge_cases.yaml")
|
||||||
loadYamlFile("test_data/merge_cases.yaml", &testCases)
|
|
||||||
for _, testCase := range testCases {
|
for _, testCase := range testCases {
|
||||||
testCase.Dict1.MergeWith(testCase.Dict2)
|
testCase.Dict1.MergeWith(testCase.Dict2)
|
||||||
if !reflect.DeepEqual(testCase.Dict1, testCase.Result) {
|
if !reflect.DeepEqual(testCase.Dict1, testCase.Result) {
|
@ -7,7 +7,7 @@ import (
|
|||||||
"gopkg.in/yaml.v3"
|
"gopkg.in/yaml.v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
func LoadYaml(fn string) (Dict, error) {
|
func loadYaml(fn string) (Dict, error) {
|
||||||
content, err := os.ReadFile(fn)
|
content, err := os.ReadFile(fn)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -22,7 +22,7 @@ func LoadYaml(fn string) (Dict, error) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func LoadYamlStr(yamlStr string) (Dict, error) {
|
func loadYamlStr(yamlStr string) (Dict, error) {
|
||||||
var data Dict
|
var data Dict
|
||||||
err := yaml.Unmarshal([]byte(yamlStr), &data)
|
err := yaml.Unmarshal([]byte(yamlStr), &data)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -31,7 +31,7 @@ func LoadYamlStr(yamlStr string) (Dict, error) {
|
|||||||
return data, nil
|
return data, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d Dict) DumpYaml(fn string) error {
|
func (d Dict) dumpYaml(fn string) error {
|
||||||
data, err := yaml.Marshal(d)
|
data, err := yaml.Marshal(d)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -39,7 +39,7 @@ func (d Dict) DumpYaml(fn string) error {
|
|||||||
return os.WriteFile(fn, data, 0644) // Write with user read/write, group read, and others read permissions
|
return os.WriteFile(fn, data, 0644) // Write with user read/write, group read, and others read permissions
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d Dict) DumpYamlStr() (string, error) {
|
func (d Dict) dumpYamlStr() (string, error) {
|
||||||
data, err := yaml.Marshal(d)
|
data, err := yaml.Marshal(d)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
@ -48,7 +48,7 @@ func (d Dict) DumpYamlStr() (string, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// loadJson loads the dictionary from a JSON file.
|
// loadJson loads the dictionary from a JSON file.
|
||||||
func LoadJson(fn string) (Dict, error) {
|
func loadJson(fn string) (Dict, error) {
|
||||||
var data Dict
|
var data Dict
|
||||||
content, err := os.ReadFile(fn)
|
content, err := os.ReadFile(fn)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -62,7 +62,7 @@ func LoadJson(fn string) (Dict, error) {
|
|||||||
return data, nil
|
return data, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func LoadJsonStr(jsonStr string) (Dict, error) {
|
func loadJsonStr(jsonStr string) (Dict, error) {
|
||||||
var data Dict
|
var data Dict
|
||||||
err := json.Unmarshal([]byte(jsonStr), &data)
|
err := json.Unmarshal([]byte(jsonStr), &data)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -72,7 +72,7 @@ func LoadJsonStr(jsonStr string) (Dict, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// dumpJson writes the dictionary to a JSON file.
|
// dumpJson writes the dictionary to a JSON file.
|
||||||
func (d Dict) DumpJson(fn string) error {
|
func (d Dict) dumpJson(fn string) error {
|
||||||
data, err := json.Marshal(d)
|
data, err := json.Marshal(d)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -81,7 +81,7 @@ func (d Dict) DumpJson(fn string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// dumpJsonIndent writes the dictionary to a JSON file but applies indent first.
|
// dumpJsonIndent writes the dictionary to a JSON file but applies indent first.
|
||||||
func (d Dict) DumpJsonIndent(fn string, prefix, indent string) error {
|
func (d Dict) dumpJsonIndent(fn string, prefix, indent string) error {
|
||||||
data, err := json.MarshalIndent(d, prefix, indent)
|
data, err := json.MarshalIndent(d, prefix, indent)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -90,7 +90,7 @@ func (d Dict) DumpJsonIndent(fn string, prefix, indent string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// dumpJsonStr returns the dictionary as a JSON string.
|
// dumpJsonStr returns the dictionary as a JSON string.
|
||||||
func (d Dict) DumpJsonStr() (string, error) {
|
func (d Dict) dumpJsonStr() (string, error) {
|
||||||
data, err := json.Marshal(d)
|
data, err := json.Marshal(d)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
@ -99,7 +99,7 @@ func (d Dict) DumpJsonStr() (string, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// dumpJsonStr returns the dictionary as a JSON string.
|
// dumpJsonStr returns the dictionary as a JSON string.
|
||||||
func (d Dict) DumpJsonStrIndent(prefix, indent string) (string, error) {
|
func (d Dict) dumpJsonStrIndent(prefix, indent string) (string, error) {
|
||||||
data, err := json.MarshalIndent(d, prefix, indent)
|
data, err := json.MarshalIndent(d, prefix, indent)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
@ -31,7 +31,7 @@ key3:
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Step 3: Use the loadYaml function to load this file into a Dict.
|
// Step 3: Use the loadYaml function to load this file into a Dict.
|
||||||
dict, err := LoadYaml(tmpFile.Name())
|
dict, err := loadYaml(tmpFile.Name())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("loadYaml failed: %v", err)
|
t.Fatalf("loadYaml failed: %v", err)
|
||||||
}
|
}
|
||||||
@ -51,7 +51,7 @@ key3:
|
|||||||
// TestLoadYaml tests the loadYaml function.
|
// TestLoadYaml tests the loadYaml function.
|
||||||
func TestLoadYaml(t *testing.T) {
|
func TestLoadYaml(t *testing.T) {
|
||||||
|
|
||||||
dict, err := LoadYaml("test_data/dict1.yaml")
|
dict, err := loadYaml("test_data/dict1.yaml")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("loadYaml() returned an error: %v", err)
|
t.Fatalf("loadYaml() returned an error: %v", err)
|
||||||
}
|
}
|
||||||
@ -69,7 +69,7 @@ func TestLoadYaml(t *testing.T) {
|
|||||||
|
|
||||||
func TestDumpJsonStrIndent(t *testing.T) {
|
func TestDumpJsonStrIndent(t *testing.T) {
|
||||||
d := Dict{"key": "value", "number": 1}
|
d := Dict{"key": "value", "number": 1}
|
||||||
jsonStr, err := d.DumpJsonStrIndent("", " ")
|
jsonStr, err := d.dumpJsonStrIndent("", " ")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("dumpJsonStrIndent() returned an error: %v", err)
|
t.Fatalf("dumpJsonStrIndent() returned an error: %v", err)
|
||||||
}
|
}
|
@ -1,7 +1,6 @@
|
|||||||
package dict
|
package dict
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"reflect"
|
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -53,19 +52,3 @@ func TestIsDict(t *testing.T) {
|
|||||||
t.Errorf("Expected false, got %v", r)
|
t.Errorf("Expected false, got %v", r)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestGeValue(t *testing.T) {
|
|
||||||
testCases := []dictStrToDictTestCase{}
|
|
||||||
loadYamlFile("test_data/getvalue_cases.yaml", &testCases)
|
|
||||||
for _, testCase := range testCases {
|
|
||||||
copy := make(Dict)
|
|
||||||
copy.CopyFrom(testCase.Arg1)
|
|
||||||
result := testCase.Arg1.GetValue(testCase.Arg2)
|
|
||||||
if !reflect.DeepEqual(testCase.Result, result) {
|
|
||||||
t.Errorf("Expected dict to be %v, got %v", testCase.Result, result)
|
|
||||||
}
|
|
||||||
if !reflect.DeepEqual(testCase.Arg1, copy) {
|
|
||||||
t.Errorf("Expected dict to be %v, got %v", copy, testCase.Arg1)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,6 +1,10 @@
|
|||||||
---
|
---
|
||||||
globals:
|
globals:
|
||||||
domain: "main.sample.net"
|
domain: "main.sample.org"
|
||||||
|
names:
|
||||||
|
- Jack
|
||||||
|
- John
|
||||||
|
- Jill
|
||||||
nginx:
|
nginx:
|
||||||
globals:
|
globals:
|
||||||
http_port: 80
|
http_port: 80
|
@ -14,23 +14,18 @@ type dictDictToDictTestCase struct {
|
|||||||
Result Dict `yaml:"result"`
|
Result Dict `yaml:"result"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type dictStrToDictTestCase struct {
|
func loadDictDictToDictTestCases(fn string) []dictDictToDictTestCase {
|
||||||
Name string `yaml:"name"`
|
|
||||||
Arg1 Dict `yaml:"arg1"`
|
|
||||||
Arg2 string `yaml:"arg2"`
|
|
||||||
Result Dict `yaml:"result"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func loadYamlFile(fn string, out interface{}) {
|
|
||||||
content, err := os.ReadFile(fn)
|
content, err := os.ReadFile(fn)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
err = yaml.Unmarshal(content, out)
|
var testCases []dictDictToDictTestCase
|
||||||
|
err = yaml.Unmarshal(content, &testCases)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
return testCases
|
||||||
}
|
}
|
||||||
|
|
||||||
func sampleDict() Dict {
|
func sampleDict() Dict {
|
||||||
@ -97,9 +92,9 @@ func sampleDict() Dict {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestSampleDict(t *testing.T) {
|
func TestSampleDict(t *testing.T) {
|
||||||
originalDict, err := LoadYaml("test_data/dict2.yaml")
|
originalDict, err := loadYaml("test_data/dict2.yaml")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("LoadYaml() returned an error: %v", err)
|
t.Fatalf("loadYaml() returned an error: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
dict := sampleDict()
|
dict := sampleDict()
|
14
main.go
14
main.go
@ -1,19 +1,9 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"git.behzadan.ir/reza/GoDict/dict"
|
"fmt"
|
||||||
)
|
)
|
||||||
|
|
||||||
func load(fn string) dict.Dict {
|
|
||||||
d, err := dict.LoadYaml(fn)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
return d
|
|
||||||
}
|
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
d := load("dict/test_data/dict4.yaml")
|
fmt.Println("hi")
|
||||||
v := d.GetValue("nginx.sites.www")
|
|
||||||
v.Print()
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user