mirror of
https://github.com/xaionaro-go/streamctl.git
synced 2025-10-19 05:44:39 +08:00
Fix panics on empty config
This commit is contained in:
@@ -287,6 +287,9 @@ func ConvertPlatformConfig[T any, S StreamProfile](
|
||||
ctx context.Context,
|
||||
platCfg *AbstractPlatformConfig,
|
||||
) *PlatformConfig[T, S] {
|
||||
if platCfg == nil {
|
||||
platCfg = &AbstractPlatformConfig{}
|
||||
}
|
||||
return &PlatformConfig[T, S]{
|
||||
Enable: platCfg.Enable,
|
||||
Config: GetPlatformSpecificConfig[T](ctx, platCfg.Config),
|
||||
@@ -299,6 +302,10 @@ func GetPlatformSpecificConfig[T any](
|
||||
ctx context.Context,
|
||||
platCfgCfg any,
|
||||
) T {
|
||||
if platCfgCfg == nil {
|
||||
var zeroValue T
|
||||
return zeroValue
|
||||
}
|
||||
switch platCfgCfg := platCfgCfg.(type) {
|
||||
case T:
|
||||
return platCfgCfg
|
||||
|
Reference in New Issue
Block a user