nlepage/go-tarfs

Read a tar file contents using go1.16 io/fs abstraction

Go

49

79 commits

updated Aug 24, 2026

See the code

README

go-tarfs

Go Reference GitHub release (latest SemVer) GitHub Workflow Status License Unlicense

Read a tar file contents using go1.16 io/fs abstraction

Usage

⚠️ go-tarfs needs go>=1.21

Install:

go get github.com/nlepage/go-tarfs

Use:

package main

import (
    "os"

    tarfs "github.com/nlepage/go-tarfs"
)

func main() {
    tf, err := os.Open("path/to/archive.tar")
    if err != nil {
        panic(err)
    }
    defer tf.Close()

    tfs, err := tarfs.New(tf)
    if err != nil {
        panic(err)
    }

    f, err := tfs.Open("path/to/some/file")
    if err != nil {
        panic(err)
    }
    defer f.Close() // frees the associated reader

    // use f...
}

More information at pkg.go.dev/github.com/nlepage/go-tarfs

Long living fs.FS

The io.Reader given to tarfs.New must stay opened while using the returned fs.FS (this is true only if the io.Reader implements io.ReaderAt).

Memory usage

Since v1.2.0 files content are not stored in memory anymore if the io.Reader given to tarfs.New implements io.ReaderAt.

For now, no effort is done to support symbolic links.

Show your support

Give a ⭐️ if this project helped you!

Contributors ✨

All Contributors

Thanks goes to these wonderful people (emoji key):

This project follows the all-contributors specification. Contributions of any kind welcome!

📝 License

This project is unlicensed, it is free and unencumbered software released into the public domain.

golang
tar
tarball

nlepage/go-tarfs

Read a tar file contents using go1.16 io/fs abstraction

Go

49

79 commits

updated Aug 24, 2026

See the code

README

go-tarfs

Go Reference GitHub release (latest SemVer) GitHub Workflow Status License Unlicense

Read a tar file contents using go1.16 io/fs abstraction

Usage

⚠️ go-tarfs needs go>=1.21

Install:

go get github.com/nlepage/go-tarfs

Use:

package main

import (
    "os"

    tarfs "github.com/nlepage/go-tarfs"
)

func main() {
    tf, err := os.Open("path/to/archive.tar")
    if err != nil {
        panic(err)
    }
    defer tf.Close()

    tfs, err := tarfs.New(tf)
    if err != nil {
        panic(err)
    }

    f, err := tfs.Open("path/to/some/file")
    if err != nil {
        panic(err)
    }
    defer f.Close() // frees the associated reader

    // use f...
}

More information at pkg.go.dev/github.com/nlepage/go-tarfs

Long living fs.FS

The io.Reader given to tarfs.New must stay opened while using the returned fs.FS (this is true only if the io.Reader implements io.ReaderAt).

Memory usage

Since v1.2.0 files content are not stored in memory anymore if the io.Reader given to tarfs.New implements io.ReaderAt.

For now, no effort is done to support symbolic links.

Show your support

Give a ⭐️ if this project helped you!

Contributors ✨

All Contributors

Thanks goes to these wonderful people (emoji key):

This project follows the all-contributors specification. Contributions of any kind welcome!

📝 License

This project is unlicensed, it is free and unencumbered software released into the public domain.

golang
tar
tarball

Project health

Overall

3.4/10

Maintained

3/10

Code review

0/10
OpenSSF Scorecard

Latest release

v1.2.1 · Aug 15, 2023

Releases this year

0

Significant stargazers

Jimmi Dyson

345 followers · starred Feb 2022

Cezar Craciunoiu

94 followers · starred Jun 2025

Johnny Steenbergen

46 followers · starred Dec 2024