cloudwego / cloudwego/kitex

tool: GetGOPATH truncates Windows drive-letter paths

Open Beginner friendly
#1,993 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
8k
Forks
918
Avg merge
1d 13h
Merged PRs (30d)
7

Description

### Version

`main` at `72ad8a8db57e53846c656e56dce4e3c873d86161` (also reproducible with Kitex v0.16.3 in `version.go`)

### Environment

- Windows/amd64
- Go 1.26.3
- An explicitly configured drive-letter GOPATH (for example, `C:\Users\example\go`)

### What happened?

`tool/internal_pkg/util.GetGOPATH` splits the `GOPATH` environment variable with a hard-coded colon. On Windows, the drive-letter colon is treated as a path-list separator, so a normal explicitly configured GOPATH such as `C:\Users\example\go` is returned as just `C`.

This causes the existing Windows regression path in `refGoSrcPath` to fail because its test sets GOPATH to the repository's absolute working directory:

```console
> go test ./tool/cmd/kitex/args -run '^TestArguments_refGoSrcPath$' -count=1 -v
=== RUN TestArguments_refGoSrcPath
args_test.go:32: assertion failed
--- FAIL: TestArguments_refGoSrcPath (0.00s)
FAIL
```

The returned GOPATH is also used as a fallback when locating compiler plugins, so drive-letter truncation can affect GOPATH-mode code generation and tool discovery when GOPATH is explicitly configured.

### What did you expect to happen?

The first GOPATH entry should be returned intact, using the platform's path-list separator. The standard-library `filepath.SplitList` handles both Windows semicolon-separated lists and Unix colon-separated lists.

### Additional context

I searched open and closed issues, all PR states, Discussions, and commit history for `GetGOPATH`, `filepath.SplitList`, and related Windows GOPATH reports. #944/#949 and #1772 address different Windows code-generation failures; I did not find an existing report or competing fix for this separator bug.

Contributor guide

Open the contributing guide

Research direction

Start with tool/internal_pkg/util.GetGOPATH and run go test ./tool/cmd/kitex/args -run '^TestArguments_refGoSrcPath$' -count=1 -v on Windows. Check the existing Windows regression path and the standard-library filepath.SplitList behavior. Done means an explicitly configured drive-letter GOPATH remains intact and the regression test passes.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
tooling
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
88/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.