Summary
Client.Service is exported, allowing callers to bypass the abstraction.
Current State
Files:
internal/gmail/client.go:29 - Service *gmail.Service
internal/calendar/client.go:26 - Service *calendar.Service
internal/contacts/client.go:23 - Service *people.Service
type Client struct {
Service *gmail.Service // Exported!
// ...
}
Problems
- External code can bypass the Client abstraction
- Makes it impossible to track API usage
- Prevents adding cross-cutting concerns (logging, metrics)
- Defeats the purpose of the abstraction
Proposed Solution
Make service lowercase and expose functionality through methods only:
type Client struct {
service *gmail.Service // Private!
// ...
}
func (c *Client) GetMessage(id string) (*Message, error) {
// Use c.service internally
}
Priority
P2 - Design improvement (depends on interface work in #35)