Closed
Description
Bug description
Wire generates broken code. It generates function body without return statement.
To Reproduce
Run wire
with following file
// +build wireinject
package storage
import "github.com/google/wire"
type MyInterface interface {
Method()
}
type MyImplementation struct{}
func (MyImplementation) Method() {}
func XXX(MyImplementation) MyInterface {
wire.Build(wire.Bind(new(MyInterface), new(MyImplementation)))
return nil
}
It will generate following file
// Code generated by Wire. DO NOT EDIT.
//go:generate wire
//+build !wireinject
package storage
// Injectors from missed_return.go:
func XXX(myImplementation MyImplementation) MyInterface {
}
// missed_return.go:
type MyInterface interface {
Method()
}
type MyImplementation struct{}
func (MyImplementation) Method() {}
Expected behavior
Wire should generate following file
//+build !wireinject
package storage
// Injectors from missed_return.go:
func XXX(myImplementation MyImplementation) MyInterface {
return myImplementation
}
// missed_return.go:
type MyInterface interface {
Method()
}
type MyImplementation struct{}
func (MyImplementation) Method() {}
Version
github.com/google/wire v0.3.0
go version go1.13 darwin/amd64
Activity