tar

package module
v0.0.0-...-c5f2ec4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 6, 2025 License: BSD-3-Clause Imports: 14 Imported by: 0

README

github.com/tetsuo/tar

tar/untar extracted from golang/build's internals.

Usage

package main

import (
	"context"
	"log"

	"cloud.google.com/go/storage"
	"github.com/tetsuo/tar/gcs"
)

func main() {
	ctx := context.Background()

	// Initialize GCS client
	client, err := storage.NewClient(ctx)
	if err != nil {
		log.Fatalf("failed to create GCS client: %v", err)
	}
	defer client.Close()

	// Inputs
	workDir := "/tmp/my-app"           // full working directory path
	relDir := "data"                   // subdir inside workDir to pack/unpack
	bucketName := "my-bucket"          // replace with your GCS bucket name
	objectName := "archives/data.tar"  // target object path in GCS

	// Pack directory into GCS object
	if err := gcs.Pack(ctx, client, workDir, relDir, bucketName, objectName); err != nil {
		log.Fatalf("failed to pack: %v", err)
	}
	log.Println("Pack successful.")

	// Unpack the GCS object back into directory
	if err := gcs.Unpack(ctx, client, workDir, relDir, bucketName, objectName); err != nil {
		log.Fatalf("failed to unpack: %v", err)
	}
	log.Println("Unpack successful.")
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Pack

func Pack(w io.Writer, workDir, dir string) error

func Unpack

func Unpack(r io.Reader, workDir, dir string) error

Unpack reads the gzip-compressed tar file from r and writes it into dir.

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL