hexdigest / gowrap

GoWrap is a command line tool for generating decorators for Go interfaces
MIT License
1.06k stars 82 forks source link

Generated imports fail when we have an alias #90

Open NoGambiNoBugs opened 3 months ago

NoGambiNoBugs commented 3 months ago

When we have some interface with methods that use parameters from another package that was imported with an alias... the result is not going well, just to explain:

This is working:

Code:

import ".../pkg/proto"

...

// MyInterface is a driven port.
//
//go:generate gowrap gen -g -i MyInterface -t ../templates/log.go.tmpl -o ./decorators/logs/url_shortener_gateway_with_logs.go
type MyInterface interface {
    MyMethod(ctx context.Context, body proto.Incomming) (proto.Outcomming, error)
}

This isn't working:

Code:

import alias ".../pkg/proto"

...

// MyInterface is a driven port.
//
//go:generate gowrap gen -g -i MyInterface -t ../templates/log.go.tmpl -o ./decorators/logs/url_shortener_gateway_with_logs.go
type MyInterface interface {
    MyMethod(ctx context.Context, body alias.Incomming) (alias.Outcomming, error)
}

I am using the latest version of package.