File input/output: Difference between revisions

→‎{{header|Go}}: added solution that satisfies the task better.
m (→‎{{header|Tcl}}: more polish)
(→‎{{header|Go}}: added solution that satisfies the task better.)
Line 759:
 
=={{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
 
1,707

edits