#1993·kitex

tool: GetGOPATH truncates Windows drive-letter paths

Author: dajiaohuangCreated Aug 24, 2026Updated Aug 24, 2026

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:

bash
> 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.