{"record":{"id":"4102a592466cab7c","repo":"micro/go-micro","slug":"broker-q-is-not-linked-into-this-binary-import-g","errorCode":null,"errorMessage":"broker %q is not linked into this binary: import go-micro.dev/v6/cmd/defaults to enable flag-selected plugins","messagePattern":"broker %q is not linked into this binary: import go-micro\\.dev/v6/cmd/defaults to enable flag-selected plugins","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/cmd.go","lineNumber":512,"sourceCode":"\t\tsopts, clopts := c.setRegistry(r())\n\t\tserverOpts = append(serverOpts, sopts...)\n\t\tclientOpts = append(clientOpts, clopts...)\n\t}\n\n\t// Set the debug profile\n\tif name := ctx.String(\"debug-profile\"); len(name) > 0 {\n\t\tp, ok := c.opts.DebugProfiles[name]\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unsupported profile: %s\", name)\n\t\t}\n\t\t*c.opts.DebugProfile = p()\n\t}\n\n\t// Set the broker\n\tif name := ctx.String(\"broker\"); len(name) > 0 && (*c.opts.Broker).String() != name {\n\t\tb, ok := c.opts.Brokers[name]\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"broker %q is not linked into this binary: import go-micro.dev/v6/cmd/defaults to enable flag-selected plugins\", name)\n\t\t}\n\t\tsopts, clopts := c.setBroker(b())\n\t\tserverOpts = append(serverOpts, sopts...)\n\t\tclientOpts = append(clientOpts, clopts...)\n\t}\n\n\t// Set the selector\n\tif name := ctx.String(\"selector\"); len(name) > 0 && (*c.opts.Selector).String() != name {\n\t\ts, ok := c.opts.Selectors[name]\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"Selector %s not found\", name)\n\t\t}\n\n\t\t*c.opts.Selector = s(selector.Registry(*c.opts.Registry))\n\n\t\t// No server option here. Should there be?\n\t\tclientOpts = append(clientOpts, client.Selector(*c.opts.Selector))\n\t}","sourceCodeStart":494,"sourceCodeEnd":530,"githubUrl":"https://github.com/micro/go-micro/blob/24529f140421a11a33b6999ab7944f2021cfd69c/cmd/cmd.go#L494-L530","documentation":"The --broker flag is looked up in c.opts.Brokers, which only contains brokers whose plugin packages were imported and whose init() registered them. Unknown names abort the Before hook with this linking hint.","triggerScenarios":"Passing --broker nats/kafka/rabbitmq to a binary that lacks that broker plugin, or a name differing from the current default broker.","commonSituations":"Custom micro binary built without cmd/defaults; following messaging examples without importing the broker plugin; version migrations where the broker plugin moved packages.","solutions":["Import _ \"go-micro.dev/v6/cmd/defaults\" or the specific broker plugin (e.g. _ \"go-micro.dev/v6/plugins/broker/nats\") and rebuild.","Verify the registered broker name matches the flag value exactly.","Omit --broker to keep the current/default broker.","List which broker plugins your binary imports to confirm availability."],"exampleFix":"// before: missing broker link\nmicro --broker nats server\n// after: main.go\nimport _ \"go-micro.dev/v6/plugins/broker/nats\"\n// then:\nmicro --broker nats server","handlingStrategy":"validation","validationCode":"allowedBrokers := map[string]bool{\"\": true, \"nats\": true, \"kafka\": true /* linked */}\nif !allowedBrokers[*brokerFlag] {\n    return fmt.Errorf(\"broker %q not linked; import its plugin and rebuild\", *brokerFlag)\n}","typeGuard":null,"tryCatchPattern":"if err := c.Run(ctx); err != nil {\n    if strings.Contains(err.Error(), \"is not linked into this binary\") && strings.Contains(err.Error(), \"broker\") {\n        return fmt.Errorf(\"broker plugin missing: %w\", err)\n    }\n    return err\n}","preventionTips":["Import the broker plugin package (or cmd/defaults) wherever --broker flags are used.","List linked brokers in your release notes so ops knows valid flag values.","Validate broker flags in entrypoint scripts before launching the binary."],"tags":["cli","broker","plugin-not-linked"],"backgroundTag":"plugin-not-linked","analyzedSha":"24529f140421a11a33b6999ab7944f2021cfd69c","analyzedAt":"2026-09-01T02:52:24.923Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}