MCPcopy
hub / github.com/danielmiessler/Fabric / captureOutput

Function captureOutput

internal/plugins/plugin_test.go:276–286  ·  view source on GitHub ↗

captureOutput captures the output of a function call

(f func())

Source from the content-addressed store, hash-verified

274
275// captureOutput captures the output of a function call
276func captureOutput(f func()) string {
277 var buf bytes.Buffer
278 stdout := os.Stdout
279 r, w, _ := os.Pipe()
280 os.Stdout = w
281 f()
282 _ = w.Close()
283 os.Stdout = stdout
284 _, _ = buf.ReadFrom(r)
285 return buf.String()
286}
287
288// captureInput captures the input for a function call
289func captureInput(input string) func() {

Callers 1

TestSetting_PrintFunction · 0.85

Calls 2

CloseMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected