Truncate a file: Difference between revisions
Content added Content deleted
(Added C# solution.) |
(Go solution) |
||
Line 141: | Line 141: | ||
} |
} |
||
}</lang> |
}</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}}== |
=={{header|Haskell}}== |