MCPcopy Create free account
hub / github.com/linuxkit/linuxkit / getWriter

Function getWriter

pkg/init/cmd/service/system_init.go:189–205  ·  view source on GitHub ↗
(line string)

Source from the content-addressed store, hash-verified

187}
188
189func getWriter(line string) (io.Writer, error) {
190 switch {
191 case line == "stderr":
192 return os.Stderr, nil
193 case line == "stdout":
194 return os.Stdout, nil
195 case strings.HasPrefix(line, "/"):
196 // does the file exist?
197 f, err := os.OpenFile(line,
198 os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)
199 if err != nil {
200 return nil, fmt.Errorf("unable to open file %s for creation or appending: %v", line, err)
201 }
202 return f, nil
203 }
204 return nil, fmt.Errorf("invalid option for writer: %s", line)
205}

Callers 1

systemInitCmdFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected