Skip to content
Latchkey

protoc "--go_out: protoc-gen-go: Plugin failed with status code 1" in CI

protoc launched protoc-gen-go successfully but the plugin itself exited with status 1. The plugin prints its own error above this line: most often a missing go_package option or an unresolved import mapping.

What this error means

protoc fails with "--go_out: protoc-gen-go: Plugin failed with status code 1", preceded by a plugin message about go_package or an M option for an imported file.

protoc
protoc-gen-go: unable to determine Go import path for "api/v1/user.proto"

Please specify either:
  - a "go_package" option in the .proto source file, or
  - a "M" argument on the command line.

--go_out: protoc-gen-go: Plugin failed with status code 1.

Common causes

The .proto file has no go_package option

protoc-gen-go needs a Go import path to place generated files; without option go_package = "..." it cannot determine one and exits 1.

An imported .proto lacks an M mapping

A referenced file has no go_package and no M<file>=<import> argument on the command line, so the plugin cannot resolve where its types live.

How to fix it

Add a go_package option to every .proto

  1. Add option go_package = "example.com/gen/apiv1;apiv1"; to each proto.
  2. Regenerate so the plugin has an import path.
  3. Commit the regenerated Go files.
api/v1/user.proto
option go_package = "example.com/proto/gen/api/v1;apiv1";

Map imports with M arguments

When you cannot edit an imported proto, provide the mapping on the command line as the plugin suggests.

Terminal
protoc --go_out=. \
  --go_opt=Mapi/v1/user.proto=example.com/gen/apiv1 \
  api/v1/user.proto

How to prevent it

  • Set go_package in every proto so codegen is unambiguous.
  • Use --go_opt=module=... to strip a common prefix consistently.
  • Generate through buf.gen.yaml so options are declared once, not per invocation.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →