{"record":{"id":"38f12a39b62f0684","repo":"golang/go","slug":"copying-s-to-s-v","errorCode":null,"errorMessage":"copying %s to %s: %v","messagePattern":"copying (.+?) to (.+?): (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cmd/go/internal/work/gc.go","lineNumber":528,"sourceCode":"\t\t// about bytes, not runes.\n\t\tname := fi.Name()\n\t\tif len(name) > 16 {\n\t\t\tname = name[:16]\n\t\t} else {\n\t\t\tname += strings.Repeat(\" \", 16-len(name))\n\t\t}\n\t\tsize := fi.Size()\n\t\tfmt.Fprintf(w, \"%s%-12d%-6d%-6d%-8o%-10d`\\n\",\n\t\t\tname, 0, 0, 0, 0644, size)\n\t\tn, err := io.Copy(w, src)\n\t\tsrc.Close()\n\t\tif err == nil && n < size {\n\t\t\terr = io.ErrUnexpectedEOF\n\t\t} else if err == nil && n > size {\n\t\t\terr = fmt.Errorf(\"file larger than size reported by stat\")\n\t\t}\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"copying %s to %s: %v\", ofile, afile, err)\n\t\t}\n\t\tif size&1 != 0 {\n\t\t\tw.WriteByte(0)\n\t\t}\n\t}\n\n\tif err := w.Flush(); err != nil {\n\t\treturn err\n\t}\n\treturn dst.Close()\n}\n\n// setextld sets the appropriate linker flags for the specified compiler.\nfunc setextld(ldflags []string, compiler []string) ([]string, error) {\n\tfor _, f := range ldflags {\n\t\tif f == \"-extld\" || strings.HasPrefix(f, \"-extld=\") {\n\t\t\t// don't override -extld if supplied\n\t\t\treturn ldflags, nil","sourceCodeStart":510,"sourceCodeEnd":546,"githubUrl":"https://github.com/golang/go/blob/b6b368adc57c96c3151d224d172029f233ead2c3/src/cmd/go/internal/work/gc.go#L510-L546","documentation":"A wrapper that fires when copying an object file (ofile) into an archive (afile) fails for any reason - including the file-larger-than-stat case (1193), an unexpected EOF where the file shrank (n < size), or a raw I/O error from io.Copy. The placeholders are the source object path and the destination archive path.","triggerScenarios":"Fires in the archive builder after io.Copy when err != nil (short read, long read, or copy failure), wrapping the underlying error with source and destination paths.","commonSituations":"Concurrent modification of object files, a full disk, broken build artifacts, or filesystem errors during the archive step.","solutions":["Run `go clean -cache` and rebuild","Ensure no concurrent builds modify the same object files","Check disk space and filesystem health"],"exampleFix":"// before\ngo build ./...\n// after\ngo clean -cache && go build ./...","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"// Archive copy failed (race or I/O): clean and retry\nif bytes.Contains(out, []byte(\"copying\")) && bytes.Contains(out, []byte(\"to\")) {\n    exec.Command(\"go\", \"clean\", \"-cache\").Run()\n    out, err = cmd.CombinedOutput()\n}","preventionTips":["Run a single build at a time per work directory","Keep GOCACHE and the build output on reliable local storage","Monitor disk space during large builds"],"tags":["go-toolchain","archive","io","filesystem"],"analyzedSha":"b6b368adc57c96c3151d224d172029f233ead2c3","analyzedAt":"2026-08-12T00:22:02.250Z","schemaVersion":2},"datasetVersion":"2026-08-12T08:17:17.861Z"}