summaryrefslogtreecommitdiff
path: root/internal/api/plantoeat.go
diff options
context:
space:
mode:
authorPeter Stone <thepeterstone@gmail.com>2026-01-25 20:55:58 -1000
committerPeter Stone <thepeterstone@gmail.com>2026-01-25 20:55:58 -1000
commitf5b997bfc4c77ef262726d14b30d387eb7acd1c6 (patch)
tree740879da10f3ddcd62bf276cd0632134b53a23c8 /internal/api/plantoeat.go
parentfa95c71494458070b78270e3d9170076028fc974 (diff)
Fix all static analysis errors (golangci-lint)
- Fix errcheck: handle all error return values in production code - Fix errcheck: handle all error return values in test files - Fix staticcheck: replace deprecated WithCredentialsFile with WithAuthCredentialsFile - Remove unused code: authHeaders, planToEatPlannerItem, planToEatResponse - Use defer func() { _ = x.Close() }() pattern for ignored close errors Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Diffstat (limited to 'internal/api/plantoeat.go')
-rw-r--r--internal/api/plantoeat.go25
1 files changed, 2 insertions, 23 deletions
diff --git a/internal/api/plantoeat.go b/internal/api/plantoeat.go
index a7fdf58..5c24cc1 100644
--- a/internal/api/plantoeat.go
+++ b/internal/api/plantoeat.go
@@ -39,27 +39,6 @@ func (c *PlanToEatClient) SetSessionCookie(cookie string) {
c.sessionCookie = cookie
}
-func (c *PlanToEatClient) authHeaders() map[string]string {
- return map[string]string{"Authorization": "Bearer " + c.apiKey}
-}
-
-// planToEatPlannerItem represents a planner item from the API
-type planToEatPlannerItem struct {
- ID int `json:"id"`
- Date string `json:"date"`
- MealType string `json:"meal_type"`
- Recipe struct {
- ID int `json:"id"`
- Title string `json:"title"`
- URL string `json:"url"`
- } `json:"recipe"`
-}
-
-// planToEatResponse wraps the API response
-type planToEatResponse struct {
- Items []planToEatPlannerItem `json:"items"`
-}
-
// GetUpcomingMeals fetches meals by scraping the planner web interface
// Requires a valid session cookie set via SetSessionCookie
func (c *PlanToEatClient) GetUpcomingMeals(ctx context.Context, days int) ([]models.Meal, error) {
@@ -84,7 +63,7 @@ func (c *PlanToEatClient) GetUpcomingMeals(ctx context.Context, days int) ([]mod
if err != nil {
return nil, fmt.Errorf("request failed: %w", err)
}
- defer resp.Body.Close()
+ defer func() { _ = resp.Body.Close() }()
log.Printf("DEBUG [PlanToEat/Meals]: Response status %d", resp.StatusCode)
@@ -238,7 +217,7 @@ func (c *PlanToEatClient) GetShoppingList(ctx context.Context) ([]models.Shoppin
if err != nil {
return nil, fmt.Errorf("request failed: %w", err)
}
- defer resp.Body.Close()
+ defer func() { _ = resp.Body.Close() }()
log.Printf("DEBUG [PlanToEat/Shopping]: Response status %d", resp.StatusCode)