Skip to content

Commit

Permalink
fix no config panic bug (#332)
Browse files Browse the repository at this point in the history
  • Loading branch information
kira1928 committed Jan 13, 2023
1 parent 18c21d4 commit 45f1f2e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 13 deletions.
26 changes: 13 additions & 13 deletions src/cmd/bililive/internal/flag/flag.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,20 @@ func init() {

// GenConfigFromFlags generates configuration by parsing command line parameters.
func GenConfigFromFlags() *configs.Config {
cfg := &configs.Config{
RPC: configs.RPC{
Enable: *RPC,
Bind: *RPCBind,
},
Debug: *Debug,
Interval: *Interval,
OutPutPath: *Output,
OutputTmpl: *OutputFileTmpl,
LiveRooms: configs.NewLiveRoomsWithStrings(*Input),
Feature: configs.Feature{
UseNativeFlvParser: *NativeFlvParser,
},
cfg := configs.NewConfig()
cfg.RPC = configs.RPC{
Enable: *RPC,
Bind: *RPCBind,
}
cfg.Debug = *Debug
cfg.Interval = *Interval
cfg.OutPutPath = *Output
cfg.OutputTmpl = *OutputFileTmpl
cfg.LiveRooms = configs.NewLiveRoomsWithStrings(*Input)
cfg.Feature = configs.Feature{
UseNativeFlvParser: *NativeFlvParser,
}

if SplitStrategies != nil && len(*SplitStrategies) > 0 {
for _, s := range *SplitStrategies {
// TODO: not hard code
Expand Down
6 changes: 6 additions & 0 deletions src/configs/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,12 @@ var defaultConfig = Config{
TimeoutInUs: 60000000,
}

func NewConfig() *Config {
config := new(Config)
config.liveRoomIndexCache = map[string]int{}
return config
}

// Verify will return an error when this config has problem.
func (c *Config) Verify() error {
if c == nil {
Expand Down

0 comments on commit 45f1f2e

Please sign in to comment.