Init functions not found during build via make file

11 views
Skip to first unread message

Em

unread,
Nov 4, 2020, 11:23:06 AM11/4/20
to go-cloud
I have main.go in which i am creating my logger using the InitializeLogger methods from wire. here is how my wire.go looks like

//+build wireinject

package main


func InitializeLogger(writer io.Writer, options ...func(*servicelogger.Logger)) servicelogger.Logger {
    panic(wire.Build(servicelogger.New))
}

func InitializeColorLogger(writer io.Writer, options ...func(*servicelogger.Logger)) servicelogger.Logger {
    panic(wire.Build(servicelogger.NewColorLogger))
}
//------
now in the directory where i have this main.go and wire.go, I ran wire command and it successfully generated wire_gen.go. I build my project via make file. The command that builds the project is

GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -a -o service-name cmd/servicename/main.go;

However, this command is giving me error that it couldn't find  InitializeLogger and InitializeColorLogger

Is there any flag that i need to add to my build command? 

rvan...@google.com

unread,
Nov 4, 2020, 11:30:39 AM11/4/20
to go-cloud
Make sure to include wire_gen.go in your build...?

Overall, your problem doesn't look like it has anything to do with wire; one of the nice things about wire is that it happens at compile time. wire_gen.go is just a regular .go file like any other. 

HTH


Reply all
Reply to author
Forward
0 new messages