| 1 | package yamlscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/ |
| 2 | |
| 3 | import ( |
| 4 | "contextscip-go gomod github.com/golang/go/src go1.21.0 context/" |
| 5 | "encodingscip-go gomod github.com/golang/go/src go1.21.0 encoding/" |
| 6 | "fmtscip-go gomod github.com/golang/go/src go1.21.0 fmt/" |
| 7 | "ioscip-go gomod github.com/golang/go/src go1.21.0 io/" |
| 8 | "mathscip-go gomod github.com/golang/go/src go1.21.0 math/" |
| 9 | "reflectscip-go gomod github.com/golang/go/src go1.21.0 reflect/" |
| 10 | "sortscip-go gomod github.com/golang/go/src go1.21.0 sort/" |
| 11 | "strconvscip-go gomod github.com/golang/go/src go1.21.0 strconv/" |
| 12 | "stringsscip-go gomod github.com/golang/go/src go1.21.0 strings/" |
| 13 | "timescip-go gomod github.com/golang/go/src go1.21.0 time/" |
| 14 | |
| 15 | "github.com/goccy/go-yaml/astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/" |
| 16 | "github.com/goccy/go-yaml/internal/errorsscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/errors`/" |
| 17 | "github.com/goccy/go-yaml/parserscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/parser`/" |
| 18 | "github.com/goccy/go-yaml/printerscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/printer`/" |
| 19 | "github.com/goccy/go-yaml/tokenscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/token`/" |
| 20 | ) |
| 21 | |
| 22 | const ( |
| 23 | // DefaultIndentSpaces default number of space for indent |
| 24 | DefaultIndentSpacesscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/DefaultIndentSpaces. = 2 |
| 25 | ) |
| 26 | |
| 27 | // Encoder writes YAML values to an output stream. |
| 28 | type Encoderscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder# struct { |
| 29 | writerscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#writer. ioscip-go gomod github.com/golang/go/src go1.21.0 io/.Writerscip-go gomod github.com/golang/go/src go1.21.0 io/Writer# |
| 30 | optsscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#opts. []EncodeOptionscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/EncodeOption# |
| 31 | singleQuotescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#singleQuote. bool |
| 32 | isFlowStylescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#isFlowStyle. bool |
| 33 | isJSONStylescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#isJSONStyle. bool |
| 34 | useJSONMarshalerscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#useJSONMarshaler. bool |
| 35 | enableSmartAnchorscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#enableSmartAnchor. bool |
| 36 | aliasRefToNamescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#aliasRefToName. map[uintptr]string |
| 37 | anchorRefToNamescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#anchorRefToName. map[uintptr]string |
| 38 | anchorNameMapscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#anchorNameMap. map[string]struct{} |
| 39 | anchorCallbackscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#anchorCallback. func(*astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.AnchorNodescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/AnchorNode#, interface{}) error |
| 40 | customMarshalerMapscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#customMarshalerMap. map[reflectscip-go gomod github.com/golang/go/src go1.21.0 reflect/.Typescip-go gomod github.com/golang/go/src go1.21.0 reflect/Type#]func(contextscip-go gomod github.com/golang/go/src go1.21.0 context/.Contextscip-go gomod github.com/golang/go/src go1.21.0 context/Context#, interface{}) ([]byte, error) |
| 41 | omitZeroscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#omitZero. bool |
| 42 | omitEmptyscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#omitEmpty. bool |
| 43 | autoIntscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#autoInt. bool |
| 44 | useLiteralStyleIfMultilinescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#useLiteralStyleIfMultiline. bool |
| 45 | commentMapscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#commentMap. map[*Pathscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Path#][]*Commentscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Comment# |
| 46 | writtenscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#written. bool |
| 47 | |
| 48 | linescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#line. int |
| 49 | columnscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#column. int |
| 50 | offsetscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#offset. int |
| 51 | indentNumscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#indentNum. int |
| 52 | indentLevelscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#indentLevel. int |
| 53 | indentSequencescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#indentSequence. bool |
| 54 | } |
| 55 | |
| 56 | // NewEncoder returns a new encoder that writes to w. |
| 57 | // The Encoder should be closed after use to flush all data to w. |
| 58 | func NewEncoderscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/NewEncoder().(w ioscip-go gomod github.com/golang/go/src go1.21.0 io/.Writerscip-go gomod github.com/golang/go/src go1.21.0 io/Writer#, opts ...EncodeOptionscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/EncodeOption#) *Encoderscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder# { |
| 59 | return &Encoderscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#{ |
| 60 | writerscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#writer.: w, |
| 61 | optsscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#opts.: opts, |
| 62 | customMarshalerMapscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#customMarshalerMap.: map[reflectscip-go gomod github.com/golang/go/src go1.21.0 reflect/.Typescip-go gomod github.com/golang/go/src go1.21.0 reflect/Type#]func(contextscip-go gomod github.com/golang/go/src go1.21.0 context/.Contextscip-go gomod github.com/golang/go/src go1.21.0 context/Context#, interface{}) ([]byte, error){}, |
| 63 | linescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#line.: 1, |
| 64 | columnscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#column.: 1, |
| 65 | offsetscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#offset.: 0, |
| 66 | indentNumscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#indentNum.: DefaultIndentSpacesscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/DefaultIndentSpaces., |
| 67 | anchorRefToNamescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#anchorRefToName.: make(map[uintptr]string), |
| 68 | anchorNameMapscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#anchorNameMap.: make(map[string]struct{}), |
| 69 | aliasRefToNamescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#aliasRefToName.: make(map[uintptr]string), |
| 70 | } |
| 71 | } |
| 72 | |
| 73 | // Close closes the encoder by writing any remaining data. |
| 74 | // It does not write a stream terminating string "...". |
| 75 | func (e *Encoderscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#) Closescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#Close().() error { |
| 76 | return nil |
| 77 | } |
| 78 | |
| 79 | // Encode writes the YAML encoding of v to the stream. |
| 80 | // If multiple items are encoded to the stream, |
| 81 | // the second and subsequent document will be preceded with a "---" document separator, |
| 82 | // but the first will not. |
| 83 | // |
| 84 | // See the documentation for Marshal for details about the conversion of Go values to YAML. |
| 85 | func (e *Encoderscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#) Encodescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#Encode().(v interface{}) error { |
| 86 | return e.EncodeContextscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#EncodeContext().(contextscip-go gomod github.com/golang/go/src go1.21.0 context/.Backgroundscip-go gomod github.com/golang/go/src go1.21.0 context/Background().(), v) |
| 87 | } |
| 88 | |
| 89 | // EncodeContext writes the YAML encoding of v to the stream with context.Context. |
| 90 | func (e *Encoderscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#) EncodeContextscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#EncodeContext().(ctx contextscip-go gomod github.com/golang/go/src go1.21.0 context/.Contextscip-go gomod github.com/golang/go/src go1.21.0 context/Context#, v interface{}) error { |
| 91 | node, err := e.EncodeToNodeContextscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#EncodeToNodeContext().(ctx, v) |
| 92 | if err != nil { |
| 93 | return err |
| 94 | } |
| 95 | if err := e.setCommentByCommentMapscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#setCommentByCommentMap().(node); err != nil { |
| 96 | return err |
| 97 | } |
| 98 | if !e.writtenscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#written. { |
| 99 | e.writtenscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#written. = true |
| 100 | } else { |
| 101 | // write document separator |
| 102 | _, _ = e.writerscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#writer..Writescip-go gomod github.com/golang/go/src go1.21.0 io/Writer#Write().([]byte("---\n")) |
| 103 | } |
| 104 | var p printerscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/printer`/.Printerscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/printer`/Printer# |
| 105 | _, _ = e.writerscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#writer..Writescip-go gomod github.com/golang/go/src go1.21.0 io/Writer#Write().(p.PrintNodescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/printer`/Printer#PrintNode().(node)) |
| 106 | return nil |
| 107 | } |
| 108 | |
| 109 | // EncodeToNode convert v to ast.Node. |
| 110 | func (e *Encoderscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#) EncodeToNodescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#EncodeToNode().(v interface{}) (astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.Nodescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/Node#, error) { |
| 111 | return e.EncodeToNodeContextscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#EncodeToNodeContext().(contextscip-go gomod github.com/golang/go/src go1.21.0 context/.Backgroundscip-go gomod github.com/golang/go/src go1.21.0 context/Background().(), v) |
| 112 | } |
| 113 | |
| 114 | // EncodeToNodeContext convert v to ast.Node with context.Context. |
| 115 | func (e *Encoderscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#) EncodeToNodeContextscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#EncodeToNodeContext().(ctx contextscip-go gomod github.com/golang/go/src go1.21.0 context/.Contextscip-go gomod github.com/golang/go/src go1.21.0 context/Context#, v interface{}) (astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.Nodescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/Node#, error) { |
| 116 | for _, opt := range e.optsscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#opts. { |
| 117 | if err := opt(e); err != nil { |
| 118 | return nil, err |
| 119 | } |
| 120 | } |
| 121 | if e.enableSmartAnchorscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#enableSmartAnchor. { |
| 122 | // during the first encoding, store all mappings between alias addresses and their names. |
| 123 | if _, err := e.encodeValuescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#encodeValue().(ctx, reflectscip-go gomod github.com/golang/go/src go1.21.0 reflect/.ValueOfscip-go gomod github.com/golang/go/src go1.21.0 reflect/ValueOf().(v), 1); err != nil { |
| 124 | return nil, err |
| 125 | } |
| 126 | e.clearSmartAnchorRefscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#clearSmartAnchorRef().() |
| 127 | } |
| 128 | node, err := e.encodeValuescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#encodeValue().(ctx, reflectscip-go gomod github.com/golang/go/src go1.21.0 reflect/.ValueOfscip-go gomod github.com/golang/go/src go1.21.0 reflect/ValueOf().(v), 1) |
| 129 | if err != nil { |
| 130 | return nil, err |
| 131 | } |
| 132 | return node, nil |
| 133 | } |
| 134 | |
| 135 | func (e *Encoderscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#) setCommentByCommentMapscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#setCommentByCommentMap().(node astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.Nodescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/Node#) error { |
| 136 | if e.commentMapscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#commentMap. == nil { |
| 137 | return nil |
| 138 | } |
| 139 | for path, comments := range e.commentMapscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#commentMap. { |
| 140 | n, err := path.FilterNodescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Path#FilterNode().(node) |
| 141 | if err != nil { |
| 142 | return err |
| 143 | } |
| 144 | if n == nil { |
| 145 | continue |
| 146 | } |
| 147 | for _, comment := range comments { |
| 148 | commentTokens := []*tokenscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/token`/.Tokenscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/token`/Token#{} |
| 149 | for _, text := range comment.Textsscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Comment#Texts. { |
| 150 | commentTokens = append(commentTokens, tokenscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/token`/.Newscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/token`/New().(text, text, nil)) |
| 151 | } |
| 152 | commentGroup := astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.CommentGroupscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/CommentGroup().(commentTokens) |
| 153 | switch comment.Positionscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Comment#Position. { |
| 154 | case CommentHeadPositionscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/CommentHeadPosition.: |
| 155 | if err := e.setHeadCommentscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#setHeadComment().(node, n, commentGroup); err != nil { |
| 156 | return err |
| 157 | } |
| 158 | case CommentLinePositionscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/CommentLinePosition.: |
| 159 | if err := e.setLineCommentscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#setLineComment().(node, n, commentGroup); err != nil { |
| 160 | return err |
| 161 | } |
| 162 | case CommentFootPositionscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/CommentFootPosition.: |
| 163 | if err := e.setFootCommentscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#setFootComment().(node, n, commentGroup); err != nil { |
| 164 | return err |
| 165 | } |
| 166 | default: |
| 167 | return ErrUnknownCommentPositionTypescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/ErrUnknownCommentPositionType. |
| 168 | } |
| 169 | } |
| 170 | } |
| 171 | return nil |
| 172 | } |
| 173 | |
| 174 | func (e *Encoderscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#) setHeadCommentscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#setHeadComment().(node astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.Nodescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/Node#, filtered astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.Nodescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/Node#, comment *astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.CommentGroupNodescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/CommentGroupNode#) error { |
| 175 | parent := astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.Parentscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/Parent().(node, filtered) |
| 176 | if parent == nil { |
| 177 | return ErrUnsupportedHeadPositionTypescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/ErrUnsupportedHeadPositionType().(node) |
| 178 | } |
| 179 | switch p := parent.(type) { |
| 180 | case *astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.MappingValueNodescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/MappingValueNode#: |
| 181 | if err := p.SetCommentscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/BaseNode#SetComment().(comment); err != nil { |
| 182 | return err |
| 183 | } |
| 184 | case *astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.MappingNodescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/MappingNode#: |
| 185 | if err := p.SetCommentscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/BaseNode#SetComment().(comment); err != nil { |
| 186 | return err |
| 187 | } |
| 188 | case *astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.SequenceNodescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/SequenceNode#: |
| 189 | if len(p.ValueHeadCommentsscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/SequenceNode#ValueHeadComments.) == 0 { |
| 190 | p.ValueHeadCommentsscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/SequenceNode#ValueHeadComments. = make([]*astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.CommentGroupNodescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/CommentGroupNode#, len(p.Valuesscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/SequenceNode#Values.)) |
| 191 | } |
| 192 | var foundIdx int |
| 193 | for idx, v := range p.Valuesscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/SequenceNode#Values. { |
| 194 | if v == filtered { |
| 195 | foundIdx = idx |
| 196 | break |
| 197 | } |
| 198 | } |
| 199 | p.ValueHeadCommentsscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/SequenceNode#ValueHeadComments.[foundIdx] = comment |
| 200 | default: |
| 201 | return ErrUnsupportedHeadPositionTypescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/ErrUnsupportedHeadPositionType().(node) |
| 202 | } |
| 203 | return nil |
| 204 | } |
| 205 | |
| 206 | func (e *Encoderscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#) setLineCommentscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#setLineComment().(node astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.Nodescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/Node#, filtered astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.Nodescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/Node#, comment *astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.CommentGroupNodescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/CommentGroupNode#) error { |
| 207 | switch filtered.(type) { |
| 208 | case *astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.MappingValueNodescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/MappingValueNode#, *astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.SequenceNodescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/SequenceNode#: |
| 209 | // Line comment cannot be set for mapping value node. |
| 210 | // It should probably be set for the parent map node |
| 211 | if err := e.setLineCommentToParentMapNodescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#setLineCommentToParentMapNode().(node, filtered, comment); err != nil { |
| 212 | return err |
| 213 | } |
| 214 | default: |
| 215 | if err := filtered.SetCommentscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/Node#SetComment.(comment); err != nil { |
| 216 | return err |
| 217 | } |
| 218 | } |
| 219 | return nil |
| 220 | } |
| 221 | |
| 222 | func (e *Encoderscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#) setLineCommentToParentMapNodescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#setLineCommentToParentMapNode().(node astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.Nodescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/Node#, filtered astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.Nodescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/Node#, comment *astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.CommentGroupNodescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/CommentGroupNode#) error { |
| 223 | parent := astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.Parentscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/Parent().(node, filtered) |
| 224 | if parent == nil { |
| 225 | return ErrUnsupportedLinePositionTypescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/ErrUnsupportedLinePositionType().(node) |
| 226 | } |
| 227 | switch p := parent.(type) { |
| 228 | case *astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.MappingValueNodescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/MappingValueNode#: |
| 229 | if err := p.Keyscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/MappingValueNode#Key..SetCommentscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/Node#SetComment.(comment); err != nil { |
| 230 | return err |
| 231 | } |
| 232 | case *astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.MappingNodescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/MappingNode#: |
| 233 | if err := p.SetCommentscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/BaseNode#SetComment().(comment); err != nil { |
| 234 | return err |
| 235 | } |
| 236 | default: |
| 237 | return ErrUnsupportedLinePositionTypescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/ErrUnsupportedLinePositionType().(parent) |
| 238 | } |
| 239 | return nil |
| 240 | } |
| 241 | |
| 242 | func (e *Encoderscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#) setFootCommentscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#setFootComment().(node astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.Nodescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/Node#, filtered astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.Nodescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/Node#, comment *astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.CommentGroupNodescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/CommentGroupNode#) error { |
| 243 | parent := astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.Parentscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/Parent().(node, filtered) |
| 244 | if parent == nil { |
| 245 | return ErrUnsupportedFootPositionTypescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/ErrUnsupportedFootPositionType().(node) |
| 246 | } |
| 247 | switch n := parent.(type) { |
| 248 | case *astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.MappingValueNodescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/MappingValueNode#: |
| 249 | n.FootCommentscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/MappingValueNode#FootComment. = comment |
| 250 | case *astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.MappingNodescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/MappingNode#: |
| 251 | n.FootCommentscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/MappingNode#FootComment. = comment |
| 252 | case *astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.SequenceNodescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/SequenceNode#: |
| 253 | n.FootCommentscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/SequenceNode#FootComment. = comment |
| 254 | default: |
| 255 | return ErrUnsupportedFootPositionTypescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/ErrUnsupportedFootPositionType().(n) |
| 256 | } |
| 257 | return nil |
| 258 | } |
| 259 | |
| 260 | func (e *Encoderscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#) encodeDocumentscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#encodeDocument().(doc []byte) (astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.Nodescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/Node#, error) { |
| 261 | f, err := parserscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/parser`/.ParseBytesscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/parser`/ParseBytes().(doc, 0) |
| 262 | if err != nil { |
| 263 | return nil, err |
| 264 | } |
| 265 | for _, docNode := range f.Docsscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/File#Docs. { |
| 266 | if docNode.Bodyscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/DocumentNode#Body. != nil { |
| 267 | return docNode.Bodyscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/DocumentNode#Body., nil |
| 268 | } |
| 269 | } |
| 270 | return nil, nil |
| 271 | } |
| 272 | |
| 273 | func (e *Encoderscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#) isInvalidValuescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#isInvalidValue().(v reflectscip-go gomod github.com/golang/go/src go1.21.0 reflect/.Valuescip-go gomod github.com/golang/go/src go1.21.0 reflect/Value#) bool { |
| 274 | if !v.IsValidscip-go gomod github.com/golang/go/src go1.21.0 reflect/Value#IsValid().() { |
| 275 | return true |
| 276 | } |
| 277 | kind := v.Typescip-go gomod github.com/golang/go/src go1.21.0 reflect/Value#Type().().Kindscip-go gomod github.com/golang/go/src go1.21.0 reflect/Type#Kind().() |
| 278 | if kind == reflectscip-go gomod github.com/golang/go/src go1.21.0 reflect/.Ptrscip-go gomod github.com/golang/go/src go1.21.0 reflect/Ptr. && v.IsNilscip-go gomod github.com/golang/go/src go1.21.0 reflect/Value#IsNil().() { |
| 279 | return true |
| 280 | } |
| 281 | if kind == reflectscip-go gomod github.com/golang/go/src go1.21.0 reflect/.Interfacescip-go gomod github.com/golang/go/src go1.21.0 reflect/Interface. && v.IsNilscip-go gomod github.com/golang/go/src go1.21.0 reflect/Value#IsNil().() { |
| 282 | return true |
| 283 | } |
| 284 | return false |
| 285 | } |
| 286 | |
| 287 | type jsonMarshalerscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/jsonMarshaler# interface { |
| 288 | MarshalJSONscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/jsonMarshaler#MarshalJSON.() ([]byte, error) |
| 289 | } |
| 290 | |
| 291 | func (e *Encoderscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#) existsTypeInCustomMarshalerMapscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#existsTypeInCustomMarshalerMap().(t reflectscip-go gomod github.com/golang/go/src go1.21.0 reflect/.Typescip-go gomod github.com/golang/go/src go1.21.0 reflect/Type#) bool { |
| 292 | if _, exists := e.customMarshalerMapscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#customMarshalerMap.[t]; exists { |
| 293 | return true |
| 294 | } |
| 295 | |
| 296 | globalCustomMarshalerMuscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/globalCustomMarshalerMu..Lockscip-go gomod github.com/golang/go/src go1.21.0 sync/Mutex#Lock().() |
| 297 | defer globalCustomMarshalerMuscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/globalCustomMarshalerMu..Unlockscip-go gomod github.com/golang/go/src go1.21.0 sync/Mutex#Unlock().() |
| 298 | if _, exists := globalCustomMarshalerMapscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/globalCustomMarshalerMap.[t]; exists { |
| 299 | return true |
| 300 | } |
| 301 | return false |
| 302 | } |
| 303 | |
| 304 | func (e *Encoderscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#) marshalerFromCustomMarshalerMapscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#marshalerFromCustomMarshalerMap().(t reflectscip-go gomod github.com/golang/go/src go1.21.0 reflect/.Typescip-go gomod github.com/golang/go/src go1.21.0 reflect/Type#) (func(contextscip-go gomod github.com/golang/go/src go1.21.0 context/.Contextscip-go gomod github.com/golang/go/src go1.21.0 context/Context#, interface{}) ([]byte, error), bool) { |
| 305 | if marshaler, exists := e.customMarshalerMapscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#customMarshalerMap.[t]; exists { |
| 306 | return marshaler, exists |
| 307 | } |
| 308 | |
| 309 | globalCustomMarshalerMuscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/globalCustomMarshalerMu..Lockscip-go gomod github.com/golang/go/src go1.21.0 sync/Mutex#Lock().() |
| 310 | defer globalCustomMarshalerMuscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/globalCustomMarshalerMu..Unlockscip-go gomod github.com/golang/go/src go1.21.0 sync/Mutex#Unlock().() |
| 311 | if marshaler, exists := globalCustomMarshalerMapscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/globalCustomMarshalerMap.[t]; exists { |
| 312 | return marshaler, exists |
| 313 | } |
| 314 | return nil, false |
| 315 | } |
| 316 | |
| 317 | func (e *Encoderscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#) canEncodeByMarshalerscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#canEncodeByMarshaler().(v reflectscip-go gomod github.com/golang/go/src go1.21.0 reflect/.Valuescip-go gomod github.com/golang/go/src go1.21.0 reflect/Value#) bool { |
| 318 | if !v.CanInterfacescip-go gomod github.com/golang/go/src go1.21.0 reflect/Value#CanInterface().() { |
| 319 | return false |
| 320 | } |
| 321 | if e.existsTypeInCustomMarshalerMapscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#existsTypeInCustomMarshalerMap().(v.Typescip-go gomod github.com/golang/go/src go1.21.0 reflect/Value#Type().()) { |
| 322 | return true |
| 323 | } |
| 324 | iface := v.Interfacescip-go gomod github.com/golang/go/src go1.21.0 reflect/Value#Interface().() |
| 325 | switch iface.(type) { |
| 326 | case BytesMarshalerContextscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/BytesMarshalerContext#: |
| 327 | return true |
| 328 | case BytesMarshalerscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/BytesMarshaler#: |
| 329 | return true |
| 330 | case InterfaceMarshalerContextscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/InterfaceMarshalerContext#: |
| 331 | return true |
| 332 | case InterfaceMarshalerscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/InterfaceMarshaler#: |
| 333 | return true |
| 334 | case timescip-go gomod github.com/golang/go/src go1.21.0 time/.Timescip-go gomod github.com/golang/go/src go1.21.0 time/Time#, *timescip-go gomod github.com/golang/go/src go1.21.0 time/.Timescip-go gomod github.com/golang/go/src go1.21.0 time/Time#: |
| 335 | return true |
| 336 | case timescip-go gomod github.com/golang/go/src go1.21.0 time/.Durationscip-go gomod github.com/golang/go/src go1.21.0 time/Duration#: |
| 337 | return true |
| 338 | case encodingscip-go gomod github.com/golang/go/src go1.21.0 encoding/.TextMarshalerscip-go gomod github.com/golang/go/src go1.21.0 encoding/TextMarshaler#: |
| 339 | return true |
| 340 | case jsonMarshalerscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/jsonMarshaler#: |
| 341 | return e.useJSONMarshalerscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#useJSONMarshaler. |
| 342 | } |
| 343 | return false |
| 344 | } |
| 345 | |
| 346 | func (e *Encoderscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#) encodeByMarshalerscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#encodeByMarshaler().(ctx contextscip-go gomod github.com/golang/go/src go1.21.0 context/.Contextscip-go gomod github.com/golang/go/src go1.21.0 context/Context#, v reflectscip-go gomod github.com/golang/go/src go1.21.0 reflect/.Valuescip-go gomod github.com/golang/go/src go1.21.0 reflect/Value#, column int) (astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.Nodescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/Node#, error) { |
| 347 | iface := v.Interfacescip-go gomod github.com/golang/go/src go1.21.0 reflect/Value#Interface().() |
| 348 | |
| 349 | if marshaler, exists := e.marshalerFromCustomMarshalerMapscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#marshalerFromCustomMarshalerMap().(v.Typescip-go gomod github.com/golang/go/src go1.21.0 reflect/Value#Type().()); exists { |
| 350 | doc, err := marshaler(ctx, iface) |
| 351 | if err != nil { |
| 352 | return nil, err |
| 353 | } |
| 354 | node, err := e.encodeDocumentscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#encodeDocument().(doc) |
| 355 | if err != nil { |
| 356 | return nil, err |
| 357 | } |
| 358 | return node, nil |
| 359 | } |
| 360 | |
| 361 | if marshaler, ok := iface.(BytesMarshalerContextscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/BytesMarshalerContext#); ok { |
| 362 | doc, err := marshaler.MarshalYAMLscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/BytesMarshalerContext#MarshalYAML.(ctx) |
| 363 | if err != nil { |
| 364 | return nil, err |
| 365 | } |
| 366 | node, err := e.encodeDocumentscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#encodeDocument().(doc) |
| 367 | if err != nil { |
| 368 | return nil, err |
| 369 | } |
| 370 | return node, nil |
| 371 | } |
| 372 | |
| 373 | if marshaler, ok := iface.(BytesMarshalerscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/BytesMarshaler#); ok { |
| 374 | doc, err := marshaler.MarshalYAMLscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/BytesMarshaler#MarshalYAML.() |
| 375 | if err != nil { |
| 376 | return nil, err |
| 377 | } |
| 378 | node, err := e.encodeDocumentscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#encodeDocument().(doc) |
| 379 | if err != nil { |
| 380 | return nil, err |
| 381 | } |
| 382 | return node, nil |
| 383 | } |
| 384 | |
| 385 | if marshaler, ok := iface.(InterfaceMarshalerContextscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/InterfaceMarshalerContext#); ok { |
| 386 | marshalV, err := marshaler.MarshalYAMLscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/InterfaceMarshalerContext#MarshalYAML.(ctx) |
| 387 | if err != nil { |
| 388 | return nil, err |
| 389 | } |
| 390 | return e.encodeValuescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#encodeValue().(ctx, reflectscip-go gomod github.com/golang/go/src go1.21.0 reflect/.ValueOfscip-go gomod github.com/golang/go/src go1.21.0 reflect/ValueOf().(marshalV), column) |
| 391 | } |
| 392 | |
| 393 | if marshaler, ok := iface.(InterfaceMarshalerscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/InterfaceMarshaler#); ok { |
| 394 | marshalV, err := marshaler.MarshalYAMLscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/InterfaceMarshaler#MarshalYAML.() |
| 395 | if err != nil { |
| 396 | return nil, err |
| 397 | } |
| 398 | return e.encodeValuescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#encodeValue().(ctx, reflectscip-go gomod github.com/golang/go/src go1.21.0 reflect/.ValueOfscip-go gomod github.com/golang/go/src go1.21.0 reflect/ValueOf().(marshalV), column) |
| 399 | } |
| 400 | |
| 401 | if t, ok := iface.(timescip-go gomod github.com/golang/go/src go1.21.0 time/.Timescip-go gomod github.com/golang/go/src go1.21.0 time/Time#); ok { |
| 402 | return e.encodeTimescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#encodeTime().(t, column), nil |
| 403 | } |
| 404 | // Handle *time.Time explicitly since it implements TextMarshaler and shouldn't be treated as plain text |
| 405 | if t, ok := iface.(*timescip-go gomod github.com/golang/go/src go1.21.0 time/.Timescip-go gomod github.com/golang/go/src go1.21.0 time/Time#); ok && t != nil { |
| 406 | return e.encodeTimescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#encodeTime().(*t, column), nil |
| 407 | } |
| 408 | |
| 409 | if t, ok := iface.(timescip-go gomod github.com/golang/go/src go1.21.0 time/.Durationscip-go gomod github.com/golang/go/src go1.21.0 time/Duration#); ok { |
| 410 | return e.encodeDurationscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#encodeDuration().(t, column), nil |
| 411 | } |
| 412 | |
| 413 | if marshaler, ok := iface.(encodingscip-go gomod github.com/golang/go/src go1.21.0 encoding/.TextMarshalerscip-go gomod github.com/golang/go/src go1.21.0 encoding/TextMarshaler#); ok { |
| 414 | text, err := marshaler.MarshalTextscip-go gomod github.com/golang/go/src go1.21.0 encoding/TextMarshaler#MarshalText().() |
| 415 | if err != nil { |
| 416 | return nil, err |
| 417 | } |
| 418 | node := e.encodeStringscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#encodeString().(string(text), column) |
| 419 | return node, nil |
| 420 | } |
| 421 | |
| 422 | if e.useJSONMarshalerscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#useJSONMarshaler. { |
| 423 | if marshaler, ok := iface.(jsonMarshalerscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/jsonMarshaler#); ok { |
| 424 | jsonBytes, err := marshaler.MarshalJSONscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/jsonMarshaler#MarshalJSON.() |
| 425 | if err != nil { |
| 426 | return nil, err |
| 427 | } |
| 428 | doc, err := JSONToYAMLscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/JSONToYAML().(jsonBytes) |
| 429 | if err != nil { |
| 430 | return nil, err |
| 431 | } |
| 432 | node, err := e.encodeDocumentscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#encodeDocument().(doc) |
| 433 | if err != nil { |
| 434 | return nil, err |
| 435 | } |
| 436 | return node, nil |
| 437 | } |
| 438 | } |
| 439 | |
| 440 | return nil, errorsscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/errors`/.Newscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/errors`/New.("does not implemented Marshaler") |
| 441 | } |
| 442 | |
| 443 | func (e *Encoderscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#) encodeValuescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#encodeValue().(ctx contextscip-go gomod github.com/golang/go/src go1.21.0 context/.Contextscip-go gomod github.com/golang/go/src go1.21.0 context/Context#, v reflectscip-go gomod github.com/golang/go/src go1.21.0 reflect/.Valuescip-go gomod github.com/golang/go/src go1.21.0 reflect/Value#, column int) (astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.Nodescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/Node#, error) { |
| 444 | if e.isInvalidValuescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#isInvalidValue().(v) { |
| 445 | return e.encodeNilscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#encodeNil().(), nil |
| 446 | } |
| 447 | if e.canEncodeByMarshalerscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#canEncodeByMarshaler().(v) { |
| 448 | node, err := e.encodeByMarshalerscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#encodeByMarshaler().(ctx, v, column) |
| 449 | if err != nil { |
| 450 | return nil, err |
| 451 | } |
| 452 | return node, nil |
| 453 | } |
| 454 | switch v.Typescip-go gomod github.com/golang/go/src go1.21.0 reflect/Value#Type().().Kindscip-go gomod github.com/golang/go/src go1.21.0 reflect/Type#Kind().() { |
| 455 | case reflectscip-go gomod github.com/golang/go/src go1.21.0 reflect/.Intscip-go gomod github.com/golang/go/src go1.21.0 reflect/Int., reflectscip-go gomod github.com/golang/go/src go1.21.0 reflect/.Int8scip-go gomod github.com/golang/go/src go1.21.0 reflect/Int8., reflectscip-go gomod github.com/golang/go/src go1.21.0 reflect/.Int16scip-go gomod github.com/golang/go/src go1.21.0 reflect/Int16., reflectscip-go gomod github.com/golang/go/src go1.21.0 reflect/.Int32scip-go gomod github.com/golang/go/src go1.21.0 reflect/Int32., reflectscip-go gomod github.com/golang/go/src go1.21.0 reflect/.Int64scip-go gomod github.com/golang/go/src go1.21.0 reflect/Int64.: |
| 456 | return e.encodeIntscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#encodeInt().(v.Intscip-go gomod github.com/golang/go/src go1.21.0 reflect/Value#Int().()), nil |
| 457 | case reflectscip-go gomod github.com/golang/go/src go1.21.0 reflect/.Uintscip-go gomod github.com/golang/go/src go1.21.0 reflect/Uint., reflectscip-go gomod github.com/golang/go/src go1.21.0 reflect/.Uint8scip-go gomod github.com/golang/go/src go1.21.0 reflect/Uint8., reflectscip-go gomod github.com/golang/go/src go1.21.0 reflect/.Uint16scip-go gomod github.com/golang/go/src go1.21.0 reflect/Uint16., reflectscip-go gomod github.com/golang/go/src go1.21.0 reflect/.Uint32scip-go gomod github.com/golang/go/src go1.21.0 reflect/Uint32., reflectscip-go gomod github.com/golang/go/src go1.21.0 reflect/.Uint64scip-go gomod github.com/golang/go/src go1.21.0 reflect/Uint64.: |
| 458 | return e.encodeUintscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#encodeUint().(v.Uintscip-go gomod github.com/golang/go/src go1.21.0 reflect/Value#Uint().()), nil |
| 459 | case reflectscip-go gomod github.com/golang/go/src go1.21.0 reflect/.Float32scip-go gomod github.com/golang/go/src go1.21.0 reflect/Float32.: |
| 460 | return e.encodeFloatscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#encodeFloat().(v.Floatscip-go gomod github.com/golang/go/src go1.21.0 reflect/Value#Float().(), 32), nil |
| 461 | case reflectscip-go gomod github.com/golang/go/src go1.21.0 reflect/.Float64scip-go gomod github.com/golang/go/src go1.21.0 reflect/Float64.: |
| 462 | return e.encodeFloatscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#encodeFloat().(v.Floatscip-go gomod github.com/golang/go/src go1.21.0 reflect/Value#Float().(), 64), nil |
| 463 | case reflectscip-go gomod github.com/golang/go/src go1.21.0 reflect/.Ptrscip-go gomod github.com/golang/go/src go1.21.0 reflect/Ptr.: |
| 464 | if value := e.encodePtrAnchorscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#encodePtrAnchor().(v, column); value != nil { |
| 465 | return value, nil |
| 466 | } |
| 467 | return e.encodeValuescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#encodeValue().(ctx, v.Elemscip-go gomod github.com/golang/go/src go1.21.0 reflect/Value#Elem().(), column) |
| 468 | case reflectscip-go gomod github.com/golang/go/src go1.21.0 reflect/.Interfacescip-go gomod github.com/golang/go/src go1.21.0 reflect/Interface.: |
| 469 | return e.encodeValuescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#encodeValue().(ctx, v.Elemscip-go gomod github.com/golang/go/src go1.21.0 reflect/Value#Elem().(), column) |
| 470 | case reflectscip-go gomod github.com/golang/go/src go1.21.0 reflect/.Stringscip-go gomod github.com/golang/go/src go1.21.0 reflect/String.: |
| 471 | return e.encodeStringscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#encodeString().(v.Stringscip-go gomod github.com/golang/go/src go1.21.0 reflect/Value#String().(), column), nil |
| 472 | case reflectscip-go gomod github.com/golang/go/src go1.21.0 reflect/.Boolscip-go gomod github.com/golang/go/src go1.21.0 reflect/Bool.: |
| 473 | return e.encodeBoolscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#encodeBool().(v.Boolscip-go gomod github.com/golang/go/src go1.21.0 reflect/Value#Bool().()), nil |
| 474 | case reflectscip-go gomod github.com/golang/go/src go1.21.0 reflect/.Slicescip-go gomod github.com/golang/go/src go1.21.0 reflect/Slice.: |
| 475 | if mapSlice, ok := v.Interfacescip-go gomod github.com/golang/go/src go1.21.0 reflect/Value#Interface().().(MapSlicescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/MapSlice#); ok { |
| 476 | return e.encodeMapSlicescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#encodeMapSlice().(ctx, mapSlice, column) |
| 477 | } |
| 478 | if value := e.encodePtrAnchorscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#encodePtrAnchor().(v, column); value != nil { |
| 479 | return value, nil |
| 480 | } |
| 481 | return e.encodeSlicescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#encodeSlice().(ctx, v) |
| 482 | case reflectscip-go gomod github.com/golang/go/src go1.21.0 reflect/.Arrayscip-go gomod github.com/golang/go/src go1.21.0 reflect/Array.: |
| 483 | return e.encodeArrayscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#encodeArray().(ctx, v) |
| 484 | case reflectscip-go gomod github.com/golang/go/src go1.21.0 reflect/.Structscip-go gomod github.com/golang/go/src go1.21.0 reflect/Struct.: |
| 485 | if v.CanInterfacescip-go gomod github.com/golang/go/src go1.21.0 reflect/Value#CanInterface().() { |
| 486 | if mapItem, ok := v.Interfacescip-go gomod github.com/golang/go/src go1.21.0 reflect/Value#Interface().().(MapItemscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/MapItem#); ok { |
| 487 | return e.encodeMapItemscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#encodeMapItem().(ctx, mapItem, column) |
| 488 | } |
| 489 | if t, ok := v.Interfacescip-go gomod github.com/golang/go/src go1.21.0 reflect/Value#Interface().().(timescip-go gomod github.com/golang/go/src go1.21.0 time/.Timescip-go gomod github.com/golang/go/src go1.21.0 time/Time#); ok { |
| 490 | return e.encodeTimescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#encodeTime().(t, column), nil |
| 491 | } |
| 492 | } |
| 493 | return e.encodeStructscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#encodeStruct().(ctx, v, column) |
| 494 | case reflectscip-go gomod github.com/golang/go/src go1.21.0 reflect/.Mapscip-go gomod github.com/golang/go/src go1.21.0 reflect/Map.: |
| 495 | if value := e.encodePtrAnchorscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#encodePtrAnchor().(v, column); value != nil { |
| 496 | return value, nil |
| 497 | } |
| 498 | return e.encodeMapscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#encodeMap().(ctx, v, column) |
| 499 | default: |
| 500 | return nil, fmtscip-go gomod github.com/golang/go/src go1.21.0 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.21.0 fmt/Errorf().("unknown value type %s", v.Typescip-go gomod github.com/golang/go/src go1.21.0 reflect/Value#Type().().Stringscip-go gomod github.com/golang/go/src go1.21.0 reflect/Type#String().()) |
| 501 | } |
| 502 | } |
| 503 | |
| 504 | func (e *Encoderscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#) encodePtrAnchorscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#encodePtrAnchor().(v reflectscip-go gomod github.com/golang/go/src go1.21.0 reflect/.Valuescip-go gomod github.com/golang/go/src go1.21.0 reflect/Value#, column int) astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.Nodescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/Node# { |
| 505 | anchorName, exists := e.getAnchorscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#getAnchor().(v.Pointerscip-go gomod github.com/golang/go/src go1.21.0 reflect/Value#Pointer().()) |
| 506 | if !exists { |
| 507 | return nil |
| 508 | } |
| 509 | aliasName := anchorName |
| 510 | alias := astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.Aliasscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/Alias().(tokenscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/token`/.Newscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/token`/New().("*", "*", e.posscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#pos().(column))) |
| 511 | alias.Valuescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/AliasNode#Value. = astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.Stringscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/String().(tokenscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/token`/.Newscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/token`/New().(aliasName, aliasName, e.posscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#pos().(column))) |
| 512 | e.setSmartAliasscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#setSmartAlias().(aliasName, v.Pointerscip-go gomod github.com/golang/go/src go1.21.0 reflect/Value#Pointer().()) |
| 513 | return alias |
| 514 | } |
| 515 | |
| 516 | func (e *Encoderscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#) posscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#pos().(column int) *tokenscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/token`/.Positionscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/token`/Position# { |
| 517 | return &tokenscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/token`/.Positionscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/token`/Position#{ |
| 518 | Linescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/token`/Position#Line.: e.linescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#line., |
| 519 | Columnscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/token`/Position#Column.: column, |
| 520 | Offsetscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/token`/Position#Offset.: e.offsetscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#offset., |
| 521 | IndentNumscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/token`/Position#IndentNum.: e.indentNumscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#indentNum., |
| 522 | IndentLevelscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/token`/Position#IndentLevel.: e.indentLevelscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#indentLevel., |
| 523 | } |
| 524 | } |
| 525 | |
| 526 | func (e *Encoderscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#) encodeNilscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#encodeNil().() *astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.NullNodescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/NullNode# { |
| 527 | value := "null" |
| 528 | return astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.Nullscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/Null().(tokenscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/token`/.Newscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/token`/New().(value, value, e.posscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#pos().(e.columnscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#column.))) |
| 529 | } |
| 530 | |
| 531 | func (e *Encoderscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#) encodeIntscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#encodeInt().(v int64) *astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.IntegerNodescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/IntegerNode# { |
| 532 | value := strconvscip-go gomod github.com/golang/go/src go1.21.0 strconv/.FormatIntscip-go gomod github.com/golang/go/src go1.21.0 strconv/FormatInt().(v, 10) |
| 533 | return astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.Integerscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/Integer().(tokenscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/token`/.Newscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/token`/New().(value, value, e.posscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#pos().(e.columnscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#column.))) |
| 534 | } |
| 535 | |
| 536 | func (e *Encoderscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#) encodeUintscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#encodeUint().(v uint64) *astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.IntegerNodescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/IntegerNode# { |
| 537 | value := strconvscip-go gomod github.com/golang/go/src go1.21.0 strconv/.FormatUintscip-go gomod github.com/golang/go/src go1.21.0 strconv/FormatUint().(v, 10) |
| 538 | return astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.Integerscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/Integer().(tokenscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/token`/.Newscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/token`/New().(value, value, e.posscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#pos().(e.columnscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#column.))) |
| 539 | } |
| 540 | |
| 541 | func (e *Encoderscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#) encodeFloatscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#encodeFloat().(v float64, bitSize int) astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.Nodescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/Node# { |
| 542 | if v == mathscip-go gomod github.com/golang/go/src go1.21.0 math/.Infscip-go gomod github.com/golang/go/src go1.21.0 math/Inf().(0) { |
| 543 | value := ".inf" |
| 544 | return astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.Infinityscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/Infinity().(tokenscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/token`/.Newscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/token`/New().(value, value, e.posscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#pos().(e.columnscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#column.))) |
| 545 | } else if v == mathscip-go gomod github.com/golang/go/src go1.21.0 math/.Infscip-go gomod github.com/golang/go/src go1.21.0 math/Inf().(-1) { |
| 546 | value := "-.inf" |
| 547 | return astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.Infinityscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/Infinity().(tokenscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/token`/.Newscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/token`/New().(value, value, e.posscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#pos().(e.columnscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#column.))) |
| 548 | } else if mathscip-go gomod github.com/golang/go/src go1.21.0 math/.IsNaNscip-go gomod github.com/golang/go/src go1.21.0 math/IsNaN().(v) { |
| 549 | value := ".nan" |
| 550 | return astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.Nanscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/Nan().(tokenscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/token`/.Newscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/token`/New().(value, value, e.posscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#pos().(e.columnscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#column.))) |
| 551 | } |
| 552 | value := strconvscip-go gomod github.com/golang/go/src go1.21.0 strconv/.FormatFloatscip-go gomod github.com/golang/go/src go1.21.0 strconv/FormatFloat().(v, 'g', -1, bitSize) |
| 553 | if !stringsscip-go gomod github.com/golang/go/src go1.21.0 strings/.Containsscip-go gomod github.com/golang/go/src go1.21.0 strings/Contains().(value, ".") && !stringsscip-go gomod github.com/golang/go/src go1.21.0 strings/.Containsscip-go gomod github.com/golang/go/src go1.21.0 strings/Contains().(value, "e") { |
| 554 | if e.autoIntscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#autoInt. { |
| 555 | return astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.Integerscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/Integer().(tokenscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/token`/.Newscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/token`/New().(value, value, e.posscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#pos().(e.columnscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#column.))) |
| 556 | } |
| 557 | // append x.0 suffix to keep float value context |
| 558 | value = fmtscip-go gomod github.com/golang/go/src go1.21.0 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.21.0 fmt/Sprintf().("%s.0", value) |
| 559 | } |
| 560 | return astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.Floatscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/Float().(tokenscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/token`/.Newscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/token`/New().(value, value, e.posscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#pos().(e.columnscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#column.))) |
| 561 | } |
| 562 | |
| 563 | func (e *Encoderscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#) isNeedQuotedscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#isNeedQuoted().(v string) bool { |
| 564 | if e.isJSONStylescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#isJSONStyle. { |
| 565 | return true |
| 566 | } |
| 567 | if e.useLiteralStyleIfMultilinescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#useLiteralStyleIfMultiline. && stringsscip-go gomod github.com/golang/go/src go1.21.0 strings/.ContainsAnyscip-go gomod github.com/golang/go/src go1.21.0 strings/ContainsAny().(v, "\n\r") { |
| 568 | return false |
| 569 | } |
| 570 | if e.isFlowStylescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#isFlowStyle. && stringsscip-go gomod github.com/golang/go/src go1.21.0 strings/.ContainsAnyscip-go gomod github.com/golang/go/src go1.21.0 strings/ContainsAny().(v, `]},'"`) { |
| 571 | return true |
| 572 | } |
| 573 | if e.isFlowStylescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#isFlowStyle. { |
| 574 | for i := 0; i < len(v); i++ { |
| 575 | if v[i] != ':' { |
| 576 | continue |
| 577 | } |
| 578 | if i+1 < len(v) && v[i+1] == '/' { |
| 579 | continue |
| 580 | } |
| 581 | return true |
| 582 | } |
| 583 | } |
| 584 | if tokenscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/token`/.IsNeedQuotedscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/token`/IsNeedQuoted().(v) { |
| 585 | return true |
| 586 | } |
| 587 | return false |
| 588 | } |
| 589 | |
| 590 | func (e *Encoderscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#) encodeStringscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#encodeString().(v string, column int) *astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.StringNodescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/StringNode# { |
| 591 | if e.isNeedQuotedscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#isNeedQuoted().(v) { |
| 592 | if e.singleQuotescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#singleQuote. { |
| 593 | v = quoteWithscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/quoteWith().(v, '\'') |
| 594 | } else { |
| 595 | v = strconvscip-go gomod github.com/golang/go/src go1.21.0 strconv/.Quotescip-go gomod github.com/golang/go/src go1.21.0 strconv/Quote().(v) |
| 596 | } |
| 597 | } |
| 598 | return astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.Stringscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/String().(tokenscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/token`/.Newscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/token`/New().(v, v, e.posscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#pos().(column))) |
| 599 | } |
| 600 | |
| 601 | func (e *Encoderscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#) encodeBoolscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#encodeBool().(v bool) *astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.BoolNodescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/BoolNode# { |
| 602 | value := strconvscip-go gomod github.com/golang/go/src go1.21.0 strconv/.FormatBoolscip-go gomod github.com/golang/go/src go1.21.0 strconv/FormatBool().(v) |
| 603 | return astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.Boolscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/Bool().(tokenscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/token`/.Newscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/token`/New().(value, value, e.posscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#pos().(e.columnscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#column.))) |
| 604 | } |
| 605 | |
| 606 | func (e *Encoderscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#) encodeSlicescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#encodeSlice().(ctx contextscip-go gomod github.com/golang/go/src go1.21.0 context/.Contextscip-go gomod github.com/golang/go/src go1.21.0 context/Context#, value reflectscip-go gomod github.com/golang/go/src go1.21.0 reflect/.Valuescip-go gomod github.com/golang/go/src go1.21.0 reflect/Value#) (*astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.SequenceNodescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/SequenceNode#, error) { |
| 607 | if e.indentSequencescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#indentSequence. { |
| 608 | e.columnscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#column. += e.indentNumscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#indentNum. |
| 609 | defer func() { e.columnscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#column. -= e.indentNumscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#indentNum. }() |
| 610 | } |
| 611 | column := e.columnscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#column. |
| 612 | sequence := astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.Sequencescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/Sequence().(tokenscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/token`/.Newscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/token`/New().("-", "-", e.posscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#pos().(column)), e.isFlowStylescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#isFlowStyle.) |
| 613 | for i := 0; i < value.Lenscip-go gomod github.com/golang/go/src go1.21.0 reflect/Value#Len().(); i++ { |
| 614 | node, err := e.encodeValuescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#encodeValue().(ctx, value.Indexscip-go gomod github.com/golang/go/src go1.21.0 reflect/Value#Index().(i), column) |
| 615 | if err != nil { |
| 616 | return nil, err |
| 617 | } |
| 618 | sequence.Valuesscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/SequenceNode#Values. = append(sequence.Valuesscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/SequenceNode#Values., node) |
| 619 | } |
| 620 | return sequence, nil |
| 621 | } |
| 622 | |
| 623 | func (e *Encoderscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#) encodeArrayscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#encodeArray().(ctx contextscip-go gomod github.com/golang/go/src go1.21.0 context/.Contextscip-go gomod github.com/golang/go/src go1.21.0 context/Context#, value reflectscip-go gomod github.com/golang/go/src go1.21.0 reflect/.Valuescip-go gomod github.com/golang/go/src go1.21.0 reflect/Value#) (*astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.SequenceNodescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/SequenceNode#, error) { |
| 624 | if e.indentSequencescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#indentSequence. { |
| 625 | e.columnscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#column. += e.indentNumscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#indentNum. |
| 626 | defer func() { e.columnscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#column. -= e.indentNumscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#indentNum. }() |
| 627 | } |
| 628 | column := e.columnscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#column. |
| 629 | sequence := astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.Sequencescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/Sequence().(tokenscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/token`/.Newscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/token`/New().("-", "-", e.posscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#pos().(column)), e.isFlowStylescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#isFlowStyle.) |
| 630 | for i := 0; i < value.Lenscip-go gomod github.com/golang/go/src go1.21.0 reflect/Value#Len().(); i++ { |
| 631 | node, err := e.encodeValuescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#encodeValue().(ctx, value.Indexscip-go gomod github.com/golang/go/src go1.21.0 reflect/Value#Index().(i), column) |
| 632 | if err != nil { |
| 633 | return nil, err |
| 634 | } |
| 635 | sequence.Valuesscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/SequenceNode#Values. = append(sequence.Valuesscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/SequenceNode#Values., node) |
| 636 | } |
| 637 | return sequence, nil |
| 638 | } |
| 639 | |
| 640 | func (e *Encoderscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#) encodeMapItemscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#encodeMapItem().(ctx contextscip-go gomod github.com/golang/go/src go1.21.0 context/.Contextscip-go gomod github.com/golang/go/src go1.21.0 context/Context#, item MapItemscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/MapItem#, column int) (*astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.MappingValueNodescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/MappingValueNode#, error) { |
| 641 | k := reflectscip-go gomod github.com/golang/go/src go1.21.0 reflect/.ValueOfscip-go gomod github.com/golang/go/src go1.21.0 reflect/ValueOf().(item.Keyscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/MapItem#Key.) |
| 642 | v := reflectscip-go gomod github.com/golang/go/src go1.21.0 reflect/.ValueOfscip-go gomod github.com/golang/go/src go1.21.0 reflect/ValueOf().(item.Valuescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/MapItem#Value.) |
| 643 | value, err := e.encodeValuescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#encodeValue().(ctx, v, column) |
| 644 | if err != nil { |
| 645 | return nil, err |
| 646 | } |
| 647 | if e.isMapNodescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#isMapNode().(value) { |
| 648 | value.AddColumnscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/Node#AddColumn.(e.indentNumscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#indentNum.) |
| 649 | } |
| 650 | if e.isTagAndMapNodescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#isTagAndMapNode().(value) { |
| 651 | value.AddColumnscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/Node#AddColumn.(e.indentNumscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#indentNum.) |
| 652 | } |
| 653 | return astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.MappingValuescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/MappingValue().( |
| 654 | tokenscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/token`/.Newscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/token`/New().("", "", e.posscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#pos().(column)), |
| 655 | e.encodeStringscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#encodeString().(k.Interfacescip-go gomod github.com/golang/go/src go1.21.0 reflect/Value#Interface().().(string), column), |
| 656 | value, |
| 657 | ), nil |
| 658 | } |
| 659 | |
| 660 | func (e *Encoderscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#) encodeMapSlicescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#encodeMapSlice().(ctx contextscip-go gomod github.com/golang/go/src go1.21.0 context/.Contextscip-go gomod github.com/golang/go/src go1.21.0 context/Context#, value MapSlicescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/MapSlice#, column int) (*astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.MappingNodescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/MappingNode#, error) { |
| 661 | node := astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.Mappingscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/Mapping().(tokenscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/token`/.Newscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/token`/New().("", "", e.posscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#pos().(column)), e.isFlowStylescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#isFlowStyle.) |
| 662 | for _, item := range value { |
| 663 | encoded, err := e.encodeMapItemscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#encodeMapItem().(ctx, item, column) |
| 664 | if err != nil { |
| 665 | return nil, err |
| 666 | } |
| 667 | node.Valuesscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/MappingNode#Values. = append(node.Valuesscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/MappingNode#Values., encoded) |
| 668 | } |
| 669 | return node, nil |
| 670 | } |
| 671 | |
| 672 | func (e *Encoderscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#) isMapNodescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#isMapNode().(node astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.Nodescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/Node#) bool { |
| 673 | _, ok := node.(astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.MapNodescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/MapNode#) |
| 674 | return ok |
| 675 | } |
| 676 | |
| 677 | func (e *Encoderscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#) isTagAndMapNodescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#isTagAndMapNode().(node astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.Nodescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/Node#) bool { |
| 678 | tn, ok := node.(*astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.TagNodescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/TagNode#) |
| 679 | return ok && e.isMapNodescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#isMapNode().(tn.Valuescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/TagNode#Value.) |
| 680 | } |
| 681 | |
| 682 | func (e *Encoderscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#) encodeMapscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#encodeMap().(ctx contextscip-go gomod github.com/golang/go/src go1.21.0 context/.Contextscip-go gomod github.com/golang/go/src go1.21.0 context/Context#, value reflectscip-go gomod github.com/golang/go/src go1.21.0 reflect/.Valuescip-go gomod github.com/golang/go/src go1.21.0 reflect/Value#, column int) (astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.Nodescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/Node#, error) { |
| 683 | node := astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.Mappingscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/Mapping().(tokenscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/token`/.Newscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/token`/New().("", "", e.posscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#pos().(column)), e.isFlowStylescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#isFlowStyle.) |
| 684 | keys := make([]interface{}, len(value.MapKeysscip-go gomod github.com/golang/go/src go1.21.0 reflect/Value#MapKeys().())) |
| 685 | for i, k := range value.MapKeysscip-go gomod github.com/golang/go/src go1.21.0 reflect/Value#MapKeys().() { |
| 686 | keys[i] = k.Interfacescip-go gomod github.com/golang/go/src go1.21.0 reflect/Value#Interface().() |
| 687 | } |
| 688 | sortscip-go gomod github.com/golang/go/src go1.21.0 sort/.Slicescip-go gomod github.com/golang/go/src go1.21.0 sort/Slice().(keys, func(i, j int) bool { |
| 689 | return fmtscip-go gomod github.com/golang/go/src go1.21.0 fmt/.Sprintscip-go gomod github.com/golang/go/src go1.21.0 fmt/Sprint().(keys[i]) < fmtscip-go gomod github.com/golang/go/src go1.21.0 fmt/.Sprintscip-go gomod github.com/golang/go/src go1.21.0 fmt/Sprint().(keys[j]) |
| 690 | }) |
| 691 | for _, key := range keys { |
| 692 | k := reflectscip-go gomod github.com/golang/go/src go1.21.0 reflect/.ValueOfscip-go gomod github.com/golang/go/src go1.21.0 reflect/ValueOf().(key) |
| 693 | v := value.MapIndexscip-go gomod github.com/golang/go/src go1.21.0 reflect/Value#MapIndex().(k) |
| 694 | encoded, err := e.encodeValuescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#encodeValue().(ctx, v, column) |
| 695 | if err != nil { |
| 696 | return nil, err |
| 697 | } |
| 698 | if e.isMapNodescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#isMapNode().(encoded) { |
| 699 | encoded.AddColumnscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/Node#AddColumn.(e.indentNumscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#indentNum.) |
| 700 | } |
| 701 | if e.isTagAndMapNodescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#isTagAndMapNode().(encoded) { |
| 702 | encoded.AddColumnscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/Node#AddColumn.(e.indentNumscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#indentNum.) |
| 703 | } |
| 704 | keyText := fmtscip-go gomod github.com/golang/go/src go1.21.0 fmt/.Sprintscip-go gomod github.com/golang/go/src go1.21.0 fmt/Sprint().(key) |
| 705 | vRef := e.toPointerscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#toPointer().(v) |
| 706 | |
| 707 | // during the second encoding, an anchor is assigned if it is found to be used by an alias. |
| 708 | if aliasName, exists := e.getSmartAliasscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#getSmartAlias().(vRef); exists { |
| 709 | anchorName := aliasName |
| 710 | anchorNode := astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.Anchorscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/Anchor().(tokenscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/token`/.Newscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/token`/New().("&", "&", e.posscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#pos().(column))) |
| 711 | anchorNode.Namescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/AnchorNode#Name. = astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.Stringscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/String().(tokenscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/token`/.Newscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/token`/New().(anchorName, anchorName, e.posscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#pos().(column))) |
| 712 | anchorNode.Valuescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/AnchorNode#Value. = encoded |
| 713 | encoded = anchorNode |
| 714 | } |
| 715 | node.Valuesscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/MappingNode#Values. = append(node.Valuesscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/MappingNode#Values., astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.MappingValuescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/MappingValue().( |
| 716 | nil, |
| 717 | e.encodeStringscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#encodeString().(keyText, column), |
| 718 | encoded, |
| 719 | )) |
| 720 | e.setSmartAnchorscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#setSmartAnchor().(vRef, keyText) |
| 721 | } |
| 722 | return node, nil |
| 723 | } |
| 724 | |
| 725 | // IsZeroer is used to check whether an object is zero to determine |
| 726 | // whether it should be omitted when marshaling with the omitempty flag. |
| 727 | // One notable implementation is time.Time. |
| 728 | type IsZeroerscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/IsZeroer# interface { |
| 729 | IsZeroscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/IsZeroer#IsZero.() bool |
| 730 | } |
| 731 | |
| 732 | func (e *Encoderscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#) isOmittedByOmitZeroscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#isOmittedByOmitZero().(v reflectscip-go gomod github.com/golang/go/src go1.21.0 reflect/.Valuescip-go gomod github.com/golang/go/src go1.21.0 reflect/Value#) bool { |
| 733 | kind := v.Kindscip-go gomod github.com/golang/go/src go1.21.0 reflect/Value#Kind().() |
| 734 | if z, ok := v.Interfacescip-go gomod github.com/golang/go/src go1.21.0 reflect/Value#Interface().().(IsZeroerscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/IsZeroer#); ok { |
| 735 | if (kind == reflectscip-go gomod github.com/golang/go/src go1.21.0 reflect/.Ptrscip-go gomod github.com/golang/go/src go1.21.0 reflect/Ptr. || kind == reflectscip-go gomod github.com/golang/go/src go1.21.0 reflect/.Interfacescip-go gomod github.com/golang/go/src go1.21.0 reflect/Interface.) && v.IsNilscip-go gomod github.com/golang/go/src go1.21.0 reflect/Value#IsNil().() { |
| 736 | return true |
| 737 | } |
| 738 | return z.IsZeroscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/IsZeroer#IsZero.() |
| 739 | } |
| 740 | switch kind { |
| 741 | case reflectscip-go gomod github.com/golang/go/src go1.21.0 reflect/.Stringscip-go gomod github.com/golang/go/src go1.21.0 reflect/String.: |
| 742 | return len(v.Stringscip-go gomod github.com/golang/go/src go1.21.0 reflect/Value#String().()) == 0 |
| 743 | case reflectscip-go gomod github.com/golang/go/src go1.21.0 reflect/.Interfacescip-go gomod github.com/golang/go/src go1.21.0 reflect/Interface., reflectscip-go gomod github.com/golang/go/src go1.21.0 reflect/.Ptrscip-go gomod github.com/golang/go/src go1.21.0 reflect/Ptr., reflectscip-go gomod github.com/golang/go/src go1.21.0 reflect/.Slicescip-go gomod github.com/golang/go/src go1.21.0 reflect/Slice., reflectscip-go gomod github.com/golang/go/src go1.21.0 reflect/.Mapscip-go gomod github.com/golang/go/src go1.21.0 reflect/Map.: |
| 744 | return v.IsNilscip-go gomod github.com/golang/go/src go1.21.0 reflect/Value#IsNil().() |
| 745 | case reflectscip-go gomod github.com/golang/go/src go1.21.0 reflect/.Intscip-go gomod github.com/golang/go/src go1.21.0 reflect/Int., reflectscip-go gomod github.com/golang/go/src go1.21.0 reflect/.Int8scip-go gomod github.com/golang/go/src go1.21.0 reflect/Int8., reflectscip-go gomod github.com/golang/go/src go1.21.0 reflect/.Int16scip-go gomod github.com/golang/go/src go1.21.0 reflect/Int16., reflectscip-go gomod github.com/golang/go/src go1.21.0 reflect/.Int32scip-go gomod github.com/golang/go/src go1.21.0 reflect/Int32., reflectscip-go gomod github.com/golang/go/src go1.21.0 reflect/.Int64scip-go gomod github.com/golang/go/src go1.21.0 reflect/Int64.: |
| 746 | return v.Intscip-go gomod github.com/golang/go/src go1.21.0 reflect/Value#Int().() == 0 |
| 747 | case reflectscip-go gomod github.com/golang/go/src go1.21.0 reflect/.Float32scip-go gomod github.com/golang/go/src go1.21.0 reflect/Float32., reflectscip-go gomod github.com/golang/go/src go1.21.0 reflect/.Float64scip-go gomod github.com/golang/go/src go1.21.0 reflect/Float64.: |
| 748 | return v.Floatscip-go gomod github.com/golang/go/src go1.21.0 reflect/Value#Float().() == 0 |
| 749 | case reflectscip-go gomod github.com/golang/go/src go1.21.0 reflect/.Uintscip-go gomod github.com/golang/go/src go1.21.0 reflect/Uint., reflectscip-go gomod github.com/golang/go/src go1.21.0 reflect/.Uint8scip-go gomod github.com/golang/go/src go1.21.0 reflect/Uint8., reflectscip-go gomod github.com/golang/go/src go1.21.0 reflect/.Uint16scip-go gomod github.com/golang/go/src go1.21.0 reflect/Uint16., reflectscip-go gomod github.com/golang/go/src go1.21.0 reflect/.Uint32scip-go gomod github.com/golang/go/src go1.21.0 reflect/Uint32., reflectscip-go gomod github.com/golang/go/src go1.21.0 reflect/.Uint64scip-go gomod github.com/golang/go/src go1.21.0 reflect/Uint64., reflectscip-go gomod github.com/golang/go/src go1.21.0 reflect/.Uintptrscip-go gomod github.com/golang/go/src go1.21.0 reflect/Uintptr.: |
| 750 | return v.Uintscip-go gomod github.com/golang/go/src go1.21.0 reflect/Value#Uint().() == 0 |
| 751 | case reflectscip-go gomod github.com/golang/go/src go1.21.0 reflect/.Boolscip-go gomod github.com/golang/go/src go1.21.0 reflect/Bool.: |
| 752 | return !v.Boolscip-go gomod github.com/golang/go/src go1.21.0 reflect/Value#Bool().() |
| 753 | case reflectscip-go gomod github.com/golang/go/src go1.21.0 reflect/.Structscip-go gomod github.com/golang/go/src go1.21.0 reflect/Struct.: |
| 754 | vt := v.Typescip-go gomod github.com/golang/go/src go1.21.0 reflect/Value#Type().() |
| 755 | for i := v.NumFieldscip-go gomod github.com/golang/go/src go1.21.0 reflect/Value#NumField().() - 1; i >= 0; i-- { |
| 756 | if vt.Fieldscip-go gomod github.com/golang/go/src go1.21.0 reflect/Type#Field().(i).PkgPathscip-go gomod github.com/golang/go/src go1.21.0 reflect/StructField#PkgPath. != "" { |
| 757 | continue // private field |
| 758 | } |
| 759 | if !e.isOmittedByOmitZeroscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#isOmittedByOmitZero().(v.Fieldscip-go gomod github.com/golang/go/src go1.21.0 reflect/Value#Field().(i)) { |
| 760 | return false |
| 761 | } |
| 762 | } |
| 763 | return true |
| 764 | } |
| 765 | return false |
| 766 | } |
| 767 | |
| 768 | func (e *Encoderscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#) isOmittedByOmitEmptyOptionscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#isOmittedByOmitEmptyOption().(v reflectscip-go gomod github.com/golang/go/src go1.21.0 reflect/.Valuescip-go gomod github.com/golang/go/src go1.21.0 reflect/Value#) bool { |
| 769 | switch v.Kindscip-go gomod github.com/golang/go/src go1.21.0 reflect/Value#Kind().() { |
| 770 | case reflectscip-go gomod github.com/golang/go/src go1.21.0 reflect/.Stringscip-go gomod github.com/golang/go/src go1.21.0 reflect/String.: |
| 771 | return len(v.Stringscip-go gomod github.com/golang/go/src go1.21.0 reflect/Value#String().()) == 0 |
| 772 | case reflectscip-go gomod github.com/golang/go/src go1.21.0 reflect/.Interfacescip-go gomod github.com/golang/go/src go1.21.0 reflect/Interface., reflectscip-go gomod github.com/golang/go/src go1.21.0 reflect/.Ptrscip-go gomod github.com/golang/go/src go1.21.0 reflect/Ptr.: |
| 773 | return v.IsNilscip-go gomod github.com/golang/go/src go1.21.0 reflect/Value#IsNil().() |
| 774 | case reflectscip-go gomod github.com/golang/go/src go1.21.0 reflect/.Slicescip-go gomod github.com/golang/go/src go1.21.0 reflect/Slice., reflectscip-go gomod github.com/golang/go/src go1.21.0 reflect/.Mapscip-go gomod github.com/golang/go/src go1.21.0 reflect/Map.: |
| 775 | return v.Lenscip-go gomod github.com/golang/go/src go1.21.0 reflect/Value#Len().() == 0 |
| 776 | case reflectscip-go gomod github.com/golang/go/src go1.21.0 reflect/.Intscip-go gomod github.com/golang/go/src go1.21.0 reflect/Int., reflectscip-go gomod github.com/golang/go/src go1.21.0 reflect/.Int8scip-go gomod github.com/golang/go/src go1.21.0 reflect/Int8., reflectscip-go gomod github.com/golang/go/src go1.21.0 reflect/.Int16scip-go gomod github.com/golang/go/src go1.21.0 reflect/Int16., reflectscip-go gomod github.com/golang/go/src go1.21.0 reflect/.Int32scip-go gomod github.com/golang/go/src go1.21.0 reflect/Int32., reflectscip-go gomod github.com/golang/go/src go1.21.0 reflect/.Int64scip-go gomod github.com/golang/go/src go1.21.0 reflect/Int64.: |
| 777 | return v.Intscip-go gomod github.com/golang/go/src go1.21.0 reflect/Value#Int().() == 0 |
| 778 | case reflectscip-go gomod github.com/golang/go/src go1.21.0 reflect/.Float32scip-go gomod github.com/golang/go/src go1.21.0 reflect/Float32., reflectscip-go gomod github.com/golang/go/src go1.21.0 reflect/.Float64scip-go gomod github.com/golang/go/src go1.21.0 reflect/Float64.: |
| 779 | return v.Floatscip-go gomod github.com/golang/go/src go1.21.0 reflect/Value#Float().() == 0 |
| 780 | case reflectscip-go gomod github.com/golang/go/src go1.21.0 reflect/.Uintscip-go gomod github.com/golang/go/src go1.21.0 reflect/Uint., reflectscip-go gomod github.com/golang/go/src go1.21.0 reflect/.Uint8scip-go gomod github.com/golang/go/src go1.21.0 reflect/Uint8., reflectscip-go gomod github.com/golang/go/src go1.21.0 reflect/.Uint16scip-go gomod github.com/golang/go/src go1.21.0 reflect/Uint16., reflectscip-go gomod github.com/golang/go/src go1.21.0 reflect/.Uint32scip-go gomod github.com/golang/go/src go1.21.0 reflect/Uint32., reflectscip-go gomod github.com/golang/go/src go1.21.0 reflect/.Uint64scip-go gomod github.com/golang/go/src go1.21.0 reflect/Uint64., reflectscip-go gomod github.com/golang/go/src go1.21.0 reflect/.Uintptrscip-go gomod github.com/golang/go/src go1.21.0 reflect/Uintptr.: |
| 781 | return v.Uintscip-go gomod github.com/golang/go/src go1.21.0 reflect/Value#Uint().() == 0 |
| 782 | case reflectscip-go gomod github.com/golang/go/src go1.21.0 reflect/.Boolscip-go gomod github.com/golang/go/src go1.21.0 reflect/Bool.: |
| 783 | return !v.Boolscip-go gomod github.com/golang/go/src go1.21.0 reflect/Value#Bool().() |
| 784 | } |
| 785 | return false |
| 786 | } |
| 787 | |
| 788 | // The current implementation of the omitempty tag combines the functionality of encoding/json's omitempty and omitzero tags. |
| 789 | // This stems from a historical decision to respect the implementation of gopkg.in/yaml.v2, but it has caused confusion, |
| 790 | // so we are working to integrate it into the functionality of encoding/json. (However, this will take some time.) |
| 791 | // In the current implementation, in addition to the exclusion conditions of omitempty, |
| 792 | // if a type implements IsZero, that implementation will be used. |
| 793 | // Furthermore, for non-pointer structs, if all fields are eligible for exclusion, |
| 794 | // the struct itself will also be excluded. These behaviors are originally the functionality of omitzero. |
| 795 | func (e *Encoderscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#) isOmittedByOmitEmptyTagscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#isOmittedByOmitEmptyTag().(v reflectscip-go gomod github.com/golang/go/src go1.21.0 reflect/.Valuescip-go gomod github.com/golang/go/src go1.21.0 reflect/Value#) bool { |
| 796 | kind := v.Kindscip-go gomod github.com/golang/go/src go1.21.0 reflect/Value#Kind().() |
| 797 | if z, ok := v.Interfacescip-go gomod github.com/golang/go/src go1.21.0 reflect/Value#Interface().().(IsZeroerscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/IsZeroer#); ok { |
| 798 | if (kind == reflectscip-go gomod github.com/golang/go/src go1.21.0 reflect/.Ptrscip-go gomod github.com/golang/go/src go1.21.0 reflect/Ptr. || kind == reflectscip-go gomod github.com/golang/go/src go1.21.0 reflect/.Interfacescip-go gomod github.com/golang/go/src go1.21.0 reflect/Interface.) && v.IsNilscip-go gomod github.com/golang/go/src go1.21.0 reflect/Value#IsNil().() { |
| 799 | return true |
| 800 | } |
| 801 | return z.IsZeroscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/IsZeroer#IsZero.() |
| 802 | } |
| 803 | switch kind { |
| 804 | case reflectscip-go gomod github.com/golang/go/src go1.21.0 reflect/.Stringscip-go gomod github.com/golang/go/src go1.21.0 reflect/String.: |
| 805 | return len(v.Stringscip-go gomod github.com/golang/go/src go1.21.0 reflect/Value#String().()) == 0 |
| 806 | case reflectscip-go gomod github.com/golang/go/src go1.21.0 reflect/.Interfacescip-go gomod github.com/golang/go/src go1.21.0 reflect/Interface., reflectscip-go gomod github.com/golang/go/src go1.21.0 reflect/.Ptrscip-go gomod github.com/golang/go/src go1.21.0 reflect/Ptr.: |
| 807 | return v.IsNilscip-go gomod github.com/golang/go/src go1.21.0 reflect/Value#IsNil().() |
| 808 | case reflectscip-go gomod github.com/golang/go/src go1.21.0 reflect/.Slicescip-go gomod github.com/golang/go/src go1.21.0 reflect/Slice., reflectscip-go gomod github.com/golang/go/src go1.21.0 reflect/.Mapscip-go gomod github.com/golang/go/src go1.21.0 reflect/Map.: |
| 809 | return v.Lenscip-go gomod github.com/golang/go/src go1.21.0 reflect/Value#Len().() == 0 |
| 810 | case reflectscip-go gomod github.com/golang/go/src go1.21.0 reflect/.Intscip-go gomod github.com/golang/go/src go1.21.0 reflect/Int., reflectscip-go gomod github.com/golang/go/src go1.21.0 reflect/.Int8scip-go gomod github.com/golang/go/src go1.21.0 reflect/Int8., reflectscip-go gomod github.com/golang/go/src go1.21.0 reflect/.Int16scip-go gomod github.com/golang/go/src go1.21.0 reflect/Int16., reflectscip-go gomod github.com/golang/go/src go1.21.0 reflect/.Int32scip-go gomod github.com/golang/go/src go1.21.0 reflect/Int32., reflectscip-go gomod github.com/golang/go/src go1.21.0 reflect/.Int64scip-go gomod github.com/golang/go/src go1.21.0 reflect/Int64.: |
| 811 | return v.Intscip-go gomod github.com/golang/go/src go1.21.0 reflect/Value#Int().() == 0 |
| 812 | case reflectscip-go gomod github.com/golang/go/src go1.21.0 reflect/.Float32scip-go gomod github.com/golang/go/src go1.21.0 reflect/Float32., reflectscip-go gomod github.com/golang/go/src go1.21.0 reflect/.Float64scip-go gomod github.com/golang/go/src go1.21.0 reflect/Float64.: |
| 813 | return v.Floatscip-go gomod github.com/golang/go/src go1.21.0 reflect/Value#Float().() == 0 |
| 814 | case reflectscip-go gomod github.com/golang/go/src go1.21.0 reflect/.Uintscip-go gomod github.com/golang/go/src go1.21.0 reflect/Uint., reflectscip-go gomod github.com/golang/go/src go1.21.0 reflect/.Uint8scip-go gomod github.com/golang/go/src go1.21.0 reflect/Uint8., reflectscip-go gomod github.com/golang/go/src go1.21.0 reflect/.Uint16scip-go gomod github.com/golang/go/src go1.21.0 reflect/Uint16., reflectscip-go gomod github.com/golang/go/src go1.21.0 reflect/.Uint32scip-go gomod github.com/golang/go/src go1.21.0 reflect/Uint32., reflectscip-go gomod github.com/golang/go/src go1.21.0 reflect/.Uint64scip-go gomod github.com/golang/go/src go1.21.0 reflect/Uint64., reflectscip-go gomod github.com/golang/go/src go1.21.0 reflect/.Uintptrscip-go gomod github.com/golang/go/src go1.21.0 reflect/Uintptr.: |
| 815 | return v.Uintscip-go gomod github.com/golang/go/src go1.21.0 reflect/Value#Uint().() == 0 |
| 816 | case reflectscip-go gomod github.com/golang/go/src go1.21.0 reflect/.Boolscip-go gomod github.com/golang/go/src go1.21.0 reflect/Bool.: |
| 817 | return !v.Boolscip-go gomod github.com/golang/go/src go1.21.0 reflect/Value#Bool().() |
| 818 | case reflectscip-go gomod github.com/golang/go/src go1.21.0 reflect/.Structscip-go gomod github.com/golang/go/src go1.21.0 reflect/Struct.: |
| 819 | vt := v.Typescip-go gomod github.com/golang/go/src go1.21.0 reflect/Value#Type().() |
| 820 | for i := v.NumFieldscip-go gomod github.com/golang/go/src go1.21.0 reflect/Value#NumField().() - 1; i >= 0; i-- { |
| 821 | if vt.Fieldscip-go gomod github.com/golang/go/src go1.21.0 reflect/Type#Field().(i).PkgPathscip-go gomod github.com/golang/go/src go1.21.0 reflect/StructField#PkgPath. != "" { |
| 822 | continue // private field |
| 823 | } |
| 824 | if !e.isOmittedByOmitEmptyTagscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#isOmittedByOmitEmptyTag().(v.Fieldscip-go gomod github.com/golang/go/src go1.21.0 reflect/Value#Field().(i)) { |
| 825 | return false |
| 826 | } |
| 827 | } |
| 828 | return true |
| 829 | } |
| 830 | return false |
| 831 | } |
| 832 | |
| 833 | func (e *Encoderscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#) encodeTimescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#encodeTime().(v timescip-go gomod github.com/golang/go/src go1.21.0 time/.Timescip-go gomod github.com/golang/go/src go1.21.0 time/Time#, column int) *astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.StringNodescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/StringNode# { |
| 834 | value := v.Formatscip-go gomod github.com/golang/go/src go1.21.0 time/Time#Format().(timescip-go gomod github.com/golang/go/src go1.21.0 time/.RFC3339Nanoscip-go gomod github.com/golang/go/src go1.21.0 time/RFC3339Nano.) |
| 835 | if e.isJSONStylescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#isJSONStyle. { |
| 836 | value = strconvscip-go gomod github.com/golang/go/src go1.21.0 strconv/.Quotescip-go gomod github.com/golang/go/src go1.21.0 strconv/Quote().(value) |
| 837 | } |
| 838 | return astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.Stringscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/String().(tokenscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/token`/.Newscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/token`/New().(value, value, e.posscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#pos().(column))) |
| 839 | } |
| 840 | |
| 841 | func (e *Encoderscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#) encodeDurationscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#encodeDuration().(v timescip-go gomod github.com/golang/go/src go1.21.0 time/.Durationscip-go gomod github.com/golang/go/src go1.21.0 time/Duration#, column int) *astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.StringNodescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/StringNode# { |
| 842 | value := v.Stringscip-go gomod github.com/golang/go/src go1.21.0 time/Duration#String().() |
| 843 | if e.isJSONStylescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#isJSONStyle. { |
| 844 | value = strconvscip-go gomod github.com/golang/go/src go1.21.0 strconv/.Quotescip-go gomod github.com/golang/go/src go1.21.0 strconv/Quote().(value) |
| 845 | } |
| 846 | return astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.Stringscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/String().(tokenscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/token`/.Newscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/token`/New().(value, value, e.posscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#pos().(column))) |
| 847 | } |
| 848 | |
| 849 | func (e *Encoderscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#) encodeAnchorscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#encodeAnchor().(anchorName string, value astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.Nodescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/Node#, fieldValue reflectscip-go gomod github.com/golang/go/src go1.21.0 reflect/.Valuescip-go gomod github.com/golang/go/src go1.21.0 reflect/Value#, column int) (*astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.AnchorNodescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/AnchorNode#, error) { |
| 850 | anchorNode := astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.Anchorscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/Anchor().(tokenscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/token`/.Newscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/token`/New().("&", "&", e.posscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#pos().(column))) |
| 851 | anchorNode.Namescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/AnchorNode#Name. = astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.Stringscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/String().(tokenscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/token`/.Newscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/token`/New().(anchorName, anchorName, e.posscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#pos().(column))) |
| 852 | anchorNode.Valuescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/AnchorNode#Value. = value |
| 853 | if e.anchorCallbackscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#anchorCallback. != nil { |
| 854 | if err := e.anchorCallbackscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#anchorCallback.(anchorNode, fieldValue.Interfacescip-go gomod github.com/golang/go/src go1.21.0 reflect/Value#Interface().()); err != nil { |
| 855 | return nil, err |
| 856 | } |
| 857 | if snode, ok := anchorNode.Namescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/AnchorNode#Name..(*astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.StringNodescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/StringNode#); ok { |
| 858 | anchorName = snode.Valuescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/StringNode#Value. |
| 859 | } |
| 860 | } |
| 861 | if fieldValue.Kindscip-go gomod github.com/golang/go/src go1.21.0 reflect/Value#Kind().() == reflectscip-go gomod github.com/golang/go/src go1.21.0 reflect/.Ptrscip-go gomod github.com/golang/go/src go1.21.0 reflect/Ptr. { |
| 862 | e.setAnchorscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#setAnchor().(fieldValue.Pointerscip-go gomod github.com/golang/go/src go1.21.0 reflect/Value#Pointer().(), anchorName) |
| 863 | } |
| 864 | return anchorNode, nil |
| 865 | } |
| 866 | |
| 867 | func (e *Encoderscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#) encodeStructscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#encodeStruct().(ctx contextscip-go gomod github.com/golang/go/src go1.21.0 context/.Contextscip-go gomod github.com/golang/go/src go1.21.0 context/Context#, value reflectscip-go gomod github.com/golang/go/src go1.21.0 reflect/.Valuescip-go gomod github.com/golang/go/src go1.21.0 reflect/Value#, column int) (astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.Nodescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/Node#, error) { |
| 868 | node := astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.Mappingscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/Mapping().(tokenscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/token`/.Newscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/token`/New().("", "", e.posscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#pos().(column)), e.isFlowStylescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#isFlowStyle.) |
| 869 | structType := value.Typescip-go gomod github.com/golang/go/src go1.21.0 reflect/Value#Type().() |
| 870 | fieldMap, err := structFieldMapscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/structFieldMap().(structType) |
| 871 | if err != nil { |
| 872 | return nil, err |
| 873 | } |
| 874 | hasInlineAnchorField := false |
| 875 | var inlineAnchorValue reflectscip-go gomod github.com/golang/go/src go1.21.0 reflect/.Valuescip-go gomod github.com/golang/go/src go1.21.0 reflect/Value# |
| 876 | for i := 0; i < value.NumFieldscip-go gomod github.com/golang/go/src go1.21.0 reflect/Value#NumField().(); i++ { |
| 877 | field := structType.Fieldscip-go gomod github.com/golang/go/src go1.21.0 reflect/Type#Field().(i) |
| 878 | if isIgnoredStructFieldscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/isIgnoredStructField().(field) { |
| 879 | continue |
| 880 | } |
| 881 | fieldValue := value.FieldByNamescip-go gomod github.com/golang/go/src go1.21.0 reflect/Value#FieldByName().(field.Namescip-go gomod github.com/golang/go/src go1.21.0 reflect/StructField#Name.) |
| 882 | sf := fieldMap[field.Namescip-go gomod github.com/golang/go/src go1.21.0 reflect/StructField#Name.] |
| 883 | if (e.omitZeroscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#omitZero. || sf.IsOmitZeroscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/StructField#IsOmitZero.) && e.isOmittedByOmitZeroscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#isOmittedByOmitZero().(fieldValue) { |
| 884 | // omit encoding by omitzero tag or OmitZero option. |
| 885 | continue |
| 886 | } |
| 887 | if e.omitEmptyscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#omitEmpty. && e.isOmittedByOmitEmptyOptionscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#isOmittedByOmitEmptyOption().(fieldValue) { |
| 888 | // omit encoding by OmitEmpty option. |
| 889 | continue |
| 890 | } |
| 891 | if sf.IsOmitEmptyscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/StructField#IsOmitEmpty. && e.isOmittedByOmitEmptyTagscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#isOmittedByOmitEmptyTag().(fieldValue) { |
| 892 | // omit encoding by omitempty tag. |
| 893 | continue |
| 894 | } |
| 895 | ve := e |
| 896 | if !e.isFlowStylescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#isFlowStyle. && sf.IsFlowscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/StructField#IsFlow. { |
| 897 | ve = &Encoderscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#{} |
| 898 | *ve = *e |
| 899 | ve.isFlowStylescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#isFlowStyle. = true |
| 900 | } |
| 901 | encoded, err := ve.encodeValuescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#encodeValue().(ctx, fieldValue, column) |
| 902 | if err != nil { |
| 903 | return nil, err |
| 904 | } |
| 905 | if e.isMapNodescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#isMapNode().(encoded) { |
| 906 | encoded.AddColumnscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/Node#AddColumn.(e.indentNumscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#indentNum.) |
| 907 | } |
| 908 | var key astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.MapKeyNodescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/MapKeyNode# = e.encodeStringscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#encodeString().(sf.RenderNamescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/StructField#RenderName., column) |
| 909 | switch { |
| 910 | case encoded.Typescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/Node#Type.() == astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.AliasTypescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/AliasType.: |
| 911 | if aliasName := sf.AliasNamescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/StructField#AliasName.; aliasName != "" { |
| 912 | alias, ok := encoded.(*astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.AliasNodescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/AliasNode#) |
| 913 | if !ok { |
| 914 | return nil, errorsscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/errors`/.ErrUnexpectedNodeTypescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/errors`/ErrUnexpectedNodeType().(encoded.Typescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/Node#Type.(), astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.AliasTypescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/AliasType., encoded.GetTokenscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/Node#GetToken.()) |
| 915 | } |
| 916 | got := alias.Valuescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/AliasNode#Value..Stringscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/Node#String.() |
| 917 | if aliasName != got { |
| 918 | return nil, fmtscip-go gomod github.com/golang/go/src go1.21.0 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.21.0 fmt/Errorf().("expected alias name is %q but got %q", aliasName, got) |
| 919 | } |
| 920 | } |
| 921 | if sf.IsInlinescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/StructField#IsInline. { |
| 922 | // if both used alias and inline, output `<<: *alias` |
| 923 | key = astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.MergeKeyscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/MergeKey().(tokenscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/token`/.Newscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/token`/New().("<<", "<<", e.posscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#pos().(column))) |
| 924 | } |
| 925 | case sf.AnchorNamescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/StructField#AnchorName. != "": |
| 926 | anchorNode, err := e.encodeAnchorscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#encodeAnchor().(sf.AnchorNamescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/StructField#AnchorName., encoded, fieldValue, column) |
| 927 | if err != nil { |
| 928 | return nil, err |
| 929 | } |
| 930 | encoded = anchorNode |
| 931 | case sf.IsInlinescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/StructField#IsInline.: |
| 932 | isAutoAnchor := sf.IsAutoAnchorscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/StructField#IsAutoAnchor. |
| 933 | if !hasInlineAnchorField { |
| 934 | hasInlineAnchorField = isAutoAnchor |
| 935 | } |
| 936 | if isAutoAnchor { |
| 937 | inlineAnchorValue = fieldValue |
| 938 | } |
| 939 | mapNode, ok := encoded.(astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.MapNodescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/MapNode#) |
| 940 | if !ok { |
| 941 | // if an inline field is null, skip encoding it |
| 942 | if _, ok := encoded.(*astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.NullNodescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/NullNode#); ok { |
| 943 | continue |
| 944 | } |
| 945 | return nil, errorsscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/errors`/.Newscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/errors`/New.("inline value is must be map or struct type") |
| 946 | } |
| 947 | mapIter := mapNode.MapRangescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/MapNode#MapRange.() |
| 948 | for mapIter.Nextscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/MapNodeIter#Next().() { |
| 949 | mapKey := mapIter.Keyscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/MapNodeIter#Key().() |
| 950 | mapValue := mapIter.Valuescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/MapNodeIter#Value().() |
| 951 | keyName := mapKey.GetTokenscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/Node#GetToken.().Valuescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/token`/Token#Value. |
| 952 | if fieldMap.isIncludedRenderNamescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/StructFieldMap#isIncludedRenderName().(keyName) { |
| 953 | // if declared the same key name, skip encoding this field |
| 954 | continue |
| 955 | } |
| 956 | mapKey.AddColumnscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/Node#AddColumn.(-e.indentNumscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#indentNum.) |
| 957 | mapValue.AddColumnscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/Node#AddColumn.(-e.indentNumscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#indentNum.) |
| 958 | node.Valuesscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/MappingNode#Values. = append(node.Valuesscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/MappingNode#Values., astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.MappingValuescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/MappingValue().(nil, mapKey, mapValue)) |
| 959 | } |
| 960 | continue |
| 961 | case sf.IsAutoAnchorscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/StructField#IsAutoAnchor.: |
| 962 | anchorNode, err := e.encodeAnchorscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#encodeAnchor().(sf.RenderNamescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/StructField#RenderName., encoded, fieldValue, column) |
| 963 | if err != nil { |
| 964 | return nil, err |
| 965 | } |
| 966 | encoded = anchorNode |
| 967 | } |
| 968 | node.Valuesscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/MappingNode#Values. = append(node.Valuesscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/MappingNode#Values., astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.MappingValuescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/MappingValue().(nil, key, encoded)) |
| 969 | } |
| 970 | if hasInlineAnchorField { |
| 971 | node.AddColumnscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/MappingNode#AddColumn().(e.indentNumscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#indentNum.) |
| 972 | anchorName := "anchor" |
| 973 | anchorNode := astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.Anchorscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/Anchor().(tokenscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/token`/.Newscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/token`/New().("&", "&", e.posscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#pos().(column))) |
| 974 | anchorNode.Namescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/AnchorNode#Name. = astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.Stringscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/String().(tokenscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/token`/.Newscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/token`/New().(anchorName, anchorName, e.posscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#pos().(column))) |
| 975 | anchorNode.Valuescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/AnchorNode#Value. = node |
| 976 | if e.anchorCallbackscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#anchorCallback. != nil { |
| 977 | if err := e.anchorCallbackscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#anchorCallback.(anchorNode, value.Addrscip-go gomod github.com/golang/go/src go1.21.0 reflect/Value#Addr().().Interfacescip-go gomod github.com/golang/go/src go1.21.0 reflect/Value#Interface().()); err != nil { |
| 978 | return nil, err |
| 979 | } |
| 980 | if snode, ok := anchorNode.Namescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/AnchorNode#Name..(*astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.StringNodescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/StringNode#); ok { |
| 981 | anchorName = snode.Valuescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/StringNode#Value. |
| 982 | } |
| 983 | } |
| 984 | if inlineAnchorValue.Kindscip-go gomod github.com/golang/go/src go1.21.0 reflect/Value#Kind().() == reflectscip-go gomod github.com/golang/go/src go1.21.0 reflect/.Ptrscip-go gomod github.com/golang/go/src go1.21.0 reflect/Ptr. { |
| 985 | e.setAnchorscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#setAnchor().(inlineAnchorValue.Pointerscip-go gomod github.com/golang/go/src go1.21.0 reflect/Value#Pointer().(), anchorName) |
| 986 | } |
| 987 | return anchorNode, nil |
| 988 | } |
| 989 | return node, nil |
| 990 | } |
| 991 | |
| 992 | func (e *Encoderscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#) toPointerscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#toPointer().(v reflectscip-go gomod github.com/golang/go/src go1.21.0 reflect/.Valuescip-go gomod github.com/golang/go/src go1.21.0 reflect/Value#) uintptr { |
| 993 | if e.isInvalidValuescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#isInvalidValue().(v) { |
| 994 | return 0 |
| 995 | } |
| 996 | |
| 997 | switch v.Typescip-go gomod github.com/golang/go/src go1.21.0 reflect/Value#Type().().Kindscip-go gomod github.com/golang/go/src go1.21.0 reflect/Type#Kind().() { |
| 998 | case reflectscip-go gomod github.com/golang/go/src go1.21.0 reflect/.Ptrscip-go gomod github.com/golang/go/src go1.21.0 reflect/Ptr.: |
| 999 | return v.Pointerscip-go gomod github.com/golang/go/src go1.21.0 reflect/Value#Pointer().() |
| 1000 | case reflectscip-go gomod github.com/golang/go/src go1.21.0 reflect/.Interfacescip-go gomod github.com/golang/go/src go1.21.0 reflect/Interface.: |
| 1001 | return e.toPointerscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#toPointer().(v.Elemscip-go gomod github.com/golang/go/src go1.21.0 reflect/Value#Elem().()) |
| 1002 | case reflectscip-go gomod github.com/golang/go/src go1.21.0 reflect/.Slicescip-go gomod github.com/golang/go/src go1.21.0 reflect/Slice.: |
| 1003 | return v.Pointerscip-go gomod github.com/golang/go/src go1.21.0 reflect/Value#Pointer().() |
| 1004 | case reflectscip-go gomod github.com/golang/go/src go1.21.0 reflect/.Mapscip-go gomod github.com/golang/go/src go1.21.0 reflect/Map.: |
| 1005 | return v.Pointerscip-go gomod github.com/golang/go/src go1.21.0 reflect/Value#Pointer().() |
| 1006 | } |
| 1007 | return 0 |
| 1008 | } |
| 1009 | |
| 1010 | func (e *Encoderscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#) clearSmartAnchorRefscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#clearSmartAnchorRef().() { |
| 1011 | if !e.enableSmartAnchorscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#enableSmartAnchor. { |
| 1012 | return |
| 1013 | } |
| 1014 | e.anchorRefToNamescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#anchorRefToName. = make(map[uintptr]string) |
| 1015 | e.anchorNameMapscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#anchorNameMap. = make(map[string]struct{}) |
| 1016 | } |
| 1017 | |
| 1018 | func (e *Encoderscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#) setSmartAnchorscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#setSmartAnchor().(ptr uintptr, name string) { |
| 1019 | if !e.enableSmartAnchorscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#enableSmartAnchor. { |
| 1020 | return |
| 1021 | } |
| 1022 | e.setAnchorscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#setAnchor().(ptr, e.generateAnchorNamescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#generateAnchorName().(name)) |
| 1023 | } |
| 1024 | |
| 1025 | func (e *Encoderscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#) setAnchorscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#setAnchor().(ptr uintptr, name string) { |
| 1026 | if ptr == 0 { |
| 1027 | return |
| 1028 | } |
| 1029 | if name == "" { |
| 1030 | return |
| 1031 | } |
| 1032 | e.anchorRefToNamescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#anchorRefToName.[ptr] = name |
| 1033 | e.anchorNameMapscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#anchorNameMap.[name] = struct{}{} |
| 1034 | } |
| 1035 | |
| 1036 | func (e *Encoderscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#) generateAnchorNamescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#generateAnchorName().(base string) string { |
| 1037 | if _, exists := e.anchorNameMapscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#anchorNameMap.[base]; !exists { |
| 1038 | return base |
| 1039 | } |
| 1040 | for i := 1; i < 100; i++ { |
| 1041 | name := base + strconvscip-go gomod github.com/golang/go/src go1.21.0 strconv/.Itoascip-go gomod github.com/golang/go/src go1.21.0 strconv/Itoa().(i) |
| 1042 | if _, exists := e.anchorNameMapscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#anchorNameMap.[name]; exists { |
| 1043 | continue |
| 1044 | } |
| 1045 | return name |
| 1046 | } |
| 1047 | return "" |
| 1048 | } |
| 1049 | |
| 1050 | func (e *Encoderscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#) getAnchorscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#getAnchor().(ref uintptr) (string, bool) { |
| 1051 | anchorName, exists := e.anchorRefToNamescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#anchorRefToName.[ref] |
| 1052 | return anchorName, exists |
| 1053 | } |
| 1054 | |
| 1055 | func (e *Encoderscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#) setSmartAliasscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#setSmartAlias().(name string, ref uintptr) { |
| 1056 | if !e.enableSmartAnchorscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#enableSmartAnchor. { |
| 1057 | return |
| 1058 | } |
| 1059 | e.aliasRefToNamescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#aliasRefToName.[ref] = name |
| 1060 | } |
| 1061 | |
| 1062 | func (e *Encoderscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#) getSmartAliasscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#getSmartAlias().(ref uintptr) (string, bool) { |
| 1063 | if !e.enableSmartAnchorscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#enableSmartAnchor. { |
| 1064 | return "", false |
| 1065 | } |
| 1066 | aliasName, exists := e.aliasRefToNamescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Encoder#aliasRefToName.[ref] |
| 1067 | return aliasName, exists |
| 1068 | } |