From 0ea59dbd2e63ba059ac9fd52c2f1e24658e672d0 Mon Sep 17 00:00:00 2001 From: Chris Novakovic Date: Wed, 8 Oct 2025 20:23:08 +0100 Subject: [PATCH] Writer: don't prepend file mode bits to file mode field ar archives are only capable of storing regular files, so the file mode bits that `Reader` prepends to every file mode header field are redundant (and it forces users to strip them off manually whenever a file header passes through a `Writer` multiple times, otherwise they accumulate and overflow the header field). Just encode the mode we were given - which may or may not contain file mode bits of its own, at the caller's discretion - in octal and insert it into the header field. --- writer.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/writer.go b/writer.go index a7b1d5d..4981d28 100644 --- a/writer.go +++ b/writer.go @@ -81,7 +81,7 @@ func (aw *Writer) numeric(b []byte, x int64) { } func (aw *Writer) octal(b []byte, x int64) { - s := "100" + strconv.FormatInt(x, 8) + s := strconv.FormatInt(x, 8) for len(s) < len(b) { s = s + " " }