(ic *Inception, sf *StructField)
| 40 | } |
| 41 | |
| 42 | func getOmitEmpty(ic *Inception, sf *StructField) string { |
| 43 | ptname := "j." + sf.Name |
| 44 | if sf.Pointer { |
| 45 | ptname = "*" + ptname |
| 46 | return "if true {\n" |
| 47 | } |
| 48 | switch sf.Typ.Kind() { |
| 49 | |
| 50 | case reflect.Array, reflect.Map, reflect.Slice, reflect.String: |
| 51 | return "if len(" + ptname + ") != 0 {" + "\n" |
| 52 | |
| 53 | case reflect.Int, |
| 54 | reflect.Int8, |
| 55 | reflect.Int16, |
| 56 | reflect.Int32, |
| 57 | reflect.Int64, |
| 58 | reflect.Uint, |
| 59 | reflect.Uint8, |
| 60 | reflect.Uint16, |
| 61 | reflect.Uint32, |
| 62 | reflect.Uint64, |
| 63 | reflect.Uintptr, |
| 64 | reflect.Float32, |
| 65 | reflect.Float64: |
| 66 | return "if " + ptname + " != 0 {" + "\n" |
| 67 | |
| 68 | case reflect.Bool: |
| 69 | return "if " + ptname + " != false {" + "\n" |
| 70 | |
| 71 | case reflect.Interface, reflect.Ptr: |
| 72 | return "if " + ptname + " != nil {" + "\n" |
| 73 | |
| 74 | default: |
| 75 | // TODO(pquerna): fix types |
| 76 | return "if true {" + "\n" |
| 77 | } |
| 78 | } |
| 79 | |
| 80 | func getMapValue(ic *Inception, name string, typ reflect.Type, ptr bool, forceString bool) string { |
| 81 | var out = "" |
no outgoing calls
no test coverage detected
searching dependent graphs…