Skip to content
This repository was archived by the owner on Aug 25, 2025. It is now read-only.
This repository was archived by the owner on Aug 25, 2025. It is now read-only.

wire.go file #305

@bereyes

Description

@bereyes

Discussed in #304

Originally posted by bereyes August 18, 2021
Sorry , I have a question:
wire.go file must be on main package? If I have wire.go in another package , when I use wire cmd I am getting "undeclared name: methodName" message, and I am not sure why.
EDIT:
If wire.go is in the same folder that a provider it fails:
Example

func InitializeWebAPI() *Container {
	wire.Build(
		NewControllerContainer,
		api.NewPingController,
	)
	return &Container{}
}

If wire.go is out that folder wire cmd is able to generate wire_gen.go , is it a correct behavior?
When my code looks like:

package infrastructure

import (
	"github.com/google/wire"
	"github.com/yyy/xxx-api-rules-test/cmd/entrypoint/api"
	"github.com/yyy/xxx-test/cmd/infrastructure/dependency"
)

func InitializeWebAPI() *dependency.Container {
	wire.Build(
		dependency.NewControllerContainer,
		api.NewPingController,
	)
	return &dependency.Container{}
}

wire works well
Could you help me please?

Thanks in advance

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions