jmattheis / goverter

Generate type-safe Go converters by simply defining an interface
https://goverter.jmattheis.de/
MIT License
496 stars 46 forks source link

How to avoid `go vet copylocks` warnings? #39

Closed s-takehana closed 1 year ago

s-takehana commented 1 year ago

Have you read the project readme?

Describe your question A clear and concise description of what the question is. Include errors and go source files.

How to avoid go vet copylocks warnings?

e.g.

// goverter:converter
type Converter interface {
    Convert(source []Input) []Output
}

// generated gRPC code
type Input struct {
    state         protoimpl.MessageState
    sizeCache     protoimpl.SizeCache
    unknownFields protoimpl.UnknownFields

    Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
}

type Output struct {
    Name string
}
goverter -ignoreUnexportedFields ./example/simple

generated.go

image
call of ***** copies lock value: ***** contains google.golang.org/protobuf/internal/impl.MessageState contains sync.Mutex

I want to use pointer.

image
waltcow commented 1 year ago

same issue here https://github.com/jmattheis/goverter/issues/37#issuecomment-1341904549

s-takehana commented 1 year ago

Thanks!