Skip to content

wangkuiyi/tar

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

tar

To create a gziped tarball, simply call

tarfile, _ := os.Create("/tmp/my.tar.gz")
Tar(tarfile, dir, nil, true)

To create a tarball in a SQL table by taking the table as a filesystem, we can use the sqlfs package:

func Tar(db *sql.DB, dir string, inc include, compress bool) (e error) {
	// Create a file in the SQLFS.
	fn := strings.Replace(strings.Replace(dir, ".", "_"), "-", "_")
	sqlfn := fmt.Sprintf("sqlflow_models.%s", fn)
	sqlf, e := sqlfs.Create(db, sqlfn)
	if e != nil {
		return fmt.Errorf("Cannot create sqlfs file %s: %v", sqlfn, e)
	}
	defer func() { e = sqlf.Close() }()

	return tar.Tar(sqlf, dir, inc, compress)
}

About

A Go implementation of tar and untar

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages