String makes Node satisfy the Stringer interface.
()
| 54 | |
| 55 | // String makes Node satisfy the Stringer interface. |
| 56 | func (n Node) Encode() string { |
| 57 | s := []string{"("} |
| 58 | |
| 59 | if n.Alias != "" { |
| 60 | s = append(s, n.Alias) |
| 61 | } |
| 62 | |
| 63 | if n.Label != "" { |
| 64 | s = append(s, ":", n.Label) |
| 65 | } |
| 66 | |
| 67 | if len(n.Properties) > 0 { |
| 68 | p := make([]string, 0, len(n.Properties)) |
| 69 | for k, v := range n.Properties { |
| 70 | p = append(p, fmt.Sprintf("%s:%v", k, ToString(v))) |
| 71 | } |
| 72 | |
| 73 | s = append(s, "{") |
| 74 | s = append(s, strings.Join(p, ",")) |
| 75 | s = append(s, "}") |
| 76 | } |
| 77 | |
| 78 | s = append(s, ")") |
| 79 | return strings.Join(s, "") |
| 80 | } |