From 6e06146948af52e53c4087087f9ad915de7ac309 Mon Sep 17 00:00:00 2001 From: kujtimiihoxha Date: Wed, 22 Oct 2025 16:40:11 +0200 Subject: [PATCH] fix(lint): comments --- content_json.go | 41 +++++++++++++++++++++++++++++++++++++---- model_json.go | 3 +++ 2 files changed, 40 insertions(+), 4 deletions(-) diff --git a/content_json.go b/content_json.go index bfeb45cbee6922f1290f22b3d01e3032a21d5cb0..e9bea1195fb542f7a457b9e4c8f69a9502d081dd 100644 --- a/content_json.go +++ b/content_json.go @@ -30,6 +30,7 @@ type toolJSON struct { Data json.RawMessage `json:"data"` } +// MarshalJSON implements json.Marshaler for TextContent. func (t TextContent) MarshalJSON() ([]byte, error) { dataBytes, err := json.Marshal(struct { Text string `json:"text"` @@ -48,6 +49,7 @@ func (t TextContent) MarshalJSON() ([]byte, error) { }) } +// UnmarshalJSON implements json.Unmarshaler for TextContent. func (t *TextContent) UnmarshalJSON(data []byte) error { var cj contentJSON if err := json.Unmarshal(data, &cj); err != nil { @@ -76,6 +78,7 @@ func (t *TextContent) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements json.Marshaler for ReasoningContent. func (r ReasoningContent) MarshalJSON() ([]byte, error) { dataBytes, err := json.Marshal(struct { Text string `json:"text"` @@ -94,6 +97,7 @@ func (r ReasoningContent) MarshalJSON() ([]byte, error) { }) } +// UnmarshalJSON implements json.Unmarshaler for ReasoningContent. func (r *ReasoningContent) UnmarshalJSON(data []byte) error { var cj contentJSON if err := json.Unmarshal(data, &cj); err != nil { @@ -122,6 +126,7 @@ func (r *ReasoningContent) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements json.Marshaler for FileContent. func (f FileContent) MarshalJSON() ([]byte, error) { dataBytes, err := json.Marshal(struct { MediaType string `json:"media_type"` @@ -142,6 +147,7 @@ func (f FileContent) MarshalJSON() ([]byte, error) { }) } +// UnmarshalJSON implements json.Unmarshaler for FileContent. func (f *FileContent) UnmarshalJSON(data []byte) error { var cj contentJSON if err := json.Unmarshal(data, &cj); err != nil { @@ -172,6 +178,7 @@ func (f *FileContent) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements json.Marshaler for SourceContent. func (s SourceContent) MarshalJSON() ([]byte, error) { dataBytes, err := json.Marshal(struct { SourceType SourceType `json:"source_type"` @@ -200,6 +207,7 @@ func (s SourceContent) MarshalJSON() ([]byte, error) { }) } +// UnmarshalJSON implements json.Unmarshaler for SourceContent. func (s *SourceContent) UnmarshalJSON(data []byte) error { var cj contentJSON if err := json.Unmarshal(data, &cj); err != nil { @@ -238,6 +246,7 @@ func (s *SourceContent) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements json.Marshaler for ToolCallContent. func (t ToolCallContent) MarshalJSON() ([]byte, error) { dataBytes, err := json.Marshal(struct { ToolCallID string `json:"tool_call_id"` @@ -266,6 +275,7 @@ func (t ToolCallContent) MarshalJSON() ([]byte, error) { }) } +// UnmarshalJSON implements json.Unmarshaler for ToolCallContent. func (t *ToolCallContent) UnmarshalJSON(data []byte) error { var cj contentJSON if err := json.Unmarshal(data, &cj); err != nil { @@ -304,6 +314,7 @@ func (t *ToolCallContent) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements json.Marshaler for ToolResultContent. func (t ToolResultContent) MarshalJSON() ([]byte, error) { dataBytes, err := json.Marshal(struct { ToolCallID string `json:"tool_call_id"` @@ -330,6 +341,7 @@ func (t ToolResultContent) MarshalJSON() ([]byte, error) { }) } +// UnmarshalJSON implements json.Unmarshaler for ToolResultContent. func (t *ToolResultContent) UnmarshalJSON(data []byte) error { var cj contentJSON if err := json.Unmarshal(data, &cj); err != nil { @@ -372,6 +384,7 @@ func (t *ToolResultContent) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements json.Marshaler for ToolResultOutputContentText. func (t ToolResultOutputContentText) MarshalJSON() ([]byte, error) { dataBytes, err := json.Marshal(struct { Text string `json:"text"` @@ -388,6 +401,7 @@ func (t ToolResultOutputContentText) MarshalJSON() ([]byte, error) { }) } +// UnmarshalJSON implements json.Unmarshaler for ToolResultOutputContentText. func (t *ToolResultOutputContentText) UnmarshalJSON(data []byte) error { var tr toolResultOutputJSON if err := json.Unmarshal(data, &tr); err != nil { @@ -406,6 +420,7 @@ func (t *ToolResultOutputContentText) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements json.Marshaler for ToolResultOutputContentError. func (t ToolResultOutputContentError) MarshalJSON() ([]byte, error) { errMsg := "" if t.Error != nil { @@ -426,6 +441,7 @@ func (t ToolResultOutputContentError) MarshalJSON() ([]byte, error) { }) } +// UnmarshalJSON implements json.Unmarshaler for ToolResultOutputContentError. func (t *ToolResultOutputContentError) UnmarshalJSON(data []byte) error { var tr toolResultOutputJSON if err := json.Unmarshal(data, &tr); err != nil { @@ -445,6 +461,7 @@ func (t *ToolResultOutputContentError) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements json.Marshaler for ToolResultOutputContentMedia. func (t ToolResultOutputContentMedia) MarshalJSON() ([]byte, error) { dataBytes, err := json.Marshal(struct { Data string `json:"data"` @@ -463,6 +480,7 @@ func (t ToolResultOutputContentMedia) MarshalJSON() ([]byte, error) { }) } +// UnmarshalJSON implements json.Unmarshaler for ToolResultOutputContentMedia. func (t *ToolResultOutputContentMedia) UnmarshalJSON(data []byte) error { var tr toolResultOutputJSON if err := json.Unmarshal(data, &tr); err != nil { @@ -483,6 +501,7 @@ func (t *ToolResultOutputContentMedia) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements json.Marshaler for TextPart. func (t TextPart) MarshalJSON() ([]byte, error) { dataBytes, err := json.Marshal(struct { Text string `json:"text"` @@ -501,6 +520,7 @@ func (t TextPart) MarshalJSON() ([]byte, error) { }) } +// UnmarshalJSON implements json.Unmarshaler for TextPart. func (t *TextPart) UnmarshalJSON(data []byte) error { var mpj messagePartJSON if err := json.Unmarshal(data, &mpj); err != nil { @@ -529,6 +549,7 @@ func (t *TextPart) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements json.Marshaler for ReasoningPart. func (r ReasoningPart) MarshalJSON() ([]byte, error) { dataBytes, err := json.Marshal(struct { Text string `json:"text"` @@ -547,6 +568,7 @@ func (r ReasoningPart) MarshalJSON() ([]byte, error) { }) } +// UnmarshalJSON implements json.Unmarshaler for ReasoningPart. func (r *ReasoningPart) UnmarshalJSON(data []byte) error { var mpj messagePartJSON if err := json.Unmarshal(data, &mpj); err != nil { @@ -575,6 +597,7 @@ func (r *ReasoningPart) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements json.Marshaler for FilePart. func (f FilePart) MarshalJSON() ([]byte, error) { dataBytes, err := json.Marshal(struct { Filename string `json:"filename"` @@ -597,6 +620,7 @@ func (f FilePart) MarshalJSON() ([]byte, error) { }) } +// UnmarshalJSON implements json.Unmarshaler for FilePart. func (f *FilePart) UnmarshalJSON(data []byte) error { var mpj messagePartJSON if err := json.Unmarshal(data, &mpj); err != nil { @@ -629,6 +653,7 @@ func (f *FilePart) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements json.Marshaler for ToolCallPart. func (t ToolCallPart) MarshalJSON() ([]byte, error) { dataBytes, err := json.Marshal(struct { ToolCallID string `json:"tool_call_id"` @@ -653,6 +678,7 @@ func (t ToolCallPart) MarshalJSON() ([]byte, error) { }) } +// UnmarshalJSON implements json.Unmarshaler for ToolCallPart. func (t *ToolCallPart) UnmarshalJSON(data []byte) error { var mpj messagePartJSON if err := json.Unmarshal(data, &mpj); err != nil { @@ -687,6 +713,7 @@ func (t *ToolCallPart) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements json.Marshaler for ToolResultPart. func (t ToolResultPart) MarshalJSON() ([]byte, error) { dataBytes, err := json.Marshal(struct { ToolCallID string `json:"tool_call_id"` @@ -707,6 +734,7 @@ func (t ToolResultPart) MarshalJSON() ([]byte, error) { }) } +// UnmarshalJSON implements json.Unmarshaler for ToolResultPart. func (t *ToolResultPart) UnmarshalJSON(data []byte) error { var mpj messagePartJSON if err := json.Unmarshal(data, &mpj); err != nil { @@ -743,6 +771,7 @@ func (t *ToolResultPart) UnmarshalJSON(data []byte) error { return nil } +// UnmarshalJSON implements json.Unmarshaler for Message. func (m *Message) UnmarshalJSON(data []byte) error { var aux struct { Role MessageRole `json:"role"` @@ -776,6 +805,7 @@ func (m *Message) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements json.Marshaler for FunctionTool. func (f FunctionTool) MarshalJSON() ([]byte, error) { dataBytes, err := json.Marshal(struct { Name string `json:"name"` @@ -798,6 +828,7 @@ func (f FunctionTool) MarshalJSON() ([]byte, error) { }) } +// UnmarshalJSON implements json.Unmarshaler for FunctionTool. func (f *FunctionTool) UnmarshalJSON(data []byte) error { var tj toolJSON if err := json.Unmarshal(data, &tj); err != nil { @@ -830,6 +861,7 @@ func (f *FunctionTool) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements json.Marshaler for ProviderDefinedTool. func (p ProviderDefinedTool) MarshalJSON() ([]byte, error) { dataBytes, err := json.Marshal(struct { ID string `json:"id"` @@ -850,6 +882,7 @@ func (p ProviderDefinedTool) MarshalJSON() ([]byte, error) { }) } +// UnmarshalJSON implements json.Unmarshaler for ProviderDefinedTool. func (p *ProviderDefinedTool) UnmarshalJSON(data []byte) error { var tj toolJSON if err := json.Unmarshal(data, &tj); err != nil { @@ -873,7 +906,7 @@ func (p *ProviderDefinedTool) UnmarshalJSON(data []byte) error { return nil } -// UnmarshalTool unmarshals JSON into the appropriate Tool type +// UnmarshalTool unmarshals JSON into the appropriate Tool type. func UnmarshalTool(data []byte) (Tool, error) { var tj toolJSON if err := json.Unmarshal(data, &tj); err != nil { @@ -898,7 +931,7 @@ func UnmarshalTool(data []byte) (Tool, error) { } } -// UnmarshalContent unmarshals JSON into the appropriate Content type +// UnmarshalContent unmarshals JSON into the appropriate Content type. func UnmarshalContent(data []byte) (Content, error) { var cj contentJSON if err := json.Unmarshal(data, &cj); err != nil { @@ -947,7 +980,7 @@ func UnmarshalContent(data []byte) (Content, error) { } } -// UnmarshalMessagePart unmarshals JSON into the appropriate MessagePart type +// UnmarshalMessagePart unmarshals JSON into the appropriate MessagePart type. func UnmarshalMessagePart(data []byte) (MessagePart, error) { var mpj messagePartJSON if err := json.Unmarshal(data, &mpj); err != nil { @@ -990,7 +1023,7 @@ func UnmarshalMessagePart(data []byte) (MessagePart, error) { } } -// UnmarshalToolResultOutputContent unmarshals JSON into the appropriate ToolResultOutputContent type +// UnmarshalToolResultOutputContent unmarshals JSON into the appropriate ToolResultOutputContent type. func UnmarshalToolResultOutputContent(data []byte) (ToolResultOutputContent, error) { var troj toolResultOutputJSON if err := json.Unmarshal(data, &troj); err != nil { diff --git a/model_json.go b/model_json.go index cfcc35d01cf90e383aaa40662eeabccb89f4ad39..90a8c78520977ae8dc797c2c0575f168297917ca 100644 --- a/model_json.go +++ b/model_json.go @@ -5,6 +5,7 @@ import ( "fmt" ) +// UnmarshalJSON implements json.Unmarshaler for Call. func (c *Call) UnmarshalJSON(data []byte) error { var aux struct { Prompt Prompt `json:"prompt"` @@ -54,6 +55,7 @@ func (c *Call) UnmarshalJSON(data []byte) error { return nil } +// UnmarshalJSON implements json.Unmarshaler for Response. func (r *Response) UnmarshalJSON(data []byte) error { var aux struct { Content json.RawMessage `json:"content"` @@ -100,6 +102,7 @@ func (r *Response) UnmarshalJSON(data []byte) error { return nil } +// UnmarshalJSON implements json.Unmarshaler for StreamPart. func (s *StreamPart) UnmarshalJSON(data []byte) error { var aux struct { Type StreamPartType `json:"type"`