MCPcopy
hub / github.com/uber-go/zap / open

Function open

writer.go:60–85  ·  view source on GitHub ↗
(paths []string)

Source from the content-addressed store, hash-verified

58}
59
60func open(paths []string) ([]zapcore.WriteSyncer, func(), error) {
61 writers := make([]zapcore.WriteSyncer, 0, len(paths))
62 closers := make([]io.Closer, 0, len(paths))
63 closeAll := func() {
64 for _, c := range closers {
65 _ = c.Close()
66 }
67 }
68
69 var openErr error
70 for _, path := range paths {
71 sink, err := _sinkRegistry.newSink(path)
72 if err != nil {
73 openErr = multierr.Append(openErr, fmt.Errorf("open sink %q: %w", path, err))
74 continue
75 }
76 writers = append(writers, sink)
77 closers = append(closers, sink)
78 }
79 if openErr != nil {
80 closeAll()
81 return nil, nil, openErr
82 }
83
84 return writers, closeAll, nil
85}
86
87// CombineWriteSyncers is a utility that combines multiple WriteSyncers into a
88// single, locked WriteSyncer. If no inputs are supplied, it returns a no-op

Callers 1

OpenFunction · 0.85

Calls 3

newSinkMethod · 0.80
ErrorfMethod · 0.65
CloseMethod · 0.45

Tested by

no test coverage detected