Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing package in generated fakes with go.mod version at 1.23 #298

Open
nginx-nickc opened this issue Sep 18, 2024 · 2 comments
Open

Missing package in generated fakes with go.mod version at 1.23 #298

nginx-nickc opened this issue Sep 18, 2024 · 2 comments

Comments

@nginx-nickc
Copy link

Similar to #297, seeing different results with go.mod set to 1.22 vs 1.23.

package service

import (
	"context"
	"google.golang.org/protobuf/proto"

)

//go:generate go run github.com/maxbrunsfeld/counterfeiter/v6 -generate

//counterfeiter:generate . Example
type Example interface {
	FindExample(context.Context, proto.Message) ([]string, error)
}

with following go.mod file

module foo

go 1.22.0

toolchain go1.23.1

require google.golang.org/protobuf v1.34.2

require (
	github.com/google/go-cmp v0.6.0 // indirect
	github.com/maxbrunsfeld/counterfeiter/v6 v6.9.0 // indirect
	golang.org/x/mod v0.21.0 // indirect
	golang.org/x/sync v0.8.0 // indirect
	golang.org/x/text v0.18.0 // indirect
	golang.org/x/tools v0.25.0 // indirect
)

getting, works, but not quite correct.

package examplefakes

import (
        "context"
        service "foo"
        "sync"

        "google.golang.org/protobuf/reflect/protoreflect"
)

type FakeExample struct {
        FindExampleStub        func(context.Context, protoreflect.ProtoMessage) ([]string, error)
        findExampleMutex       sync.RWMutex
        findExampleArgsForCall []struct {
                arg1 context.Context
                arg2 protoreflect.ProtoMessage
        }

when change go.mod to

module foo

go 1.23.1

require google.golang.org/protobuf v1.34.2

require (
        github.com/google/go-cmp v0.6.0 // indirect
        github.com/maxbrunsfeld/counterfeiter/v6 v6.9.0 // indirect
        golang.org/x/mod v0.21.0 // indirect
        golang.org/x/sync v0.8.0 // indirect
        golang.org/x/text v0.18.0 // indirect
        golang.org/x/tools v0.25.0 // indirect
)

getting the following, which is causing errors.

package examplefakes

import (
        "context"
        service "foo"
        "sync"
)

type FakeExample struct {
        FindExampleStub        func(context.Context, Message) ([]string, error)
        findExampleMutex       sync.RWMutex
        findExampleArgsForCall []struct {
                arg1 context.Context
                arg2 Message
        }
        findExampleReturns struct {

Looks like possible work around

GODEBUG=gotypesalias=0 go generate ./...

xanderflood added a commit to xanderflood/counterfeiter that referenced this issue Oct 9, 2024
@xanderflood
Copy link
Contributor

#301 proposed fix!

@maxbrunsfeld feedback (and/or approval to run the test workflows) would be greatly appreciated!

@joefitzgerald
Copy link
Collaborator

Please try updating to v6.10.0, which includes #301 (thanks @xanderflood!). Let me know if that resolves the issue fully.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants