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.

Allow Provider without return values #287

Description

@khanakia

Is your feature request related to a problem? Please describe.

I want to achieve this

type Server struct {}

func (server Server) AddRoute(path string) {
}

func (server Server) Start() {
  fmt.Println("started")
}

func NewServer() Server {
  return Server{}
}

func NewAuth(server Server) {
  server.AddRoute("/login")
}

func main() {
  server := NewServer()
  NewAuth(server)
  server.Start()
}

wire.go

//+build wireinject

package main

import "github.com/google/wire"

func Init() Server {
	wire.Build(NewServer, NewAuth)
	return Server{}
}

returns error

Lucians-MacBook-Pro:kookgo khanakia$ wire
wire: /Volumes/D/www/go1/kookgo/main.go:22:6: wrong signature for provider NewAuth: no return values
wire: github.com/khanakia/kookgo: generate failed
wire: at least one generate failure

Describe the solution you'd like

A clear and concise description of what you want to happen.

Describe alternatives you've considered

How do i use the NewAuth(server) without returning any value ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions