How to create a directory in golang
The operations on directories and file names in golang are all in the os package. The specific directory creation is It is implemented through the two functions Mkdir and MkdirAll. The usage of these two functions is the same.
1 |
|
1. dirName is the directory (folder path) to be created. , can be an absolute path or a relative path (relative to GOPATH)
2. perm represents the permissions of the created directory, such as 0777 (the read r permission value is 4, the write permission w value is 2, execute The authority Examples are as follows:
1 2 3 4 5 6 7 8 9 10 11 12 13 |
|
The difference between Mkdir and MkdirAll
1. When Mkdir creates a directory, its parent directory must exist, otherwise the creation will fail
2. MkdirAll can create directories recursively, that is, as long as the root directory exists, as follows:
1 2 3 4 |
|
PHP Chinese website, a large number of programming tutorials and
website construction tutorials, welcome to learn!
The above is the detailed content of How to create a directory in golang. For more information, please follow other related articles on the PHP Chinese website!