MCPcopy
hub / github.com/docker/compose / replace

Function replace

pkg/compose/transform/replace.go:126–149  ·  view source on GitHub ↗

replace changes yaml node value in stream at position, preserving content

(in []byte, line int, column int, value string)

Source from the content-addressed store, hash-verified

124
125// replace changes yaml node value in stream at position, preserving content
126func replace(in []byte, line int, column int, value string) []byte {
127 var out []byte
128 l := 1
129 pos := 0
130 for _, b := range in {
131 if b == '\n' {
132 l++
133 if l == line {
134 break
135 }
136 }
137 pos++
138 }
139 pos += column
140 out = append(out, in[0:pos]...)
141 out = append(out, []byte(value)...)
142 for ; pos < len(in); pos++ {
143 if in[pos] == '\n' {
144 break
145 }
146 }
147 out = append(out, in[pos:]...)
148 return out
149}

Callers 2

ReplaceExtendsFileFunction · 0.85
ReplaceEnvFileFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected