| 201 | } |
| 202 | |
| 203 | func fillOperationDetail(operationDic *operationJson, formatMap map[string]interface{}) { |
| 204 | for key, value := range formatMap { |
| 205 | if !strings.Contains(operationDic.FormatEN, "["+key+"]") { |
| 206 | continue |
| 207 | } |
| 208 | t := reflect.TypeOf(value) |
| 209 | if t == nil || (t.Kind() != reflect.Array && t.Kind() != reflect.Slice) { |
| 210 | operationDic.FormatZH = strings.ReplaceAll(operationDic.FormatZH, "["+key+"]", fmt.Sprintf("[%v]", value)) |
| 211 | operationDic.FormatEN = strings.ReplaceAll(operationDic.FormatEN, "["+key+"]", fmt.Sprintf("[%v]", value)) |
| 212 | continue |
| 213 | } |
| 214 | |
| 215 | val := reflect.ValueOf(value) |
| 216 | length := val.Len() |
| 217 | elements := make([]string, 0, length) |
| 218 | for i := 0; i < length; i++ { |
| 219 | elements = append(elements, fmt.Sprintf("%v", val.Index(i).Interface())) |
| 220 | } |
| 221 | replaced := fmt.Sprintf("[%v]", strings.Join(elements, ",")) |
| 222 | operationDic.FormatZH = strings.ReplaceAll(operationDic.FormatZH, "["+key+"]", replaced) |
| 223 | operationDic.FormatEN = strings.ReplaceAll(operationDic.FormatEN, "["+key+"]", replaced) |
| 224 | } |
| 225 | } |
| 226 | |
| 227 | type operationJson struct { |
| 228 | API string `json:"api"` |