Golang archive/tar.Read() function example

package archive/tar

Read reads from the current entry in the tar archive. It returns 0, io.EOF when it reaches the end of that entry, until Next is called to advance to the next entry.

tar.Read() usage example

 tarreader := tar.NewReader(read)

 tar_read,err  := tarreader.Read() // read current file in archive
 if err == io.EOF {
 // end of tar archive
 fmt.Println('No more files to read in tar archive!')
 }

Reference :

http://golang.org/pkg/archive/tar/#Reader.Read

Advertisement