main.go 676 B

12345678910111213141516171819202122232425262728293031323334353637
  1. // Copyright (C) 2014 Jakob Borg and Contributors (see the CONTRIBUTORS file).
  2. // All rights reserved. Use of this source code is governed by an MIT-style
  3. // license that can be found in the LICENSE file.
  4. // +build ignore
  5. package main
  6. import (
  7. "bytes"
  8. "fmt"
  9. "io"
  10. "os"
  11. )
  12. func main() {
  13. buf := make([]byte, 4096)
  14. var err error
  15. for err == nil {
  16. n, err := io.ReadFull(os.Stdin, buf)
  17. if n > 0 {
  18. buf = buf[:n]
  19. repl := bytes.Replace(buf, []byte("\n"), []byte("\r\n"), -1)
  20. _, err = os.Stdout.Write(repl)
  21. if err != nil {
  22. fmt.Println(err)
  23. os.Exit(1)
  24. }
  25. }
  26. if err == io.EOF {
  27. return
  28. }
  29. buf = buf[:cap(buf)]
  30. }
  31. fmt.Println(err)
  32. os.Exit(1)
  33. }