(value any)
| 121 | } |
| 122 | |
| 123 | func encodeMCPIDValue(value any) (any, bool) { |
| 124 | if value == nil { |
| 125 | return nil, false |
| 126 | } |
| 127 | |
| 128 | switch v := value.(type) { |
| 129 | case int: |
| 130 | if v > 0 { |
| 131 | return encodeMCPInt64(int64(v)) |
| 132 | } |
| 133 | case int32: |
| 134 | if v > 0 { |
| 135 | return encodeMCPInt64(int64(v)) |
| 136 | } |
| 137 | case int64: |
| 138 | if v > 0 { |
| 139 | return encodeMCPInt64(v) |
| 140 | } |
| 141 | case uint: |
| 142 | if v > 0 { |
| 143 | return encodeMCPInt64(int64(v)) |
| 144 | } |
| 145 | case uint32: |
| 146 | if v > 0 { |
| 147 | return encodeMCPInt64(int64(v)) |
| 148 | } |
| 149 | case uint64: |
| 150 | if v > 0 && v <= uint64(^uint64(0)>>1) { |
| 151 | return encodeMCPInt64(int64(v)) |
| 152 | } |
| 153 | case float32: |
| 154 | if v > 0 && float32(int64(v)) == v { |
| 155 | return encodeMCPInt64(int64(v)) |
| 156 | } |
| 157 | case float64: |
| 158 | if v > 0 && float64(int64(v)) == v { |
| 159 | return encodeMCPInt64(int64(v)) |
| 160 | } |
| 161 | case string: |
| 162 | if id, err := strconv.ParseInt(v, 10, 64); err == nil && id > 0 { |
| 163 | return encodeMCPInt64(id) |
| 164 | } |
| 165 | } |
| 166 | |
| 167 | rv := reflect.ValueOf(value) |
| 168 | if rv.IsValid() && rv.Kind() == reflect.Ptr && !rv.IsNil() { |
| 169 | return encodeMCPIDValue(rv.Elem().Interface()) |
| 170 | } |
| 171 | |
| 172 | return nil, false |
| 173 | } |
| 174 | |
| 175 | func encodeMCPIDSlice(value any) ([]any, bool) { |
| 176 | rv := reflect.ValueOf(value) |
no test coverage detected