{"record":{"id":"6da6c5c9f7468c2c","repo":"golang/go","slug":"zip-write-to-directory","errorCode":null,"errorMessage":"zip: write to directory","messagePattern":"zip: write to directory","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/archive/zip/writer.go","lineNumber":618,"sourceCode":"\t\treturn err\n\t})\n}\n\nfunc (w *Writer) compressor(method uint16) Compressor {\n\tcomp := w.compressors[method]\n\tif comp == nil {\n\t\tcomp = compressor(method)\n\t}\n\treturn comp\n}\n\ntype dirWriter struct{}\n\nfunc (dirWriter) Write(b []byte) (int, error) {\n\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)","sourceCodeStart":600,"sourceCodeEnd":636,"githubUrl":"https://github.com/golang/go/blob/b6b368adc57c96c3151d224d172029f233ead2c3/src/archive/zip/writer.go#L600-L636","documentation":"Error \"zip: write to directory\" thrown in golang/go.","triggerScenarios":"Thrown at src/archive/zip/writer.go:618 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-12T06:17:24.410Z"}