Skip to content

Commit 9a2b05b

Browse files
committed
tarheader: remove init func
Signed-off-by: Sebastiaan van Stijn <[email protected]>
1 parent 436bd25 commit 9a2b05b

File tree

3 files changed

+10
-13
lines changed

3 files changed

+10
-13
lines changed

Diff for: tarheader/tarheader.go

+1-7
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,6 @@ func (fi nosysFileInfo) Sys() interface{} {
4242
return nil
4343
}
4444

45-
// sysStat, if non-nil, populates hdr from system-dependent fields of fi.
46-
var sysStat func(fi os.FileInfo, hdr *tar.Header) error
47-
4845
// FileInfoHeaderNoLookups creates a partially-populated tar.Header from fi.
4946
//
5047
// Compared to the archive/tar.FileInfoHeader function, this function is safe to
@@ -66,8 +63,5 @@ func FileInfoHeaderNoLookups(fi os.FileInfo, link string) (*tar.Header, error) {
6663
if err != nil {
6764
return nil, err
6865
}
69-
if sysStat != nil {
70-
return hdr, sysStat(fi, hdr)
71-
}
72-
return hdr, nil
66+
return hdr, sysStat(fi, hdr)
7367
}

Diff for: tarheader/tarheader_unix.go

+2-6
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,9 @@ import (
1111
"golang.org/x/sys/unix"
1212
)
1313

14-
func init() {
15-
sysStat = statUnix
16-
}
17-
18-
// statUnix populates hdr from system-dependent fields of fi without performing
14+
// sysStat populates hdr from system-dependent fields of fi without performing
1915
// any OS lookups.
20-
func statUnix(fi os.FileInfo, hdr *tar.Header) error {
16+
func sysStat(fi os.FileInfo, hdr *tar.Header) error {
2117
// Devmajor and Devminor are only needed for special devices.
2218

2319
// In FreeBSD, RDev for regular files is -1 (unless overridden by FS):

Diff for: tarheader/tarheader_windows.go

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package tarheader
2+
3+
// sysStat populates hdr from system-dependent fields of fi without performing
4+
// any OS lookups. It is a no-op on Windows.
5+
func sysStat(fi os.FileInfo, hdr *tar.Header) error {
6+
return nil
7+
}

0 commit comments

Comments
 (0)