main.go 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. // Copyright (C) 2014 Jakob Borg and Contributors (see the CONTRIBUTORS file).
  2. //
  3. // This program is free software: you can redistribute it and/or modify it
  4. // under the terms of the GNU General Public License as published by the Free
  5. // Software Foundation, either version 3 of the License, or (at your option)
  6. // any later version.
  7. //
  8. // This program is distributed in the hope that it will be useful, but WITHOUT
  9. // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  10. // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  11. // more details.
  12. //
  13. // You should have received a copy of the GNU General Public License along
  14. // with this program. If not, see <http://www.gnu.org/licenses/>.
  15. // +build ignore
  16. package main
  17. import (
  18. "bytes"
  19. "fmt"
  20. "io"
  21. "os"
  22. )
  23. func main() {
  24. buf := make([]byte, 4096)
  25. var err error
  26. for err == nil {
  27. n, err := io.ReadFull(os.Stdin, buf)
  28. if n > 0 {
  29. buf = buf[:n]
  30. repl := bytes.Replace(buf, []byte("\n"), []byte("\r\n"), -1)
  31. _, err = os.Stdout.Write(repl)
  32. if err != nil {
  33. fmt.Println(err)
  34. os.Exit(1)
  35. }
  36. }
  37. if err == io.EOF {
  38. return
  39. }
  40. buf = buf[:cap(buf)]
  41. }
  42. fmt.Println(err)
  43. os.Exit(1)
  44. }