上QQ阅读APP看书,第一时间看更新
Create
In order to create an empty file, we can call a helper function called Create, which opens a new file with a 0666 permission and truncates it if it doesn't exist. Alternatively, we can use OpenFile with the O_CREATE|O_TRUNCATE mode to specify custom permissions, as shown in the following code:
package main
import "os"
func main() {
f, err := os.Create("file.txt")
if err != nil {
fmt.Println("Error:", err)
return
}
f.Close()
}
本周热推: