github.com/15mga/kiwi@v0.0.2-0.20240324021231-b95d5c3ac751/core/init.go (about) 1 package core 2 3 import ( 4 "fmt" 5 "github.com/15mga/kiwi" 6 "github.com/15mga/kiwi/ds" 7 "github.com/15mga/kiwi/util" 8 "runtime" 9 "time" 10 ) 11 12 const ( 13 _Logo = ` 14 __ __ _______ ________ _______ 15 | |/ |_ _| | | |_ _| 16 | < _| |_| | | |_| |_ 17 |__|\__|_______|________|_______| 18 ` 19 ) 20 21 func init() { 22 fmt.Println(_Logo) 23 fmt.Println("ver:", runtime.Version()) 24 fmt.Println("auth:", "95eh") 25 fmt.Println("email:", "eh95@qq.com") 26 fmt.Println("site:", "https://15m.games/category/Kiwi") 27 fmt.Println("path:", util.WorkDir()+"/"+util.ExeName()) 28 fmt.Println("time:", time.Now().Format(time.DateTime)) 29 } 30 31 var ( 32 _Services = ds.NewKSet[kiwi.TSvc, kiwi.IService](8, func(service kiwi.IService) kiwi.TSvc { 33 return service.Svc() 34 }) 35 ) 36 37 func RegisterSvc(services ...kiwi.IService) { 38 for _, service := range services { 39 _ = _Services.Add(service) 40 } 41 } 42 43 func StartAllService() { 44 _Services.Iter(func(service kiwi.IService) { 45 service.Start() 46 }) 47 } 48 49 func ShutdownAllService() { 50 _Services.Iter(func(service kiwi.IService) { 51 service.Shutdown() 52 }) 53 } 54 55 func GetService(svc kiwi.TSvc) (kiwi.IService, bool) { 56 return _Services.Get(svc) 57 }