Debian Codegraph @

parsing/yaml/yaml_writer.go

raw symbols SCIP
1 package yamlscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/yaml`/
2
3 import (
4 "fmtscip-go gomod github.com/golang/go/src go1.25 fmt/"
5
6 "github.com/tomwright/dasel/v3/modelscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/"
7 "github.com/tomwright/dasel/v3/parsingscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing`/"
8 "go.yaml.in/yaml/v4scip-go gomod go.yaml.in/yaml/v4 v4.0.0-rc.3 `go.yaml.in/yaml/v4`/"
9 )
10
11 var _ parsingscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing`/.Writerscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing`/Writer# = (*yamlWriterscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/yaml`/yamlWriter#)(nil)
12
13 func newYAMLWriterscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/yaml`/newYAMLWriter().(options parsingscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing`/.WriterOptionsscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing`/WriterOptions#) (parsingscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing`/.Writerscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing`/Writer#, error) {
14 return &yamlWriterscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/yaml`/yamlWriter#{optionsscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/yaml`/yamlWriter#options.: options}, nil
15 }
16
17 type yamlWriterscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/yaml`/yamlWriter# struct {
18 optionsscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/yaml`/yamlWriter#options. parsingscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing`/.WriterOptionsscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing`/WriterOptions#
19 }
20
21 func (j *yamlWriterscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/yaml`/yamlWriter#) Separatorscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/yaml`/yamlWriter#Separator().() []byte {
22 return []byte("---\n")
23 }
24
25 // Write writes a value to a byte slice.
26 func (j *yamlWriterscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/yaml`/yamlWriter#) Writescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/yaml`/yamlWriter#Write().(value *modelscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/.Valuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/Value#) ([]byte, error) {
27 yv := &yamlValuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/yaml`/yamlValue#{valuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/yaml`/yamlValue#value.: value, compactscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/yaml`/yamlValue#compact.: j.optionsscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/yaml`/yamlWriter#options..Compactscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing`/WriterOptions#Compact.}
28 res, err := yv.ToNodescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/yaml`/yamlValue#ToNode().()
29 if err != nil {
30 return nil, err
31 }
32 return yamlscip-go gomod go.yaml.in/yaml/v4 v4.0.0-rc.3 `go.yaml.in/yaml/v4`/.Marshalscip-go gomod go.yaml.in/yaml/v4 v4.0.0-rc.3 `go.yaml.in/yaml/v4`/Marshal().(res)
33 }
34
35 func (yv *yamlValuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/yaml`/yamlValue#) ToNodescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/yaml`/yamlValue#ToNode().() (*yamlscip-go gomod go.yaml.in/yaml/v4 v4.0.0-rc.3 `go.yaml.in/yaml/v4`/.Nodescip-go gomod go.yaml.in/yaml/v4 v4.0.0-rc.3 `go.yaml.in/yaml/v4`/Node#, error) {
36 res := &yamlscip-go gomod go.yaml.in/yaml/v4 v4.0.0-rc.3 `go.yaml.in/yaml/v4`/.Nodescip-go gomod go.yaml.in/yaml/v4 v4.0.0-rc.3 `go.yaml.in/yaml/v4`/Node#{}
37
38 // TODO : Handle yaml aliases.
39 //yamlAlias, ok := yv.value.Metadata["yaml-alias"].(string)
40 //if ok {
41 //res.Kind = yaml.AliasNode
42 //res.Value = yamlAlias
43 //return res, nil
44 //}
45
46 switch yv.valuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/yaml`/yamlValue#value..Typescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/Value#Type().() {
47 case modelscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/.TypeStringscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/TypeString.:
48 v, err := yv.valuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/yaml`/yamlValue#value..StringValuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/Value#StringValue().()
49 if err != nil {
50 return nil, err
51 }
52 res.Kindscip-go gomod go.yaml.in/yaml/v4 v4.0.0-rc.3 `go.yaml.in/yaml/v4`/Node#Kind. = yamlscip-go gomod go.yaml.in/yaml/v4 v4.0.0-rc.3 `go.yaml.in/yaml/v4`/.ScalarNodescip-go gomod go.yaml.in/yaml/v4 v4.0.0-rc.3 `go.yaml.in/yaml/v4`/ScalarNode.
53 res.Valuescip-go gomod go.yaml.in/yaml/v4 v4.0.0-rc.3 `go.yaml.in/yaml/v4`/Node#Value. = v
54 res.Tagscip-go gomod go.yaml.in/yaml/v4 v4.0.0-rc.3 `go.yaml.in/yaml/v4`/Node#Tag. = "!!str"
55 if styleVal, ok := yv.valuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/yaml`/yamlValue#value..MetadataValuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/Value#MetadataValue().("yaml-style"); ok {
56 if style, ok := styleVal.(yamlscip-go gomod go.yaml.in/yaml/v4 v4.0.0-rc.3 `go.yaml.in/yaml/v4`/.Stylescip-go gomod go.yaml.in/yaml/v4 v4.0.0-rc.3 `go.yaml.in/yaml/v4`/Style#); ok {
57 res.Stylescip-go gomod go.yaml.in/yaml/v4 v4.0.0-rc.3 `go.yaml.in/yaml/v4`/Node#Style. = style
58 }
59 }
60 case modelscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/.TypeBoolscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/TypeBool.:
61 v, err := yv.valuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/yaml`/yamlValue#value..BoolValuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/Value#BoolValue().()
62 if err != nil {
63 return nil, err
64 }
65 res.Kindscip-go gomod go.yaml.in/yaml/v4 v4.0.0-rc.3 `go.yaml.in/yaml/v4`/Node#Kind. = yamlscip-go gomod go.yaml.in/yaml/v4 v4.0.0-rc.3 `go.yaml.in/yaml/v4`/.ScalarNodescip-go gomod go.yaml.in/yaml/v4 v4.0.0-rc.3 `go.yaml.in/yaml/v4`/ScalarNode.
66 res.Valuescip-go gomod go.yaml.in/yaml/v4 v4.0.0-rc.3 `go.yaml.in/yaml/v4`/Node#Value. = fmtscip-go gomod github.com/golang/go/src go1.25 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.25 fmt/Sprintf().("%t", v)
67 res.Tagscip-go gomod go.yaml.in/yaml/v4 v4.0.0-rc.3 `go.yaml.in/yaml/v4`/Node#Tag. = "!!bool"
68 case modelscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/.TypeIntscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/TypeInt.:
69 v, err := yv.valuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/yaml`/yamlValue#value..IntValuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/Value#IntValue().()
70 if err != nil {
71 return nil, err
72 }
73 res.Kindscip-go gomod go.yaml.in/yaml/v4 v4.0.0-rc.3 `go.yaml.in/yaml/v4`/Node#Kind. = yamlscip-go gomod go.yaml.in/yaml/v4 v4.0.0-rc.3 `go.yaml.in/yaml/v4`/.ScalarNodescip-go gomod go.yaml.in/yaml/v4 v4.0.0-rc.3 `go.yaml.in/yaml/v4`/ScalarNode.
74 res.Valuescip-go gomod go.yaml.in/yaml/v4 v4.0.0-rc.3 `go.yaml.in/yaml/v4`/Node#Value. = fmtscip-go gomod github.com/golang/go/src go1.25 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.25 fmt/Sprintf().("%d", v)
75 res.Tagscip-go gomod go.yaml.in/yaml/v4 v4.0.0-rc.3 `go.yaml.in/yaml/v4`/Node#Tag. = "!!int"
76 case modelscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/.TypeFloatscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/TypeFloat.:
77 v, err := yv.valuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/yaml`/yamlValue#value..FloatValuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/Value#FloatValue().()
78 if err != nil {
79 return nil, err
80 }
81 res.Kindscip-go gomod go.yaml.in/yaml/v4 v4.0.0-rc.3 `go.yaml.in/yaml/v4`/Node#Kind. = yamlscip-go gomod go.yaml.in/yaml/v4 v4.0.0-rc.3 `go.yaml.in/yaml/v4`/.ScalarNodescip-go gomod go.yaml.in/yaml/v4 v4.0.0-rc.3 `go.yaml.in/yaml/v4`/ScalarNode.
82 res.Valuescip-go gomod go.yaml.in/yaml/v4 v4.0.0-rc.3 `go.yaml.in/yaml/v4`/Node#Value. = fmtscip-go gomod github.com/golang/go/src go1.25 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.25 fmt/Sprintf().("%g", v)
83 res.Tagscip-go gomod go.yaml.in/yaml/v4 v4.0.0-rc.3 `go.yaml.in/yaml/v4`/Node#Tag. = "!!float"
84 case modelscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/.TypeMapscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/TypeMap.:
85 res.Kindscip-go gomod go.yaml.in/yaml/v4 v4.0.0-rc.3 `go.yaml.in/yaml/v4`/Node#Kind. = yamlscip-go gomod go.yaml.in/yaml/v4 v4.0.0-rc.3 `go.yaml.in/yaml/v4`/.MappingNodescip-go gomod go.yaml.in/yaml/v4 v4.0.0-rc.3 `go.yaml.in/yaml/v4`/MappingNode.
86 if yv.compactscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/yaml`/yamlValue#compact. {
87 res.Stylescip-go gomod go.yaml.in/yaml/v4 v4.0.0-rc.3 `go.yaml.in/yaml/v4`/Node#Style. = yamlscip-go gomod go.yaml.in/yaml/v4 v4.0.0-rc.3 `go.yaml.in/yaml/v4`/.FlowStylescip-go gomod go.yaml.in/yaml/v4 v4.0.0-rc.3 `go.yaml.in/yaml/v4`/FlowStyle.
88 }
89 if err := yv.valuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/yaml`/yamlValue#value..RangeMapscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/Value#RangeMap().(func(key string, val *modelscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/.Valuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/Value#) error {
90 keyNode := &yamlValuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/yaml`/yamlValue#{valuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/yaml`/yamlValue#value.: modelscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/.NewStringValuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/NewStringValue().(key), compactscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/yaml`/yamlValue#compact.: yv.compactscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/yaml`/yamlValue#compact.}
91 valNode := &yamlValuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/yaml`/yamlValue#{valuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/yaml`/yamlValue#value.: val, compactscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/yaml`/yamlValue#compact.: yv.compactscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/yaml`/yamlValue#compact.}
92
93 marshalledKey, err := keyNode.ToNodescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/yaml`/yamlValue#ToNode().()
94 if err != nil {
95 return err
96 }
97 marshalledVal, err := valNode.ToNodescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/yaml`/yamlValue#ToNode().()
98 if err != nil {
99 return err
100 }
101
102 res.Contentscip-go gomod go.yaml.in/yaml/v4 v4.0.0-rc.3 `go.yaml.in/yaml/v4`/Node#Content. = append(res.Contentscip-go gomod go.yaml.in/yaml/v4 v4.0.0-rc.3 `go.yaml.in/yaml/v4`/Node#Content., marshalledKey)
103 res.Contentscip-go gomod go.yaml.in/yaml/v4 v4.0.0-rc.3 `go.yaml.in/yaml/v4`/Node#Content. = append(res.Contentscip-go gomod go.yaml.in/yaml/v4 v4.0.0-rc.3 `go.yaml.in/yaml/v4`/Node#Content., marshalledVal)
104
105 return nil
106 }); err != nil {
107 return nil, err
108 }
109 case modelscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/.TypeSlicescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/TypeSlice.:
110 res.Kindscip-go gomod go.yaml.in/yaml/v4 v4.0.0-rc.3 `go.yaml.in/yaml/v4`/Node#Kind. = yamlscip-go gomod go.yaml.in/yaml/v4 v4.0.0-rc.3 `go.yaml.in/yaml/v4`/.SequenceNodescip-go gomod go.yaml.in/yaml/v4 v4.0.0-rc.3 `go.yaml.in/yaml/v4`/SequenceNode.
111 if yv.compactscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/yaml`/yamlValue#compact. {
112 res.Stylescip-go gomod go.yaml.in/yaml/v4 v4.0.0-rc.3 `go.yaml.in/yaml/v4`/Node#Style. = yamlscip-go gomod go.yaml.in/yaml/v4 v4.0.0-rc.3 `go.yaml.in/yaml/v4`/.FlowStylescip-go gomod go.yaml.in/yaml/v4 v4.0.0-rc.3 `go.yaml.in/yaml/v4`/FlowStyle.
113 }
114 if err := yv.valuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/yaml`/yamlValue#value..RangeSlicescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/Value#RangeSlice().(func(i int, val *modelscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/.Valuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/Value#) error {
115 valNode := &yamlValuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/yaml`/yamlValue#{valuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/yaml`/yamlValue#value.: val, compactscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/yaml`/yamlValue#compact.: yv.compactscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/yaml`/yamlValue#compact.}
116 marshalledVal, err := valNode.ToNodescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/yaml`/yamlValue#ToNode().()
117 if err != nil {
118 return err
119 }
120 res.Contentscip-go gomod go.yaml.in/yaml/v4 v4.0.0-rc.3 `go.yaml.in/yaml/v4`/Node#Content. = append(res.Contentscip-go gomod go.yaml.in/yaml/v4 v4.0.0-rc.3 `go.yaml.in/yaml/v4`/Node#Content., marshalledVal)
121 return nil
122 }); err != nil {
123 return nil, err
124 }
125 case modelscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/.TypeNullscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/TypeNull.:
126 res.Kindscip-go gomod go.yaml.in/yaml/v4 v4.0.0-rc.3 `go.yaml.in/yaml/v4`/Node#Kind. = yamlscip-go gomod go.yaml.in/yaml/v4 v4.0.0-rc.3 `go.yaml.in/yaml/v4`/.ScalarNodescip-go gomod go.yaml.in/yaml/v4 v4.0.0-rc.3 `go.yaml.in/yaml/v4`/ScalarNode.
127 res.Valuescip-go gomod go.yaml.in/yaml/v4 v4.0.0-rc.3 `go.yaml.in/yaml/v4`/Node#Value. = "null"
128 res.Tagscip-go gomod go.yaml.in/yaml/v4 v4.0.0-rc.3 `go.yaml.in/yaml/v4`/Node#Tag. = "!!null"
129 case modelscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/.TypeUnknownscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/TypeUnknown.:
130 return nil, fmtscip-go gomod github.com/golang/go/src go1.25 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.25 fmt/Errorf().("unknown type: %s", yv.valuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/yaml`/yamlValue#value..Typescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/Value#Type().())
131 }
132
133 return res, nil
134 }
135
136 func (yv *yamlValuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/yaml`/yamlValue#) MarshalYAMLscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/yaml`/yamlValue#MarshalYAML().() (any, error) {
137 res, err := yv.ToNodescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/yaml`/yamlValue#ToNode().()
138 if err != nil {
139 return nil, err
140 }
141 return res, nil
142 }