Olá pessoal tudo bem, preciso migrar um script em Python para Golang
Tenho uma função que apaga os arquivos e pastas depois X dias
Essa é a função em Python, alguem tem alguma dica para ajudar.
Grato.
def clean_files(BackupDir, DaysToKeep):
now = time.time()
filelist = [ f for f in os.listdir(BackupDir) if f.endswith(".gz") ]
for f in filelist:
f = os.path.join(BackupDir, f)
if os.stat(f).st_mtime < now - (DaysToKeep * 86400):
if os.path.isfile(f):
os.remove(f)
log('APAGANDO O ARQUIVO: %s COM MAIS DE %s DIAS ...' %(f, DaysToKeep))