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 Rename and Move a File in Golang?
- How to Delete or Remove a File in Golang?
- How to Truncate a File in Golang?
- Checking the Given File Exists or Not in Golang
- How to Read a File Line by Line to String in Golang?
- How to Uncompress a File in Golang?
- How to Create Custom Errors using New Function in Golang?
- How to create a Struct Instance Using a Struct Literal in Golang?
- How to Create and Print Multi Dimensional Slice in Golang?
- How to Create Modules in Golang?
- How to Create Your Own Package in Golang?
- How to convert a slice of bytes in uppercase in Golang?
- Golang program that uses fallthrough keyword
- math.Lgamma() Function in Golang with Examples
- math.Float64bits() Function in Golang With Examples
- How to check equality of slices of bytes in Golang?
- atomic.AddInt64() Function in Golang With Examples
- atomic.StoreInt64() Function in Golang With Examples
- reflect.FieldByIndex() Function in Golang with Examples
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. 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.