dep.go 564 B

123456789101112131415161718192021222324252627282930313233343536
  1. package dep
  2. import (
  3. "kpt-temporary-mqtt/config"
  4. "kpt-temporary-mqtt/store/kptstore"
  5. "gitee.com/xuyiping_admin/pkg/di"
  6. )
  7. func DI(opts ...di.HubOption) *di.Hub {
  8. var hubOpts []di.HubOption
  9. if len(opts) != 0 {
  10. hubOpts = append(opts, Global())
  11. } else {
  12. hubOpts = append(hubOpts, Global())
  13. }
  14. hub, err := di.New(hubOpts...)
  15. if err != nil {
  16. panic(err)
  17. }
  18. return hub
  19. }
  20. func Global() di.HubOption {
  21. return di.Options(Options()...)
  22. }
  23. func Options() []di.HubOption {
  24. return []di.HubOption{
  25. // 基础依赖
  26. config.Module,
  27. kptstore.Module,
  28. }
  29. }