Add comprehensive godoc documentation to all exported symbols

- Document all exported types, functions, methods, and constants across 52 files
- Add package-level doc comments to client, models, utils, and ynison packages
- Document HTTP method and endpoint path for each API client method
- Document model struct fields and DeJSON/DeList/ToJSON/ToMap methods
- Fix duplicate package doc comment in internal/models/base.go

Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
MrixsandClaude Code committed 2026-10-18 08:57:43 +03:00
1 parent 7a68ad86cb
commit 0456ca0665
54 files changed
+1097 -652

No files matched your search

+23 -12
View File
@@ -1,3 +1,4 @@
// Package utils provides utility functions for the Yandex Music API client.
package utils
import (
@@ -6,42 +7,49 @@ import (
"strings"
)
// JSONBackend defines the interface for JSON encoding/decoding
// JSONBackend defines the interface for JSON encoding/decoding.
// Implementations can use encoding/json, json-iterator, or other backends.
type JSONBackend interface {
// Marshal encodes a Go value to JSON.
Marshal(v any) ([]byte, error)
// Unmarshal decodes JSON data into a Go value.
Unmarshal(data []byte, v any) error
}
// DefaultJSONBackend uses the standard library encoding/json
// DefaultJSONBackend uses the standard library encoding/json.
type DefaultJSONBackend struct{}
// Marshal encodes a Go value to JSON using encoding/json.
func (DefaultJSONBackend) Marshal(v any) ([]byte, error) {
return json.Marshal(v)
}
// Unmarshal decodes JSON data into a Go value using encoding/json.
func (DefaultJSONBackend) Unmarshal(data []byte, v any) error {
return json.Unmarshal(data, v)
}
// GetDefaultJSONBackend returns the default JSON backend
// GetDefaultJSONBackend returns the default JSON backend (encoding/json).
func GetDefaultJSONBackend() JSONBackend {
return DefaultJSONBackend{}
}
// RawMessage is a raw encoded JSON value
// RawMessage is a raw encoded JSON value.
// It is an alias for encoding/json.RawMessage.
type RawMessage = json.RawMessage
// Marshal is a convenience function
// Marshal is a convenience function that marshals a value using the default JSON backend.
func Marshal(v any) ([]byte, error) {
return GetDefaultJSONBackend().Marshal(v)
}
// Unmarshal is a convenience function
// Unmarshal is a convenience function that unmarshals data using the default JSON backend.
func Unmarshal(data []byte, v any) error {
return GetDefaultJSONBackend().Unmarshal(data, v)
}
// ToSnakeCase converts camelCase to snake_case
// ToSnakeCase converts camelCase to snake_case.
// For example, "camelCase" becomes "camel_case".
func ToSnakeCase(s string) string {
if s == "" {
return s
@@ -60,7 +68,8 @@ func ToSnakeCase(s string) string {
return result.String()
}
// ToCamelCase converts snake_case to camelCase
// ToCamelCase converts snake_case to camelCase.
// For example, "snake_case" becomes "snakeCase".
func ToCamelCase(s string) string {
if s == "" {
return s
@@ -79,7 +88,7 @@ func ToCamelCase(s string) string {
return result.String()
}
// MapKeysToSnakeCase converts all keys in a map to snake_case
// MapKeysToSnakeCase converts all keys in a map to snake_case.
func MapKeysToSnakeCase(m map[string]any) map[string]any {
result := make(map[string]any, len(m))
for k, v := range m {
@@ -88,7 +97,7 @@ func MapKeysToSnakeCase(m map[string]any) map[string]any {
return result
}
// MapKeysToCamelCase converts all keys in a map to camelCase
// MapKeysToCamelCase converts all keys in a map to camelCase.
func MapKeysToCamelCase(m map[string]any) map[string]any {
result := make(map[string]any, len(m))
for k, v := range m {
@@ -97,7 +106,8 @@ func MapKeysToCamelCase(m map[string]any) map[string]any {
return result
}
// StructToMap converts a struct to a map using json tags
// StructToMap converts a struct to a map using json tags.
// The forRequest parameter is currently unused but reserved for future use.
func StructToMap(v any, forRequest bool) (map[string]any, error) {
data, err := Marshal(v)
if err != nil {
@@ -110,7 +120,8 @@ func StructToMap(v any, forRequest bool) (map[string]any, error) {
return result, nil
}
// GetJSONTag returns the json tag for a struct field
// GetJSONTag returns the json tag name for a struct field at the given index.
// It returns an empty string if the field has no json tag or the tag is "-".
func GetJSONTag(t reflect.Type, fieldIndex int) string {
if fieldIndex >= t.NumField() {
return ""