O'Reilly logo

Go Standard Library Cookbook by Radomir Sohlich

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

How it works...

The previous example represents four ways you can create a file or directory. The os.Create function is the simplest way to create the file. By using this function, you will create the file with permissions such as 0666.

If you need to create the file with any other configuration of permissions, then the OpenFile function of the os package is the one to be used.

The directories can be created by using the Mkdir function of the os package. This way, a directory with given permissions is created. The second option is to use the MkdirAll function. This function also creates the directory, but if the given path contains non-exiting directories, then all directories in the path are created (it works the same as the -p option of ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required