Skip to content

proposal: cmd/go: Display Compilation Errors Relative to Original Working Directory When Using go -C #72905

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
karnigen opened this issue Mar 17, 2025 · 0 comments
Labels
Milestone

Comments

@karnigen
Copy link

Proposal Details

I'd like to propose a feature enhancement to the go command-line tool, specifically regarding the behavior of the -C flag and the way compilation errors are reported, particularly in heterogeneous development environments

Current Behavior:

Currently, when using go -C <directory> <command>, the go command changes its working directory to <directory>. Consequently, all relative paths and error messages reported by the compiler are relative to this new working directory.

Desired Behavior:

It would be beneficial if there were an option or flag to display compilation errors with paths relative to the original working directory from which the go command was invoked, even when using -C. This would improve the usability of -C in scenarios where users need to execute Go commands in different directories while maintaining context with their original project structure.

Problem with Editor Integration:

Many editors and IDEs rely on absolute or project-relative paths to quickly navigate to error locations. When go -C is used, the reported relative paths are often not recognized by these tools, making it difficult to jump directly to the source of the error. This significantly hinders the debugging process.

Use Case:

Consider a situation where a user has a complex project structure and needs to run tests or builds in a subdirectory using go -C. When compilation errors occur, the reported paths are relative to the subdirectory, making it cumbersome to navigate back to the original file locations.

Proposed Solution (Optional):

Perhaps a new flag, such as -original-paths or similar, could be introduced to control this behavior. Alternatively, this could be achieved through an environment variable.

Benefits:

  • Significantly improved editor and IDE integration.
  • Faster and more efficient debugging workflow.
  • Enhanced usability of go -C in complex projects.
  • Reduced friction when working with Go in multi-language environments.
@gopherbot gopherbot added this to the Proposal milestone Mar 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants