方法
package zdpgo_fileimport ("os"
)// AddDir 创建文件夹
func AddDir(dir string) error {if !IsExist(dir) {return os.MkdirAll(dir, os.ModePerm)}return nil
}
测试
package zdpgo_fileimport "testing"func TestAddDir(t *testing.T) {data := []string{"test","test/a1","test/a2/a3",}for _, tt := range data {v := AddDir(tt)if v != nil {t.Error(v)}}
}