wire
wire copied to clipboard
error message about wire.Build does not provide file and line numbers
Please answer these questions before submitting your issue. Thanks!
What did you do?
I ran wire
in a directory containing these files:
[ ~/src/github.com/google/go-cloud/samples/shh ] cat inject_local.go
//+build wireinject
package main
import (
"github.com/google/go-cloud/secrets"
"github.com/google/go-cloud/secrets/localsecrets"
"github.com/google/wire"
)
// setupLocal is a Wire injector function that sets up the application using
// local implementations.
func setupLocal(key [32]byte) (*application, func(), error) {
makeKeeper := func() *localsecrets.Keeper {
return localsecrets.NewKeeper(key)
}
wire.Build(
newApplication,
wire.InterfaceValue(new(secrets.Encrypter), makeKeeper),
)
return nil, nil, nil
}
[ ~/src/github.com/google/go-cloud/samples/shh ] cat inject_rot13.go
//+build wireinject
package main
import (
"context"
"github.com/google/go-cloud/secrets"
"github.com/google/wire"
)
// setupRot13 is a Wire injector function that sets up the application using
// rot13 encryption.
func setupRot13() (*application, func(), error) {
makeEncrypter := func() *rot13 {
return &rot13{}
}
wire.Build(
newApplication,
wire.InterfaceValue(new(secrets.Encrypter), makeEncrypter),
)
return nil, nil, nil
}
type rot13 struct{}
func (r *rot13) Encrypt(ctx context.Context, plainText []byte) ([]byte, error) {
cipher := make([]byte, len(plainText))
for i, c := range plainText {
b, ok := m[c]
if ok {
cipher[i] = b
} else {
cipher[i] = c
}
}
return cipher, nil
}
var m = map[byte]byte{}
func init() {
in := "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
out := "NOPQRSTUVWXYZABCDEFGHIJKLMnopqrstuvwxyzabcdefghijklm"
for i, bi := range in {
bo := out[i]
m[byte(bi)] = bo
}
}
What did you expect to see?
I expected to see wire_gen.go generated, or an error message helping me find out why not.
What did you see instead?
[ ~/src/github.com/google/go-cloud/samples/shh ] wire
github.com/google/go-cloud/samples/shh: generate failed
a call to wire.Build indicates that this function is an injector, but injectors must consist of only the wire.Build call and an optional return
a call to wire.Build indicates that this function is an injector, but injectors must consist of only the wire.Build call and an optional return
wire: at least one generate failure
The error message here doesn't say where the problem is.
System details
go version go1.11.2 darwin/amd64
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/issactrotts/Library/Caches/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/issactrotts"
GOPROXY=""
GORACE=""
GOROOT="/Users/issactrotts/homebrew/Cellar/go/1.11.2/libexec"
GOTMPDIR=""
GOTOOLDIR="/Users/issactrotts/homebrew/Cellar/go/1.11.2/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD=""
GOROOT/bin/go version: go version go1.11.2 darwin/amd64
GOROOT/bin/go tool compile -V: compile version go1.11.2
uname -v: Darwin Kernel Version 17.7.0: Wed Oct 10 23:06:14 PDT 2018; root:xnu-4570.71.13~1/RELEASE_X86_64
ProductName: Mac OS X
ProductVersion: 10.13.6
BuildVersion: 17G3025
lldb --version: lldb-1000.0.38.2
Swift-4.2
@ijt, can you elaborate more on what information would have helped you to address the issue?
Sure. I wanted it to tell me the file and line number where the problem occurred.
Yeah, that's not working as expected. Thanks for the report!