wire icon indicating copy to clipboard operation
wire copied to clipboard

how to solve "redeclare in this package "after generate

Open whybangbang opened this issue 3 years ago • 2 comments

after command "wire" execute, duplicate funciton name will exist in a same package, for example "InitializeApi" how to solve, thx image

whybangbang avatar Mar 13 '22 03:03 whybangbang

Did you put the build constraints in wire.go? For example see https://github.com/google/wire/blob/9d78e0ad8cbeb6716fa6bdbca689bdb9ce0e8fe8/_tutorial/wire.go#L15-L16

If this doesn't work, can you provide a more detailed repro step? e.g. What does your source look like, and what command did you run that tells you "redeclare in this package". Thanks!

jayzhuang avatar Apr 17 '22 22:04 jayzhuang

@whybangbang don't forget the add trailing line

//go:build wireinject 
 // +build wireinject 

image

raza-basit avatar Aug 14 '22 06:08 raza-basit