How ilyabrin/disk works
Main Components
• User Application
– Your Go program that imports “github.com/ilyabrin/disk” and calls its methods (e.g., DiskInfo).
• Disk Library (“ilyabrin/disk” package)
– Client Constructor (client.go)
– HTTP Transport & Authentication (embedded in client.go/helpers.go)
– API Operations (operations.go)
– Resource Type Definitions (types.go, resources.go)
– Utility Helpers & Error Handling (helpers.go, trash.go, public.go, etc.)
– Test Suites ( *_test.go )
• External Service
– Yandex.Disk REST API endpoints (https://cloud-api.yandex.net)
Relationships & Data Flows
• The User Application calls the Disk client’s public methods (e.g., client.New(), client.DiskInfo(ctx)).
• Client constructs an HTTP request, injecting the YANDEX_DISK_ACCESS_TOKEN in headers.
• HTTP Transport sends requests to Yandex.Disk REST API.
• Yandex API returns JSON, which the library’s types + helpers unmarshal into Go structs.
• Library returns typed results or errors back to the User Application.
Architectural Patterns & Design Principles
• Modular Package Layout
– Separation of concerns: construction (client.go), operations (operations.go), types (types.go), helpers (helpers.go).
• Dependency Injection for HTTP client (allows custom HTTP.Client or mock transport in tests).
• Clear public vs. private API: exported functions/types vs. internal helpers.
• Table-driven tests covering each module.
Relevant Technologies & Frameworks
• Language: Go
• HTTP: net/http
• JSON: encoding/json
• Testing: testing package + possibly testify
• CI/CD: GitHub Actions, CodeQL, Dependabot
Putting It All Together
– Within the Library column, subdivide into:
• Client & Auth
• Operations
• Types & Resources
• Helpers & Error Handling
• Tests (optional, maybe as a separate cluster)
1. New() → HTTP client setup
2. DiskInfo(ctx) → operations.go → buildRequest()
3. HTTP transport → Yandex.Disk API
4. JSON response → unmarshal → Go struct
5. Return to caller or error