Conversation
waruqi
commented
Dec 5, 2025
- Before adding new features and new modules, please go to issues to submit the relevant feature description first.
- Write good commit messages and use the same coding conventions as the rest of the project.
- Please commit code to dev branch and we will merge into master branch in feature
- Ensure your edited codes with four spaces instead of TAB.
- 增加新特性和新模块之前,请先到issues提交相关特性说明,经过讨论评估确认后,再进行相应的代码提交,避免做无用工作。
- 编写友好可读的提交信息,并使用与工程代码相同的代码规范,代码请用4个空格字符代替tab缩进。
- 请提交代码到dev分支,如果通过,我们会在特定时间合并到master分支上。
- 为了规范化提交日志的格式,commit消息,不要用中文,请用英文描述。
Summary of ChangesHello @waruqi, 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 introduces a comprehensive rewrite of Xmake's Go language support, aiming to modernize and simplify the build experience. By transitioning to the unified 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. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request is a significant and valuable rewrite of the Go language support, modernizing it to use the go build command and greatly improving cross-compilation capabilities. The changes are well-structured and move xmake's Go support in the right direction. However, I've identified a few critical issues: a compilation error in a test file, a missing build script that will likely break all Go builds, and a new default configuration that disables Go modules, which could be problematic for modern Go projects. Addressing these points will make this excellent contribution ready for merging.
| import ( | ||
| "fmt" | ||
| "module" | ||
| "test" |
There was a problem hiding this comment.
| end | ||
| end) | ||
| on_build_files("build.object") | ||
| on_build("build.target") |
There was a problem hiding this comment.
The build process is now correctly hooked into on_build("build.target"). However, this requires a corresponding script file at xmake/rules/go/build/target.lua to define the build implementation. This file appears to be missing from the pull request. Without it, any attempt to build a Go target will fail as xmake won't be able to find the build script. You should add a target.lua file for the go rule, similar in structure to those for other languages like Rust or Nim.
| -- Disable Go modules mode to use GOPATH mode | ||
| -- This allows Go to find packages using GOPATH | ||
| if not os.getenv("GO111MODULE") then | ||
| toolchain:add("runenvs", "GO111MODULE", "off") | ||
| end |
There was a problem hiding this comment.
Forcing GO111MODULE=off disables Go modules, which is the standard for dependency management in modern Go projects. This is a very restrictive default that will break builds for most current Go projects relying on go.mod. A better approach would be to not set this variable, allowing the Go toolchain to use its own defaults (which are module-aware), or to set it to "auto" to support both module-based and GOPATH-based projects.
-- Set Go modules mode. 'auto' is a flexible default.
-- This allows using Go modules or GOPATH depending on project structure.
if not os.getenv("GO111MODULE") then
toolchain:add("runenvs", "GO111MODULE", "auto")
end
|
|
||
| -- add build flags | ||
| if flags then | ||
| table.join2(argv, flags) |
There was a problem hiding this comment.
Using table.join2 is effective, but for combining flags which can be complex (e.g., multiple -ldflags), it might be safer and clearer to handle them more granularly. The current implementation merges all flags into a single list, which could lead to issues if flags need to be paired with their values, especially with how -ldflags are constructed elsewhere as a two-element table. A more robust approach would be to process flags, particularly those like -ldflags, to ensure they are correctly formatted and merged.