Skip to content

Load input failed: unknown package error with aliased importsΒ #254

@jDomantas

Description

@jDomantas

Actual behavior

File contents:

// file subpkg/alphabetically_first.go
package subpkg

import (
	"time"
)

var _ time.Time


// file subpkg/alphabetically_second.go
package subpkg

import (
	aliased_time_import "time"
)

type I1 interface {
	Foo(t aliased_time_import.Time)
}


// file x.go
package mockgen_repro

import "mockgen_repro/subpkg"

type I2 interface {
	subpkg.I1
}


// file go.mod
module mockgen_repro

go 1.24.0

Mockgen in source mode on x.go fails:

# mockgen -source x.go
2025/05/20 11:53:46 Loading input failed: .../mockgen_repro/subpkg/alphabetically_second.go:8:5: failed parsing arguments: .../mockgen_repro/subpkg/alphabetically_second.go:8:8: unknown package "aliased_time_import"

Expected behavior

Mock generation should succeed (like it does if I rename alphabetically_first.go and alphabetically_second.go to be ordered the other way around).

Additional Information

  • gomock mode (reflect or source): source
  • gomock version or git ref: v0.5.2
  • golang version: 1.24.0

Triage Notes for the Maintainers

There is some existing discussion about this bug in #166, but the original reported bug there was different and the issue got closed, so I'm reporting it here again with the reproduction specifically for the issue that I encountered.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions