{"record":{"id":"ae623cf3a61fc39e","repo":"golang/go","slug":"binary-only-packages-are-no-longer-supported","errorCode":null,"errorMessage":"binary-only packages are no longer supported","messagePattern":"binary-only packages are no longer supported","errorType":"validation","errorClass":"PackageError","httpStatus":null,"severity":"error","filePath":"src/cmd/go/internal/load/pkg.go","lineNumber":2001,"sourceCode":"\t\tfoldPath[fold] = p.ImportPath\n\t} else if other != p.ImportPath {\n\t\tsetError(ImportErrorf(p.ImportPath, \"case-insensitive import collision: %q and %q\", p.ImportPath, other))\n\t\treturn\n\t}\n\n\tif !SafeArg(p.ImportPath) {\n\t\tsetError(ImportErrorf(p.ImportPath, \"invalid import path %q\", p.ImportPath))\n\t\treturn\n\t}\n\n\t// Errors after this point are caused by this package, not the importing\n\t// package. Pushing the path here prevents us from reporting the error\n\t// with the position of the import declaration.\n\tstk.Push(ImportInfo{Pkg: path, Pos: extractFirstImport(importPos)})\n\tdefer stk.Pop()\n\n\tif p.BinaryOnly {\n\t\tsetError(errors.New(\"binary-only packages are no longer supported\"))\n\t}\n\n\tpkgPath := p.ImportPath\n\tif p.Internal.CmdlineFiles {\n\t\tpkgPath = \"command-line-arguments\"\n\t}\n\tif cfg.ModulesEnabled {\n\t\tp.Module = modload.PackageModuleInfo(ld, ctx, pkgPath)\n\t}\n\tp.DefaultGODEBUG = defaultGODEBUG(ld, p, nil, nil, nil)\n\n\tif !opts.SuppressEmbedFiles {\n\t\tp.EmbedFiles, p.Internal.Embed, err = resolveEmbed(p.Dir, p.EmbedPatterns)\n\t\tif err != nil {\n\t\t\tp.Incomplete = true\n\t\t\tsetError(err)\n\t\t\tembedErr := err.(*EmbedError)\n\t\t\tp.Error.setPos(p.Internal.Build.EmbedPatternPos[embedErr.Pattern])","sourceCodeStart":1983,"sourceCodeEnd":2019,"githubUrl":"https://github.com/golang/go/blob/b6b368adc57c96c3151d224d172029f233ead2c3/src/cmd/go/internal/load/pkg.go#L1983-L2019","documentation":"The //go:binary-only-package pragma was a GOPATH-era mechanism to distribute a package as a precompiled .a file without source. Support was removed; the loader now unconditionally errors when p.BinaryOnly is true. The package cannot be built, imported, or used in module mode.","triggerScenarios":"A Go source file in the package (or its documented stub) contains the `//go:binary-only-package` comment, causing p.BinaryOnly to be set during package load.","commonSituations":"Legacy projects migrated from GOPATH that depended on closed-source binary-only libraries; vendored commercial libraries once shipped as .a files; old documentation or tutorials suggesting the pragma.","solutions":["Obtain the source code for the package and remove the //go:binary-only-package comment.","Replace the closed-source dependency with an open-source or source-available alternative module.","Publish the library through a private module proxy that serves source so the go command can build it."],"exampleFix":"// before (stub.go):\n//go:binary-only-package\npackage foo\n\n// after: provide the real source, remove the pragma line\npackage foo","handlingStrategy":"validation","validationCode":"// Scan for the pragma before building:\n//   grep -rn \"go:binary-only-package\" .\n// If found, remove the comment and provide source, or replace the dependency.","typeGuard":null,"tryCatchPattern":null,"preventionTips":["When migrating from GOPATH to modules, audit dependencies for the //go:binary-only-package pragma.","Prefer source-available dependencies distributed through a module proxy."],"tags":["go","gopath","binary-only","legacy","build"],"analyzedSha":"b6b368adc57c96c3151d224d172029f233ead2c3","analyzedAt":"2026-08-12T00:22:02.250Z","schemaVersion":2},"datasetVersion":"2026-08-12T12:17:08.281Z"}