Is there a better dependency injection pattern in golang?

后端 未结 6 1891
野趣味
野趣味 2021-02-07 09:07

Given this code:

package main

import (
    \"fmt\"
)

type datstr string

type Guy interface {
   SomeDumbGuy() string
}

func (d *datstr) SomeDumbGuy() string          


        
6条回答
  •  -上瘾入骨i
    2021-02-07 09:49

    If you're still interested in finding a DI library for Go that uses very minimal reflection I made one called axon. It's based on Google's Guice so if you're coming from the Java world (like myself) it should lend itself well to how you expect it to work.

    I've used it in web servers and it hasn't had any problems and was fast enough to not have any impact on being used within CLIs.

提交回复
热议问题