{"record":{"id":"8c5365865e99be7b","repo":"golang/go","slug":"zip-write-to-closed-file","errorCode":null,"errorMessage":"zip: write to closed file","messagePattern":"zip: write to closed file","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/archive/zip/writer.go","lineNumber":633,"sourceCode":"\tif len(b) == 0 {\n\t\treturn 0, nil\n\t}\n\treturn 0, errors.New(\"zip: write to directory\")\n}\n\ntype fileWriter struct {\n\t*header\n\tzipw      io.Writer\n\trawCount  *countWriter\n\tcomp      io.WriteCloser\n\tcompCount *countWriter\n\tcrc32     hash.Hash32\n\tclosed    bool\n}\n\nfunc (w *fileWriter) Write(p []byte) (int, error) {\n\tif w.closed {\n\t\treturn 0, errors.New(\"zip: write to closed file\")\n\t}\n\tif w.raw {\n\t\treturn w.zipw.Write(p)\n\t}\n\tw.crc32.Write(p)\n\treturn w.rawCount.Write(p)\n}\n\nfunc (w *fileWriter) close() error {\n\tif w.closed {\n\t\treturn errors.New(\"zip: file closed twice\")\n\t}\n\tw.closed = true\n\tif w.raw {\n\t\treturn w.writeDataDescriptor()\n\t}\n\tif err := w.comp.Close(); err != nil {\n\t\treturn err","sourceCodeStart":615,"sourceCodeEnd":651,"githubUrl":"https://github.com/golang/go/blob/b6b368adc57c96c3151d224d172029f233ead2c3/src/archive/zip/writer.go#L615-L651","documentation":"Error \"zip: write to closed file\" thrown in golang/go.","triggerScenarios":"Thrown at src/archive/zip/writer.go:633 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"analyzedSha":"b6b368adc57c96c3151d224d172029f233ead2c3","analyzedAt":"2026-08-12T00:22:02.250Z","schemaVersion":2},"datasetVersion":"2026-08-12T08:17:17.861Z"}