https://github.com/nlepage/go-tarfs
Read a tar file contents using go1.16 io/fs abstraction
https://github.com/nlepage/go-tarfs
golang tar tarball
Last synced: 8 months ago
JSON representation
Read a tar file contents using go1.16 io/fs abstraction
- Host: GitHub
- URL: https://github.com/nlepage/go-tarfs
- Owner: nlepage
- License: unlicense
- Created: 2021-02-03T23:30:41.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2023-11-20T10:31:58.000Z (over 2 years ago)
- Last Synced: 2024-10-11T22:52:09.527Z (over 1 year ago)
- Topics: golang, tar, tarball
- Language: Go
- Homepage: https://pkg.go.dev/github.com/nlepage/go-tarfs
- Size: 92.8 KB
- Stars: 36
- Watchers: 2
- Forks: 8
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# go-tarfs
[](https://pkg.go.dev/github.com/nlepage/go-tarfs)


[](https://github.com/nlepage/go-tarfs/blob/master/LICENSE)
> Read a tar file contents using go1.16 io/fs abstraction
## Usage
⚠️ go-tarfs needs go>=1.17
Install:
```sh
go get github.com/nlepage/go-tarfs
```
Use:
```go
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](https://pkg.go.dev/github.com/nlepage/go-tarfs#section-documentation)
### 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](https://github.com/nlepage/go-tarfs/releases/tag/v1.2.0) files content are not stored in memory anymore if the `io.Reader` given to `tarfs.New` implements `io.ReaderAt`.
### Symbolic links
For now, no effort is done to support symbolic links.
## Show your support
Give a ⭐️ if this project helped you!
## Contributors ✨
[](#contributors-)
Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):

Nicolas Lepage
💻 ⚠️ 💡 🚧 👀

Jonas Plum
⚠️ 💻

MengYX
🐛 💻

Andrey Dyatlov
🐛 💻 ⚠️

Joe Lanford
💻 👀 🐛
This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!
## 📝 License
This project is [unlicensed](https://github.com/nlepage/go-tarfs/blob/master/LICENSE), it is free and unencumbered software released into the public domain.