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