(fields []string)
| 358 | } |
| 359 | |
| 360 | func (repo Repository) ExportData(fields []string) map[string]interface{} { |
| 361 | v := reflect.ValueOf(repo) |
| 362 | data := map[string]interface{}{} |
| 363 | for _, f := range fields { |
| 364 | switch f { |
| 365 | case "license": |
| 366 | data[f] = map[string]interface{}{ |
| 367 | "key": repo.License.Key, |
| 368 | "name": repo.License.Name, |
| 369 | "url": repo.License.URL, |
| 370 | } |
| 371 | case "owner": |
| 372 | data[f] = repo.Owner.ExportData() |
| 373 | default: |
| 374 | sf := fieldByName(v, f) |
| 375 | data[f] = sf.Interface() |
| 376 | } |
| 377 | } |
| 378 | return data |
| 379 | } |
| 380 | |
| 381 | func (repo Repository) MarshalJSON() ([]byte, error) { |
| 382 | return json.Marshal(map[string]interface{}{ |
nothing calls this directly
no test coverage detected