aboutsummaryrefslogtreecommitdiff
path: root/model/stringNode.go
diff options
context:
space:
mode:
authorNeonXP <i@neonxp.dev>2022-11-21 04:46:32 +0300
committerNeonXP <i@neonxp.dev>2022-11-21 04:46:32 +0300
commit0d431048d3e68609b90306efd9ed015143ae651f (patch)
tree2a5fe21654bb9af02a0419722f2cd80d588465a2 /model/stringNode.go
parent4054a50ce4232ebfc4dae043863ad96d46b25b43 (diff)
added set method
Diffstat (limited to 'model/stringNode.go')
-rw-r--r--model/stringNode.go11
1 files changed, 11 insertions, 0 deletions
diff --git a/model/stringNode.go b/model/stringNode.go
index afa4023..b8dfcfb 100644
--- a/model/stringNode.go
+++ b/model/stringNode.go
@@ -1,5 +1,7 @@
package model
+import "fmt"
+
type StringNode struct {
Value string
}
@@ -11,3 +13,12 @@ func (n StringNode) Type() NodeType {
func (n *StringNode) MarshalJSON() ([]byte, error) {
return []byte(`"` + n.Value + `"`), nil
}
+
+func (n *StringNode) Set(v any) error {
+ val, ok := v.(string)
+ if !ok {
+ return fmt.Errorf("%v is not string", v)
+ }
+ n.Value = val
+ return nil
+}