Keval Bhogayata
Keval Bhogayata

Reputation: 6686

Avoid parent folder structure when creating tar

https://github.com/mimoo/eureka/blob/master/folders.go

I am using the compress method given in the above link for creating Tar with recursive folder structure in Golang.

Now, say if I give /home/Documents/project as src

Then, the created tar also contains /home/Documents/project/files I want to avoid the parent folder structure here.

Ex. tar should directly contain : files

How can I modify this method to achieve this ?

Thanks in advance.

Upvotes: 1

Views: 261

Answers (1)

emptyhua
emptyhua

Reputation: 6692

A tricky method without modifying the code, If your program does not have concurrent logic, you can do this:

os.Chdir("/home/Documents/project")
compress("./", output)

Upvotes: 2

Related Questions