Advertisement
Guest User

Untitled

a guest
Jun 18th, 2019
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. trie := &trieSlice{
  2. Children: make([]*tNode, 5),
  3. }
  4.  
  5. trie.Children[0] = &tNode{Children: make([]*tNode, 5), IsLeaf: true, Value: 10}
  6. trie.Children[4] = &tNode{Children: make([]*tNode, 5), IsLeaf: true, Value: 20}
  7.  
  8.  
  9. // YAML marshal
  10. yamlB, err := yaml.Marshal(trie)
  11. if err != nil {
  12. fmt.Println("error in yaml conversion ...", err.Error())
  13. }
  14. ioutil.WriteFile("../resources/trieSliceBorder.yml", yamlB, 0644)
  15.  
  16. // JSON marshal
  17. b, err := json.Marshal(trie)
  18. if err != nil {
  19. fmt.Println("error while marshalling final trie json ", err.Error())
  20. t.Fail()
  21. }
  22. ioutil.WriteFile("../resources/trieSliceBorder.json", b, 0644)
  23.  
  24. {
  25. "c": [null, null, null, null, {
  26. "c": [null, null, null, null, null, null, null,
  27. {
  28. "c": [null, null, null, null, null, null, null],
  29. "v": 1,
  30. "e": true
  31. }
  32. ]
  33. }]
  34. }```
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement