如何使用golang在localhost系统中创建临时目录

Here I'm trying to create a temporary directory in my local system using the below mentioned code

Code

path := "/home/iron/go/"
fmt.Println(os.Stat(path))
// this statement prints the data showing numbers
if _, err := os.Stat(path); os.IsNotExist(err) {
    os.MkdirAll(path, 0755)
}

I also searched for it but I want to do this from above code or add some lines to code.

Links for making temporary directory:- link 1, link 2

You can just get the os temp directory and manually create a folder under this directory without random suffix(random is for solving conflict):

goPath := filepath.Join(os.TempDir(), "/home/iron/go/")
> /var/folders/m2/4clpt6wj62j6dt9kwpr4b5fh0000gn/T/home/iron/go