```
refactor(service): 优化Use函数参数类型 移除Use函数中initFunc参数的指针包装,直接使用func() error类型。 简化函数内部调用逻辑,提升代码可读性和健壮性。 ```
This commit is contained in:
parent
44319d03b9
commit
f681f0bb17
|
@ -108,15 +108,12 @@ func (s *Service) Gateway(grpcAddr string, httpAddr string) {
|
|||
http.ListenAndServe(httpAddr, s.Opts.GatewayMux)
|
||||
}
|
||||
|
||||
func (s *Service) Use(initFunc *func() error) {
|
||||
// Execute the Init function if it's not nil
|
||||
if initFunc != nil {
|
||||
err := (*initFunc)()
|
||||
func (s *Service) Use(initFunc func() error) {
|
||||
err := (initFunc)()
|
||||
if err != nil {
|
||||
print.Error(err.Error())
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Service) Stop() {
|
||||
|
|
Loading…
Reference in New Issue