micro/go-micro · error

broker %q is not linked into this binary: import go-micro.de

Error message

broker %q is not linked into this binary: import go-micro.dev/v6/cmd/defaults to enable flag-selected plugins

What it means

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.

Source

Thrown at cmd/cmd.go:512

		sopts, clopts := c.setRegistry(r())
		serverOpts = append(serverOpts, sopts...)
		clientOpts = append(clientOpts, clopts...)
	}

	// Set the debug profile
	if name := ctx.String("debug-profile"); len(name) > 0 {
		p, ok := c.opts.DebugProfiles[name]
		if !ok {
			return fmt.Errorf("unsupported profile: %s", name)
		}
		*c.opts.DebugProfile = p()
	}

	// Set the broker
	if name := ctx.String("broker"); len(name) > 0 && (*c.opts.Broker).String() != name {
		b, ok := c.opts.Brokers[name]
		if !ok {
			return fmt.Errorf("broker %q is not linked into this binary: import go-micro.dev/v6/cmd/defaults to enable flag-selected plugins", name)
		}
		sopts, clopts := c.setBroker(b())
		serverOpts = append(serverOpts, sopts...)
		clientOpts = append(clientOpts, clopts...)
	}

	// Set the selector
	if name := ctx.String("selector"); len(name) > 0 && (*c.opts.Selector).String() != name {
		s, ok := c.opts.Selectors[name]
		if !ok {
			return fmt.Errorf("Selector %s not found", name)
		}

		*c.opts.Selector = s(selector.Registry(*c.opts.Registry))

		// No server option here. Should there be?
		clientOpts = append(clientOpts, client.Selector(*c.opts.Selector))
	}

View on GitHub (pinned to 24529f1404)

Solutions

  1. Import _ "go-micro.dev/v6/cmd/defaults" or the specific broker plugin (e.g. _ "go-micro.dev/v6/plugins/broker/nats") and rebuild.
  2. Verify the registered broker name matches the flag value exactly.
  3. Omit --broker to keep the current/default broker.
  4. List which broker plugins your binary imports to confirm availability.

Example fix

// before: missing broker link
micro --broker nats server
// after: main.go
import _ "go-micro.dev/v6/plugins/broker/nats"
// then:
micro --broker nats server
Defensive patterns

Strategy: validation

Validate before calling

allowedBrokers := map[string]bool{"": true, "nats": true, "kafka": true /* linked */}
if !allowedBrokers[*brokerFlag] {
    return fmt.Errorf("broker %q not linked; import its plugin and rebuild", *brokerFlag)
}

Try / catch

if err := c.Run(ctx); err != nil {
    if strings.Contains(err.Error(), "is not linked into this binary") && strings.Contains(err.Error(), "broker") {
        return fmt.Errorf("broker plugin missing: %w", err)
    }
    return err
}

Prevention

When it happens

Trigger: Passing --broker nats/kafka/rabbitmq to a binary that lacks that broker plugin, or a name differing from the current default broker.

Common situations: Custom micro binary built without cmd/defaults; following messaging examples without importing the broker plugin; version migrations where the broker plugin moved packages.

Related errors


AI-assisted analysis of micro/go-micro@24529f1404 (2026-09-01). Data as JSON: /api/errors/4102a592466cab7c. Report an issue: GitHub.