Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Draft
suztomo wants to merge1 commit intomain
base:main
Choose a base branch
Loading
fromshared_go_packages

Conversation

@suztomo
Copy link
Member

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:

  • Make sure to open an issue as abug/issue before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea
  • Ensure the tests and linter pass
  • Code coverage does not decrease (if any source code was changed)
  • Appropriate docs were updated (if necessary)

Fixes #<issue_number_goes_here> ☕️

langaugecontainer and message packages are to be migrated tothe librarian repository.
@product-auto-labelproduct-auto-labelbot added the size: mPull request size is medium. labelOct 14, 2025
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello@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 thesdk-platform-java project. It introduces two new Go packages,languagecontainer andmessage, designed to be language-agnostic and eventually shared across different language platforms via alibrarian repository. Thelanguagecontainer package defines a core interface for language-specific operations and a generic command execution mechanism, while themessage package provides standardized data structures for inter-module communication. Themain CLI entry point has been updated to integrate with this new architecture, showcasing how Java-specific logic will plug into the generic container framework.

Highlights

  • Introducedlanguagecontainer package: A new package defining a genericLanguageContainer interface withGenerate andConfigure methods, along with aRun function to dispatch commands based on command-line arguments.
  • Createdmessage package: A new package for defining common request and response data structures (GenerateRequest,ConfigureRequest, etc.) used for communication between the CLI and language containers.
  • Refactoredmain.go: The main CLI entry point was updated to utilize the newlanguagecontainer.Run function, demonstrating how a language-specific implementation (javaContainer) will interact with the generic command dispatcher, replacing the previous command parsing logic.
  • Prepared for module migration: The newly introducedlanguagecontainer andmessage packages are explicitly marked for future migration to a sharedlibrarian repository, indicating a strategic move towards a more modular and reusable architecture.
Using Gemini Code Assist

The 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/gemini <command> or@gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

FeatureCommandDescription
Code Review/gemini reviewPerforms a code review for the current pull request in its current state.
Pull Request Summary/gemini summaryProvides a summary of the current pull request in its current state.
Comment@gemini-code-assistResponds in comments when explicitly tagged, both in pull request comments and review comments.
Help/gemini helpDisplays a list of available commands.

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.gemini/ folder in the base of the repository. Detailed instructions can be foundhere.

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

  1. Review thePrivacy Notices,Generative AI Prohibited Use Policy,Terms of Service, and learn how to configure Gemini Code Assist in GitHubhere. Gemini can make mistakes, so double check it anduse code with caution.

Copy link
Contributor

@gemini-code-assistgemini-code-assistbot left a 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))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

critical

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.

Suggested change
os.Exit(languagecontainer.Run(os.Args,&container))
os.Exit(languagecontainer.Run(os.Args[1:],&container))

Comment on lines +62 to +64
iflen(args)<1 {
panic("args must not be empty")
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

high

Panicking on invalid user input (like missing arguments) is ungraceful for a command-line tool. It's better to print an error message and exit with a non-zero status code. This provides a better user experience.

iflen(args)<1 {slog.Error("librariangen: expected a command")return1}

Comment on lines +69 to +72
iferr!=nil {
// TODO: Save it as a response file.
panic(err)
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

high

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}

Comment on lines +77 to +79
iferr!=nil {
panic(err)
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

high

Usingpanic for handling errors can lead to abrupt program termination. It's better to log the error and return a non-zero exit code to indicate failure gracefully, which is more conventional for CLI applications.

iferr!=nil {slog.Error("librariangen: configure command failed","error",err)return1}

slog.Error("librariangen: unknown command: %s (with flags %v)",args[0],args)
return1
}
return0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

medium

Thisreturn 0 statement is unreachable because all paths in the precedingswitch statement return a value. This line can be removed.


// 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 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

medium

The removedrun function handled the--version flag. This logic has not been moved to the new implementation, which is a regression. The--version flag handling should be added back, likely in themain function before callinglanguagecontainer.Run.

@sonarqubecloud
Copy link

@sonarqubecloud
Copy link

@suztomosuztomo changed the titleShareed module experiment in sdk-platform-javaSharable module experiment in sdk-platform-javaOct 14, 2025
@suztomosuztomo changed the titleSharable module experiment in sdk-platform-javaShareable Go package experiment in sdk-platform-javaOct 14, 2025
@suztomosuztomo marked this pull request as draftOctober 20, 2025 21:14
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

1 more reviewer

@gemini-code-assistgemini-code-assist[bot]gemini-code-assist[bot] left review comments

Reviewers whose approvals may not affect merge requirements

At least 1 approving review is required to merge this pull request.

Assignees

No one assigned

Labels

size: mPull request size is medium.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

1 participant

@suztomo

[8]ページ先頭

©2009-2025 Movatter.jp