Skip to content

proposal: archive/zip: *File should implement fmt.Stringer #23260

Description

@alandonovan

I recently made the mistake of printing a *zip.File while debugging some zip reader code, expecting it to show me the name and perhaps the mode of the zip entry in some helpful form. It did show me these things, because fmt printed the raw struct, they were followed by masses of decimal numbers---the value of every byte in the file.

	rd, err := zip.NewReader(...)
	if err != nil { ... }
	for _, fh := range rd.File {
		fmt.Println(fh)
		...
	}

Here's one of the smaller lines of output:

&{{tools-3d92dd60033c312e3ae7cac319c792271cf67e37/cmd/goyacc/yacc.go 0 10 0 8 24966 18823 2447150300 21770 71391 21770 71391 [85 84 5 0 1 29 109 72 88] 0 } 0xc42025ca80 0xc420aa80c0 2525793 115491}

Ideally *File would have a friendly String method.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions