service_test.go 401 B

123456789101112131415161718192021222324
  1. package service
  2. import (
  3. "flag"
  4. "path/filepath"
  5. "time"
  6. "go-common/app/interface/main/space/conf"
  7. "go-common/library/log"
  8. )
  9. var svf *Service
  10. func WithService(f func(s *Service)) func() {
  11. return func() {
  12. dir, _ := filepath.Abs("../cmd/space-test.toml")
  13. flag.Set("conf", dir)
  14. conf.Init()
  15. log.Init(conf.Conf.Log)
  16. svf = New(conf.Conf)
  17. time.Sleep(200 * time.Millisecond)
  18. f(svf)
  19. }
  20. }