File input/output: Difference between revisions

Content added Content deleted
m (→‎{{header|Tcl}}: more polish)
(→‎{{header|Go}}: added solution that satisfies the task better.)
Line 759: Line 759:


=={{header|Go}}==
=={{header|Go}}==
<lang go>package main

import (
"fmt"
"io/ioutil"
)

func main() {
b, err := ioutil.ReadFile("input.txt")
if err != nil {
fmt.Println(err)
return
}
if err = ioutil.WriteFile("output.txt", b, 0666); err != nil {
fmt.Println(err)
}
}</lang>
Alternative solution is not a one-liner, but is one of "secondary interest" that copies data from one file to another without an intermediate variable.
<lang go>package main
<lang go>package main