Skip to content
This repository was archived by the owner on Jun 27, 2023. It is now read-only.
This repository was archived by the owner on Jun 27, 2023. It is now read-only.

Does -imports work? Package alias is inconsistent, and -imports does not fix it. #646

Open
uber-go/mock
#41
@AndrewDK

Description

@AndrewDK

Actual behavior A clear and concise description of what the bug is.

The package alias produced by mockgen is variable for the same inputs. Specifically, sometimes we see
extract "github.com/codeclysm/extract/v3"
and others we see
v3 "github.com/codeclysm/extract/v3"
Also, using -imports extract=github.com/codeclysm/extract/v3 does not have any effect on the output.

Expected behavior A clear and concise description of what you expected to happen.

I expect the same inputs to product the same outputs.
I expect -imports to determine the package alias.

To Reproduce Steps to reproduce the behavior

  1. This program creates a mock file with no mention of cheesecake, as expected. Am I using -imports correctly, and is that the effect it's supposed to have?
package main

import (
	"context"
	"io"

	"github.com/codeclysm/extract/v3"
)

//go:generate go run github.com/golang/mock/mockgen -destination=mock_if.go -package main -source ./gomocktest.go -imports cheesecake=github.com/codeclysm/extract/v3

type IF interface {
	ExtractGz(ctx context.Context, body io.Reader, location string, renamer extract.Renamer) error
	ExtractZip(ctx context.Context, body io.Reader, location string, renamer extract.Renamer) error
}

func main() {
	print("hello world")
}

Additional Information

  • gomock mode (reflect or source): Source, run from go generate although running directly has the same output.
  • gomock version or git ref: github.com/golang/mock v1.6.0
  • golang version: 1.17

Triage Notes for the Maintainers

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions