Add missing fields of OnlineRecongizerResult to Go API. - #3395
Conversation
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request enhances the Go API for Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. Footnotes
|
|
Caution Review failedPull request was closed or merged during review 📝 WalkthroughWalkthroughExtended the Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Code Review
This pull request adds the Tokens, Timestamps, and Json fields to the OnlineRecognizerResult struct in the Go API, aligning it with the underlying C++ implementation. The changes correctly populate these new fields from the C result. My review includes two suggestions for improvement: one to make the Json field ignored during JSON marshalling to avoid redundancy, and another to use the idiomatic copy function for better performance and readability when handling timestamps.
| Text string | ||
| Tokens []string | ||
| Timestamps []float32 | ||
| Json string |
There was a problem hiding this comment.
The Json field appears to hold a pre-formatted JSON string from the C library which represents the other fields in the struct. When this OnlineRecognizerResult Go struct is marshalled to JSON, this can lead to a confusing and redundant output, with a JSON string embedded within another JSON object. To avoid this, consider adding a json struct tag to exclude this field from marshalling.
| Json string | |
| Json string `json:"-"` |
| for i := 0; i < n; i++ { | ||
| result.Timestamps[i] = float32(timestamps[i]) | ||
| } |
There was a problem hiding this comment.
Fixes #3393
cc @zuiaibaicaiya
Summary by CodeRabbit