golangci/golangci-lint · error

missing config argument in constructor

Error message

missing config argument in constructor

What it means

Programmer-guard inside NewPrinter: the cfg parameter (*config.Formats) was nil. This is a defensive constructor check, not a user-facing config error — the caller (typically the run command wiring) passed an invalid argument.

Source

Thrown at pkg/printers/printer.go:47

// Printer prints issues.
type Printer struct {
	cfg        *config.Formats
	reportData *report.Data
	basePath   string

	log logutils.Log

	stdOut io.Writer
	stdErr io.Writer
}

// NewPrinter creates a new Printer.
func NewPrinter(log logutils.Log, cfg *config.Formats, reportData *report.Data, basePath string) (*Printer, error) {
	if log == nil {
		return nil, errors.New("missing log argument in constructor")
	}
	if cfg == nil {
		return nil, errors.New("missing config argument in constructor")
	}
	if reportData == nil {
		return nil, errors.New("missing reportData argument in constructor")
	}

	return &Printer{
		cfg:        cfg,
		reportData: reportData,
		basePath:   basePath,
		log:        log,
		stdOut:     logutils.StdOut,
		stdErr:     logutils.StdErr,
	}, nil
}

// Print prints issues based on the formats defined.
//
//nolint:gocyclo,funlen // the complexity is related to the number of formats.

View on GitHub (pinned to ed7a235d2d)

Solutions

  1. Ensure callers construct a valid *config.Formats before calling NewPrinter
  2. Fix the calling code to pass the loaded formats configuration
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at pkg/printers/printer.go:47 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of golangci/golangci-lint@ed7a235d2d (2026-09-02). Data as JSON: /api/errors/e29f3c100e32f73b. Report an issue: GitHub.