main.go 722 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. // Copyright (C) 2014 The Syncthing Authors.
  2. //
  3. // This Source Code Form is subject to the terms of the Mozilla Public
  4. // License, v. 2.0. If a copy of the MPL was not distributed with this file,
  5. // You can obtain one at https://mozilla.org/MPL/2.0/.
  6. // +build ignore
  7. package main
  8. import (
  9. "bytes"
  10. "fmt"
  11. "io"
  12. "os"
  13. )
  14. func main() {
  15. buf := make([]byte, 4096)
  16. var err error
  17. for err == nil {
  18. n, err := io.ReadFull(os.Stdin, buf)
  19. if n > 0 {
  20. buf = buf[:n]
  21. repl := bytes.Replace(buf, []byte("\n"), []byte("\r\n"), -1)
  22. _, err = os.Stdout.Write(repl)
  23. if err != nil {
  24. fmt.Println(err)
  25. os.Exit(1)
  26. }
  27. }
  28. if err == io.EOF {
  29. return
  30. }
  31. buf = buf[:cap(buf)]
  32. }
  33. fmt.Println(err)
  34. os.Exit(1)
  35. }