# Golang DI Notes [](https://cutt.ly/bndHJbJ) - https://cutt.ly/bndHJbJ ``` Class2 / Struct - DoA - DoB - DoC DoAer -> interface DoBer DoCer DoAImpl - class/struct Method(inf) Method(...) < must be restricted to 3 Method(Class2er) Class2 / Struct - DoA - DoB - DoC (Class2er) inf - DoAer - DoBer - DoCer - DoAImpl -> DoAer DI -> (DoAer <-> DoAImpl [Options IsOnetime]) NewClass2(DoAImpl,...) Di.Create<Class2>() Class2 / Struct --> how to refactor field DoAer, DoBer, DoCer NewClass2( DoAer, DoBer ) { DoAer = DoAer, .. } - DoA -> DoAer.DoA() // delegation - DoB -> Dober.Dob() // delegation - DoC .... // Go feature // vars.go var ( doAimpl = NewDoAImpl() doBimpl = NewDoAImpl() .. ) Class2 / Struct --> how to refactor { } NewClass2() { - DoA -> doAimpl.DoA() // delegation - DoB -> doBimpl .Dob() // delegation - DoC ```
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up