- Notifications
You must be signed in to change notification settings - Fork69
Shareable Go package experiment in sdk-platform-java#3938
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:main
Are you sure you want to change the base?
Conversation
langaugecontainer and message packages are to be migrated tothe librarian repository.
Summary of ChangesHello@suztomo, 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 initiates an experimental refactoring effort to modularize the Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on ourdocumentation 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 uphere. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with theGemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Code Review
This pull request refactors the command-line handling into a sharedlanguagecontainer package, which is a good step towards modularity. However, there are a few critical issues that need to be addressed. The new implementation incorrectly passesos.Args to theRun function, which will cause command dispatching to fail. I've also pointed out that error handling has been changed to usepanic, which is not ideal for a CLI tool and should be reverted to graceful error logging and exit codes. Additionally, the--version flag functionality has been lost in the refactoring. My review includes suggestions to fix these issues.
| slog.Info("librariangen: finished successfully") | ||
| return0 | ||
| container:=javaContainer{} | ||
| os.Exit(languagecontainer.Run(os.Args,&container)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
TheRun function inlanguagecontainer expects the command-line arguments without the program name. Currently,os.Args is passed, which includes the program name as the first element (os.Args[0]). This will cause the command dispatching inRun to fail, as it will try to match the program name against commands likegenerate. You should passos.Args[1:] instead.
| os.Exit(languagecontainer.Run(os.Args,&container)) | |
| os.Exit(languagecontainer.Run(os.Args[1:],&container)) |
| iflen(args)<1 { | ||
| panic("args must not be empty") | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
| iferr!=nil { | ||
| // TODO: Save it as a response file. | ||
| panic(err) | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Usingpanic for handling errors from business logic can lead to abrupt program termination, which is generally undesirable for a CLI tool. It's better to log the error and return a non-zero exit code to indicate failure gracefully.
iferr!=nil {// TODO: Save it as a response file.slog.Error("librariangen: generate command failed","error",err)return1}
| iferr!=nil { | ||
| panic(err) | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
| slog.Error("librariangen: unknown command: %s (with flags %v)",args[0],args) | ||
| return1 | ||
| } | ||
| return0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
| // run executes the appropriate command based on the CLI's invocation arguments. | ||
| // The idiomatic structure is `librariangen [command] [flags]`. | ||
| funcrun(ctx context.Context,args []string)error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
|
|



langaugecontainer and message packages are to be migrated to
the librarian repository.
Thank you for opening a Pull Request! Before submitting your PR, please read ourcontributing guidelines.
There are a few things you can do to make sure it goes smoothly:
Fixes #<issue_number_goes_here> ☕️