Truncate a file: Difference between revisions

Go solution
(Added C# solution.)
(Go solution)
Line 141:
}
}</lang>
=={{header|Go}}==
Go has the required function in the standard library. The implementation calls operating system specific functions and returns whatever errors the operating system reports.
<lang go>import (
"fmt"
"os"
)
 
if err := os.Truncate("filename", newSize); err != nil {
fmt.Println(err)
}</lang>
Package os also has a separate function that operates on an open file.
 
=={{header|Haskell}}==
1,707

edits