MCPcopy
hub / github.com/bitfield/script / Stdout

Method Stdout

script.go:920–933  ·  view source on GitHub ↗

Stdout copies the pipe's contents to its configured standard output (using [Pipe.WithStdout]), or to [os.Stdout] otherwise, and returns the number of bytes successfully written, together with any error.

()

Source from the content-addressed store, hash-verified

918// [Pipe.WithStdout]), or to [os.Stdout] otherwise, and returns the number of
919// bytes successfully written, together with any error.
920func (p *Pipe) Stdout() (int, error) {
921 if p.Error() != nil {
922 return 0, p.Error()
923 }
924 n64, err := io.Copy(p.stdout, p)
925 if err != nil {
926 return 0, err
927 }
928 n := int(n64)
929 if int64(n) != n64 {
930 return 0, fmt.Errorf("length %d overflows int", n64)
931 }
932 return n, p.Error()
933}
934
935// String returns the pipe's contents as a string, together with any error.
936func (p *Pipe) String() (string, error) {

Callers 15

ExampleExec_okFunction · 0.80
ExampleFindFilesFunction · 0.80
ExampleIfExists_execFunction · 0.80
ExampleIfExists_noExecFunction · 0.80
ExampleListFilesFunction · 0.80
ExamplePipe_BasenameFunction · 0.80
ExamplePipe_DirnameFunction · 0.80
ExamplePipe_ExecFunction · 0.80
ExamplePipe_ExecForEachFunction · 0.80
TestMainFunction · 0.80

Calls 1

ErrorMethod · 0.95

Tested by 15

ExampleExec_okFunction · 0.64
ExampleFindFilesFunction · 0.64
ExampleIfExists_execFunction · 0.64
ExampleIfExists_noExecFunction · 0.64
ExampleListFilesFunction · 0.64
ExamplePipe_BasenameFunction · 0.64
ExamplePipe_DirnameFunction · 0.64
ExamplePipe_ExecFunction · 0.64
ExamplePipe_ExecForEachFunction · 0.64
TestMainFunction · 0.64