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

Function writeWithCarriageReturn

agent/agentssh/agentssh.go:1337–1349  ·  view source on GitHub ↗

writeWithCarriageReturn writes each line with a carriage return to ensure that each line starts at the beginning of the terminal.

(src io.Reader, dest io.Writer)

Source from the content-addressed store, hash-verified

1335// writeWithCarriageReturn writes each line with a carriage return to ensure
1336// that each line starts at the beginning of the terminal.
1337func writeWithCarriageReturn(src io.Reader, dest io.Writer) error {
1338 s := bufio.NewScanner(src)
1339 for s.Scan() {
1340 _, err := fmt.Fprint(dest, s.Text()+"\r\n")
1341 if err != nil {
1342 return xerrors.Errorf("write line: %w", err)
1343 }
1344 }
1345 if err := s.Err(); err != nil {
1346 return xerrors.Errorf("read line: %w", err)
1347 }
1348 return nil
1349}
1350
1351// userHomeDir returns the home directory of the current user, giving
1352// priority to the $HOME environment variable.

Callers 2

showAnnouncementBannerFunction · 0.85
showMOTDFunction · 0.85

Calls 4

ErrMethod · 0.80
ScanMethod · 0.45
TextMethod · 0.45
ErrorfMethod · 0.45

Tested by

no test coverage detected