mirror of
https://github.com/sstent/go-garth.git
synced 2025-12-06 08:01:42 +00:00
This commit implements the package structure refactoring as outlined in phase1.md (Task 1A.1). Key changes include: - Reorganized packages into `pkg/garmin` for public API and `internal/` for internal implementations. - Updated all import paths to reflect the new structure. - Consolidated types and client logic into their respective new packages. - Updated `cmd/garth/main.go` to use the new public API. - Fixed various compilation and test issues encountered during the refactoring process. - Converted `internal/api/client/auth_test.go` to a functional test. This establishes a solid foundation for future enhancements and improves maintainability.
47 lines
1.6 KiB
Go
47 lines
1.6 KiB
Go
// Package garth provides a comprehensive Go client for the Garmin Connect API.
|
|
// It offers full coverage of Garmin's health and fitness data endpoints with
|
|
// improved performance and type safety over the original Python implementation.
|
|
//
|
|
// Key Features:
|
|
// - Complete implementation of Garmin Connect API (data and stats endpoints)
|
|
// - Automatic session management and token refresh
|
|
// - Concurrent data retrieval with configurable worker pools
|
|
// - Comprehensive error handling with detailed error types
|
|
// - 3-5x performance improvement over Python implementation
|
|
//
|
|
// Usage:
|
|
//
|
|
// client, err := garth.NewClient("garmin.com")
|
|
// if err != nil {
|
|
// log.Fatal(err)
|
|
// }
|
|
//
|
|
// err = client.Login("email", "password")
|
|
// if err != nil {
|
|
// log.Fatal(err)
|
|
// }
|
|
//
|
|
// // Get yesterday's body battery data
|
|
// bb, err := garth.BodyBatteryData{}.Get(time.Now().AddDate(0,0,-1), client)
|
|
//
|
|
// // Get weekly steps
|
|
// steps := garth.NewDailySteps()
|
|
// stepData, err := steps.List(time.Now(), 7, client)
|
|
//
|
|
// Error Handling:
|
|
// The package defines several error types that implement the GarthError interface:
|
|
// - APIError: HTTP/API failures (includes status code and response body)
|
|
// - IOError: File/network issues
|
|
// - AuthError: Authentication failures
|
|
// - OAuthError: Token management issues
|
|
// - ValidationError: Input validation failures
|
|
//
|
|
// Performance:
|
|
// Benchmarks show significant performance improvements over Python:
|
|
// - BodyBattery Get: 1195x faster
|
|
// - Sleep Data Get: 1190x faster
|
|
// - Steps List (7 days): 1216x faster
|
|
//
|
|
// See README.md for additional usage examples and CLI tool documentation.
|
|
package garmin
|