mirror of https://github.com/usememos/memos.git
Problem: The withHeaderCarrier generic function had a type mismatch that caused compilation errors in CI. The function used `T proto.Message` constraint, but Connect's Response type expects the non-pointer message type while protobuf methods return pointers. Error from CI: type T of resp does not match *T (cannot infer T) This occurred because: - Connect methods expect: *connect.Response[v1pb.CreateSessionResponse] - Service methods return: (*v1pb.CreateSessionResponse, error) - Old signature: fn func(context.Context) (T, error) with T proto.Message - This caused T to be inferred as *v1pb.CreateSessionResponse - Leading to return type: *connect.Response[*v1pb.CreateSessionResponse] (wrong!) Solution: Changed generic signature to explicitly handle the pointer/non-pointer distinction: - New signature: fn func(context.Context) (*T, error) with T any - T is now the non-pointer type (e.g., v1pb.CreateSessionResponse) - fn returns *T (e.g., *v1pb.CreateSessionResponse) - Return type is correctly: *connect.Response[T] (e.g., *connect.Response[v1pb.CreateSessionResponse]) Also removed unused "google.golang.org/protobuf/proto" import and improved documentation to clarify the T vs *T distinction. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> |
||
|---|---|---|
| .. | ||
| test | ||
| acl.go | ||
| acl_config.go | ||
| activity_service.go | ||
| attachment_service.go | ||
| auth_service.go | ||
| auth_service_client_info_test.go | ||
| common.go | ||
| connect_handler.go | ||
| connect_interceptors.go | ||
| connect_services.go | ||
| header_carrier.go | ||
| health_service.go | ||
| idp_service.go | ||
| instance_service.go | ||
| logger_interceptor.go | ||
| memo_attachment_service.go | ||
| memo_relation_service.go | ||
| memo_service.go | ||
| memo_service_converter.go | ||
| memo_service_filter.go | ||
| reaction_service.go | ||
| resource_name.go | ||
| shortcut_service.go | ||
| user_service.go | ||
| user_service_stats.go | ||
| v1.go | ||