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> |
||
|---|---|---|
| .. | ||
| api/v1 | ||
| fileserver | ||
| frontend | ||
| rss | ||