Standard library / archive/tar

archive/tar.Header.FileInfo()

Expose header metadata through fs.FileInfo; this is archive metadata, not a filesystem stat. Expected stdout: 'a.txt 2\n'.

Formal Syntax & Structure

go syntaxgo
func (h *Header) FileInfo() fs.FileInfo

Return Value

fs.FileInfo

Metadata as a filesystem interface.

Working Example

Example Snippetgo
package main
import (  "archive/tar"  "fmt")
func must(e error) {  if e != nil {    panic(e)  }}
func main() {  h := tar.Header{Name: "sub/a.txt", Size: 2, Mode: 0600}  fmt.Println(h.FileInfo().Name(), h.FileInfo().Size())}
Go Reference