How to remove all contents of a directory using Golang?

前端 未结 4 442
灰色年华
灰色年华 2021-01-31 06:58

I\'m new to Go and can\'t seem to find a way to delete all the contents of a directory when I don\'t know the contents.

I\'ve tried:

os.RemoveAll(\"/tmp/         


        
4条回答
  •  独厮守ぢ
    2021-01-31 07:48

    It might be a stupid answer, but why not simply do?

    os.RemoveAll("/tmp/")
    os.MkdirAll("/tmp/",FileMode)
    

提交回复
热议问题