Skip to content

Commit fa1be94

Browse files
committed
fix: make suggested changes
1 parent bbde399 commit fa1be94

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

mcp/types.go

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -212,16 +212,18 @@ func (r RequestId) Value() any {
212212
func (r RequestId) String() string {
213213
switch v := r.value.(type) {
214214
case string:
215-
return v
215+
return "string:" + v
216216
case int64:
217-
return strconv.FormatInt(v, 10)
217+
return "int64:" + strconv.FormatInt(v, 10)
218218
case float64:
219219
if v == float64(int64(v)) {
220-
return strconv.FormatInt(int64(v), 10)
220+
return "int64:" + strconv.FormatInt(int64(v), 10)
221221
}
222-
return strconv.FormatFloat(v, 'f', -1, 64)
222+
return "float64:" + strconv.FormatFloat(v, 'f', -1, 64)
223+
case nil:
224+
return "<nil>"
223225
default:
224-
return fmt.Sprintf("%v", v)
226+
return "unknown:" + fmt.Sprintf("%v", v)
225227
}
226228
}
227229

@@ -235,6 +237,12 @@ func (r RequestId) MarshalJSON() ([]byte, error) {
235237
}
236238

237239
func (r *RequestId) UnmarshalJSON(data []byte) error {
240+
241+
if string(data) == "null" {
242+
r.value = nil
243+
return nil
244+
}
245+
238246
// Try unmarshaling as string first
239247
var s string
240248
if err := json.Unmarshal(data, &s); err == nil {

0 commit comments

Comments
 (0)