mirror of
https://github.com/sstent/go-garth.git
synced 2026-01-25 16:42:28 +00:00
feat(refactor): Implement 1A.1 Package Structure Refactoring
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.
This commit is contained in:
46
pkg/garmin/doc.go
Normal file
46
pkg/garmin/doc.go
Normal file
@@ -0,0 +1,46 @@
|
||||
// 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
|
||||
Reference in New Issue
Block a user