After the call to ioutil.TempDir, the directory has already been created, and MkdirAll therefore can't do anything. The mode argument in particular is misleading.