Like other programming languages, Go language also allows you to create files. For creating a file it provides Create() function, this function is used to create or truncates the given named file.
- This method will truncate the file, if the given file is already exists.
- This method will create a file with mode 0666, if the given file doesn’t exist.
- If the given path is not correct, then this method will throw an error of type *PathError.
- This method return a file descriptor which can be used for both reading and write.
- It is defined under the os package so, you have to import os package in your program for accessing Create() function.
func Create(file_name string) (*File, error)
- Checking if structure is empty or not in Golang
- How to Truncate a File in Golang?
- How to Uncompress a File in Golang?
- Checking the Given File Exists or Not in Golang
- How to Rename and Move a File in Golang?
- How to Delete or Remove a File in Golang?
- How to Create Modules in Golang?
- How to Create Your Own Package in Golang?
- How to Create Custom Errors using New Function in Golang?
- How to Create and Print Multi Dimensional Slice in Golang?
- How to Read a File Line by Line to String in Golang?
- How to create a Struct Instance Using a Struct Literal in Golang?
- Zero value in Golang
- Templates in GoLang
- Hello World in Golang
- Interfaces in Golang
- Methods With Same Name in Golang
- Methods in Golang
- Reflection in Golang
- Import in GoLang
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.