Skip to content
/ di Public

this lib combines golang plugin mechanism & a tricky reflection mechanism to implement dependency injection in golang.

Notifications You must be signed in to change notification settings

titanxxh/di

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

di(dynamic injection)

this lib can be used to dynamically inject a dependency from a dynamic lib.

for detail, check out this blog (Chinese)

this lib combines

  • golang plugin mechanism
  • and a tricky reflection mechanism to implement dynamic dependency injection in golang.

check example code.

we use example/build.sh to build 2 plugins, one is Chinese Greeter and the other is English Greeter.

the both plugins implements Greeter interface.

we can run the main with 2 args.

  • first is the so file path, ./en/so
  • second is the package path,
    • github.com/titanxxh/di/example/en.english, if your package name is same as your folder name.
    • *github.com/titanxxh/di/example/cn/v1.(cn).Chinese, if your package name is different from your folder name.

About

this lib combines golang plugin mechanism & a tricky reflection mechanism to implement dependency injection in golang.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published