{"record":{"id":"6fcde76b9eeee631","repo":"golang/go","slug":"zip-writer-closed-twice","errorCode":null,"errorMessage":"zip: writer closed twice","messagePattern":"zip: writer closed twice","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/archive/zip/writer.go","lineNumber":90,"sourceCode":"func (w *Writer) SetComment(comment string) error {\n\tif len(comment) > uint16max {\n\t\treturn errors.New(\"zip: Writer.Comment too long\")\n\t}\n\tw.comment = comment\n\treturn nil\n}\n\n// Close finishes writing the zip file by writing the central directory.\n// It does not close the underlying writer.\nfunc (w *Writer) Close() error {\n\tif w.last != nil && !w.last.closed {\n\t\tif err := w.last.close(); err != nil {\n\t\t\treturn err\n\t\t}\n\t\tw.last = nil\n\t}\n\tif w.closed {\n\t\treturn errors.New(\"zip: writer closed twice\")\n\t}\n\tw.closed = true\n\n\t// write central directory\n\tstart := w.cw.count\n\tusedZip64 := false\n\tfor _, h := range w.dir {\n\t\t// For the Central Directory, we always have the correct sizes.\n\t\t//\n\t\t// Implementations disagree on what triggers the inclusion of a Zip64\n\t\t// extra field: Info-ZIP only writes it if any size or offset EXCEEDS\n\t\t// 4GiB - 1, while libarchive writes it if any size REACHES OR EXCEEDS\n\t\t// 4GiB - 1, or if the offset EXCEEDS 4GiB - 1. The spec is ambiguous.\n\t\t//\n\t\t// We conservatively write Zip64 extra fields if any size or offset\n\t\t// REACHES OR EXCEEDS 4GiB - 1, to maximize compatibility with readers.\n\t\t// There is no ambiguity in parsing, so there is no downside to it.\n\t\t//","sourceCodeStart":72,"sourceCodeEnd":108,"githubUrl":"https://github.com/golang/go/blob/b6b368adc57c96c3151d224d172029f233ead2c3/src/archive/zip/writer.go#L72-L108","documentation":"Error \"zip: writer closed twice\" thrown in golang/go.","triggerScenarios":"Thrown at src/archive/zip/writer.go:90 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"b6b368adc57c96c3151d224d172029f233ead2c3","analyzedAt":"2026-08-12T00:22:02.250Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}