MCPcopy Index your code
hub / github.com/coder/coder / write

Method write

cli/exp_scaletest.go:269–306  ·  view source on GitHub ↗
(res harness.Results, stdout io.Writer)

Source from the content-addressed store, hash-verified

267}
268
269func (o *scaleTestOutput) write(res harness.Results, stdout io.Writer) error {
270 var (
271 w = stdout
272 c io.Closer
273 )
274 if o.path != "-" {
275 f, err := os.Create(o.path)
276 if err != nil {
277 return xerrors.Errorf("create output file: %w", err)
278 }
279 w, c = f, f
280 }
281
282 switch o.format {
283 case scaleTestOutputFormatText:
284 res.PrintText(w)
285 case scaleTestOutputFormatJSON:
286 err := json.NewEncoder(w).Encode(res)
287 if err != nil {
288 return xerrors.Errorf("encode JSON: %w", err)
289 }
290 }
291
292 // Sync the file to disk if it's a file.
293 if s, ok := w.(interface{ Sync() error }); ok {
294 // Best effort. If we get an error from syncing, just ignore it.
295 _ = s.Sync()
296 }
297
298 if c != nil {
299 err := c.Close()
300 if err != nil {
301 return xerrors.Errorf("close output file: %w", err)
302 }
303 }
304
305 return nil
306}
307
308type scaletestOutputFlags struct {
309 outputSpecs []string

Callers 11

scaletestChatMethod · 0.45
scaletestTaskStatusMethod · 0.45
scaletestBridgeMethod · 0.45
scaletestPrebuildsMethod · 0.45
scaletestDashboardMethod · 0.45
scaletestAutostartMethod · 0.45

Calls 6

EncodeMethod · 0.80
CreateMethod · 0.65
CloseMethod · 0.65
ErrorfMethod · 0.45
PrintTextMethod · 0.45
SyncMethod · 0.45

Tested by

no test coverage detected