Skip to content

Instantly share code, notes, and snippets.

@Ramko9999
Created April 25, 2021 19:48
Show Gist options
  • Save Ramko9999/7f26a6ecc8ebcec61cd5ee1c4efd52ec to your computer and use it in GitHub Desktop.
Save Ramko9999/7f26a6ecc8ebcec61cd5ee1c4efd52ec to your computer and use it in GitHub Desktop.
import (
"log"
"os"
)
/*
os.MkdirTemp takes in the path to make the temporary dir and a pattern.
os.MkdirTemp will make a new directory with a name which is the pattern + a random string.
Ex: if "transform" was my pattern, a potential temp directory can be:
./temporary/transform952209073
*/
func makeTempDir(){
dirName, err := os.MkdirTemp("./temporary", "transform");
defer os.RemoveAll(dirName); // remove all contents in a directory
if err != nil {
log.Fatal(err);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment