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 os package offers a simple way of opening the file. The function Open opens the file by the path, just in read-only mode. Another function, OpenFile, is the more powerful one and consumes the path to the file, flags, and permissions. 

The flag constants are defined in the os package and you can combine them with use of the binary OR operator |.  The permissions are set by the os package constants (for example, os.ModePerm ) or by the number notation such as 0777 (permissions: -rwxrwxrwx).

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