Logo

Programming-Idioms

History of Idiom 199 > diff from v6 to v7

Edit summary for version 7 by programming-idioms.org:
[Go] Same code without wrapping. +DocURL. +DemoURL.

Version 6

2020-12-08, 09:59:49

Version 7

2020-12-14, 08:13:47

Idiom #199 Truncate a file at the current file position

Truncate a file F at the give file position.

Idiom #199 Truncate a file at the current file position

Truncate a file F at the give file position.

Variables
F
Variables
F
Imports
os
Imports
import "os"
Code
func truncateFile(filePath string, position int64) {
	
	err := os.Truncate(filePath, position)
	if err != nil {
		fmt.Println(err)
		return
	}

	fmt.Println("succeed to truncate...")

}
Code
err := os.Truncate(F, position)
Doc URL
https://golang.org/pkg/os/#Truncate
Demo URL
https://play.golang.org/p/-y3wD6Tqkr1