timestee/optiongen

当数组类型的option时,希望增加控制with还是append

Closed this issue · 1 comments

大家都append的时候,如果有人with了,会覆盖掉前面的append,希望在声名的时候,可以只要append或者只要with,或者都有

两种控制级别:

  1. 所有 option
//go:generate optiongen --slice_only_append=true
func OnlyAppendOptionDeclareWithDefault() interface{} {
    return map[string]interface{}{
       "Address": []string{"10.0.0.1:6379", "10.0.0.2:6379"},
    }
}
  1. 单个 option
//go:generate optiongen
func OnlyAppendOptionDeclareWithDefault() interface{} {
    return map[string]interface{}{
      // annotation@Address(slice_only_append="true")
      "Address": []string{"10.0.0.1:6379", "10.0.0.2:6379"},
    }
}