wire
wire copied to clipboard
Result parameter names are not retained for generated injectors
Describe the bug
Result parameter names are not retained for generated injectors. Result parameters can be useful for tools like gopls and IDEs for suggesting variable names, generating code, and can help provide semantic context to callers of injectors.
To Reproduce
Create an injector that has a result parameter name. Call wire. Observe that the result parameter name is not copied to the generated injector.
Minimum Reproduction
Input:
// wire.go
package main
import (
"github.com/google/wire"
)
func provide() (string) {
return "provided"
}
func Inject() (val string) {
panic(wire.Build(provide))
}
Output:
// Code generated by Wire. DO NOT EDIT.
//go:generate wire
//+build !wireinject
package main
// Injectors from wire.go:
func Inject() string {
string2 := provide()
return string2
}
// wire.go:
func provide() string {
return "provided"
}
Expected behavior
I would expect the result parameter name to be copied if it exists.
// ...
func Inject() (val string) {
string2 := provide()
return string2
}
// ...
Version
github.com/google/wire v0.4.0
Additional Information
$ go version go version go1.14 windows/amd64
go env Output
$ go env set GO111MODULE=on set GOARCH=amd64 set GOBIN=C:\Users\jense\bin set GOCACHE=C:\Users\jense\AppData\Local\go-build set GOENV=C:\Users\jense\AppData\Roaming\go\env set GOEXE=.exe set GOFLAGS= set GOHOSTARCH=amd64 set GOHOSTOS=windows set GOINSECURE= set GONOPROXY= set GONOSUMDB= set GOOS=windows set GOPATH=C:\Users\jense\go set GOPRIVATE= set GOPROXY=https://proxy.golang.org,direct set GOROOT=c:\go set GOSUMDB=sum.golang.org set GOTMPDIR= set GOTOOLDIR=c:\go\pkg\tool\windows_amd64 set GCCGO=gccgo set AR=ar set CC=gcc set CXX=g++ set CGO_ENABLED=1 set GOMOD=C:\Users\jense\go.mod set CGO_CFLAGS=-g -O2 set CGO_CPPFLAGS= set CGO_CXXFLAGS=-g -O2 set CGO_FFLAGS=-g -O2 set CGO_LDFLAGS=-g -O2 set PKG_CONFIG=pkg-config set GOGCCFLAGS=-m64 -mthreads -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=C:\Users\jense\AppData\Local\Temp\go-build761127338=/tmp/go-build -gno-record-gcc-switches GOROOT/bin/go version: go version go1.14 windows/amd64 GOROOT/bin/go tool compile -V: compile version go1.14