These steps cover writing and running your application:
- From your terminal/console application, create a new directory called chapter1/filedirs.
- Navigate to this directory.
- Copy tests from https://github.com/agtorre/go-cookbook/tree/master/chapter1/filedirs, or use this as an exercise to write some of your own code!
- Create a file called dirs.go with the following contents:
package filedirs import ( "errors" "io" "os" ) // Operate manipulates files and directories func Operate() error { // this 0777 is similar to what you'd see with chown // on a command line this will create a director // /tmp/example, you may also use an absolute path // instead of a relative one if err := os.Mkdir("example_dir", os.FileMode(0755)); ...