Skip to content

Generated imports omit major-version suffix for v2+ modules (e.g. antlr/v4 -> antlr) #121

Description

@bobmorley

When generating a decorator for an interface that references types from a Go module with a major-version suffix (e.g. github.com/antlr4-go/antlr/v4), gowrap can emit an import path without the /v4 suffix:

import "github.com/antlr4-go/antlr"  // wrong

instead of:

import "github.com/antlr4-go/antlr/v4"  // correct

This causes go mod tidy to pull in the legacy pseudo-version module (github.com/antlr4-go/antlr v0.0.0-...) rather than the intended v4 module.

Workaround
Declare imports explicitly in the template; otherwise goimports picks github.com/antlr4-go/antlr instead of .../antlr/v4.

import (
	"errors"

	"github.com/antlr4-go/antlr/v4"
)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions