-
-
Notifications
You must be signed in to change notification settings - Fork 61
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Describe the bug
some convert function for grpc:
import (
"time"
"google.golang.org/protobuf/types/known/timestamppb"
)
// goverter:converter
// goverter:extend TimeToTimestamppb
type ConverterTimeToTimestamppb interface {
ConverterTimeToTimestamppb(source Input) Output
}
type Input struct {
Time time.Time
}
type Output struct {
Time *timestamp.Timestamp
}
// not work
// goverter build with go1.25 cannot recognize `type timestamp.Timestamp = timestamppb.Timestamp`
func TimeToTimestamppb(time time.Time) *timestamppb.Timestamp {
return timestamppb.New(time)
}To Reproduce
exec command (it work on goverter with go1.23), I got this:
$ goverter gen -g 'ignoreUnexported yes' ./convert
Error while creating converter method:
./convert/convert.go:19
func (convert.ConverterTimeToTimestamppb).ConverterTimeToTimestamppb(source convert.Input) convert.Output
[source] convert.Input
[target] convert.Output
| convert.Input
|
| | time.Time
| |
source.Time .???
target.Time*.Seconds
| | | |
| | | | int64
| | |
| | | google.golang.org/protobuf/types/known/timestamppb.Timestamp
| |
| | *github.com/golang/protobuf/ptypes/timestamp.Timestamp
|
| convert.Output
Cannot match the target field with the source entry: "Seconds" does not exist.Expected behavior
recognize type alias.
By the way, I found a solution, change the output type of the function from *timestamppb.Timestamp to *timestamp.Timestamp,
func TimeToTimestamp(time time.Time) *timestamp.Timestamp {
return timestamppb.New(time)
}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working