Description
Go version
go version go1.24.3 windows/amd64
Output of go env
in your module/workspace:
set AR=ar
set CC=gcc
set CGO_CFLAGS=-O2 -g
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-O2 -g
set CGO_ENABLED=1
set CGO_FFLAGS=-O2 -g
set CGO_LDFLAGS=-O2 -g
set CXX=g++
set GCCGO=gccgo
set GO111MODULE=
set GOAMD64=v1
set GOARCH=amd64
set GOAUTH=netrc
set GOBIN=G:\GOFOLDERS\version 1.24.3\GOBIN
set GOCACHE=G:\GOFOLDERS\version 1.24.3\GOCACHE
set GOCACHEPROG=
set GODEBUG=
set GOENV=G:\GOFOLDERS\version 1.24.3\GOENV\env
set GOEXE=.exe
set GOEXPERIMENT=
set GOFIPS140=off
set GOFLAGS=
set GOGCCFLAGS=-m64 -mthreads -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=G:\Temp\go-build690732913=/tmp/go-build -gno-record-gcc-switches
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GOMOD=K:\Delphi\AI Tests\Gemini Tests\Go Dependency Scanner\version 0.10\go.mod
set GOMODCACHE=G:\GOFOLDERS\version 1.24.3\GOMODCACHE
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=G:\GOFOLDERS\version 1.24.3\GOPATH
set GOPRIVATE=
set GOPROXY=
set GOROOT=G:\GOFOLDERS\version 1.24.3\GOROOT
set GOSUMDB=
set GOTELEMETRY=off
set GOTELEMETRYDIR=C:\Users\skybu\AppData\Roaming\go\telemetry
set GOTMPDIR=
set GOTOOLCHAIN=
set GOTOOLDIR=G:\GOFOLDERS\version 1.24.3\GOROOT\pkg\tool\windows_amd64
set GOVCS=
set GOVERSION=go1.24.3
set GOWORK=
set PKG_CONFIG=pkg-config
What did you do?
Short version:
package main
import (
"fmt"
"go/build"
)
func main() {
// Try to print a constant from the go/build package
fmt.Println("build.ImportComment value:", build.ImportComment)
fmt.Println("build.IgnoreTestGoFiles value:", build.IgnoreTestGoFiles)
}
Does not build on windows:
Errors:
go build -o test_build.exe
.\test_build.go:11:54: undefined: build.IgnoreTestGoFiles
Likely cause of failure:
pgk.go missing in folder:
G:\GOFOLDERS\version 1.24.3\GOROOT\src\go\build>dir
Volume in drive G is APPLICATION HARDDISK
Volume Serial Number is 0AE8-C66D
Directory of G:\GOFOLDERS\version 1.24.3\GOROOT\src\go\build
13/05/2025 20:11
.13/05/2025 20:11 ..
13/05/2025 20:11 63,892 build.go
13/05/2025 20:11 24,330 build_test.go
13/05/2025 20:11 constraint
13/05/2025 20:11 20,977 deps_test.go
13/05/2025 20:11 3,792 doc.go
13/05/2025 20:11 396 gc.go
13/05/2025 20:11 344 gccgo.go
13/05/2025 20:11 14,456 read.go
13/05/2025 20:11 6,182 read_test.go
13/05/2025 20:11 1,412 syslist_test.go
13/05/2025 20:11 testdata
13/05/2025 20:11 1,970 vendor_test.go
13/05/2025 20:11 94 zcgo.go
11 File(s) 137,845 bytes
4 Dir(s) 8,661,670,559,744 bytes free
G:\GOFOLDERS\version 1.24.3\GOROOT\src\go\build>
(Also GOFLAGS had invalid symbols, manually removed with env variable in windows, it contained something like -mod-vendor? possibly incorrectly set by some other go tool).
Long version explained by AI, two prompts:
Thank you for providing that dir output! This is the smoking gun we've been looking for.
You are absolutely correct; the directory listing for G:\GOFOLDERS\version 1.24.3\GOROOT\src\go\build does not contain a file named pkg.go.
The Root Cause Confirmed: Missing Standard Library File
The constant build.IgnoreTestGoFiles (along with build.ImportComment and many other crucial definitions for the go/build package) is defined within the pkg.go source file of the go/build package.
Because pkg.go is missing from your Go installation's src/go/build directory, the Go compiler literally cannot find the definition of build.IgnoreTestGoFiles, which is why it reports it as "undefined."
This explains all the previous errors. Your main.go code is correct, and your go version confirms a version where this constant exists. The problem is purely with the integrity of your Go installation's standard library files on your disk.
The Only Solution: A Rigorous, Verifiable Clean Reinstallation
The previous attempts to upgrade Go might have failed to fully overwrite or correctly place all the standard library files in your custom G:\GOFOLDERS path. To fix this definitively, we need to perform a complete and thorough clean reinstallation of Go. This means:
Manually deleting ALL traces of the current Go installation.
Installing a fresh copy of Go to its default location (which is usually C:\Program Files\Go or C:\Go) to ensure that GOROOT and PATH are set up in a standard, reliable way by the installer itself, minimizing any potential issues with custom paths.
Please follow these steps very carefully:
Phase 1: Complete Manual Uninstallation of Go
Close All Go-Related Programs:
Close all open command prompts, PowerShell windows, IDEs (like VS Code, GoLand), or any other applications that might be using Go files. This is crucial to prevent file locking during deletion.
Restart your computer if you encounter any "file in use" errors during deletion.
Identify and Delete All Go-Related Directories:
Based on your go env output, you need to manually delete these folders.
Navigate in File Explorer to: G:\GOFOLDERS\version 1.24.3\
Delete the ENTIRE GOROOT folder: G:\GOFOLDERS\version 1.24.3\GOROOT
Delete the ENTIRE GOPATH folder: G:\GOFOLDERS\version 1.24.3\GOPATH
Delete the ENTIRE GOCACHE folder: G:\GOFOLDERS\version 1.24.3\GOCACHE
Delete the ENTIRE GOMODCACHE folder: G:\GOFOLDERS\version 1.24.3\GOMODCACHE
Also, consider deleting the parent folder G:\GOFOLDERS\version 1.24.3\ if it becomes empty after deleting its contents.
Clean Your System's PATH Environment Variable:
Search for "Environment Variables" in the Windows Start Menu and select "Edit the system environment variables".
Click the "Environment Variables..." button.
Under "System variables", find the Path variable and click "Edit...".
Look for any entries that refer to the old Go installation path (e.g., G:\GOFOLDERS\version 1.24.3\GOROOT\bin or anything similar). Select and Delete these entries.
Also, ensure there are no GOROOT, GOPATH, GOCACHE, GOMODCACHE variables under "User variables" or "System variables". If they exist, delete them.
Click "OK" on all dialogs to save the changes.
Phase 2: Fresh Installation of Go
Download the Latest Stable Go Installer:
Go to the official Go download page: https://go.dev/dl/
Download the installer for the latest stable Go release for Windows (AMD64) (e.g., go1.22.x.windows-amd64.msi or go1.23.x.windows-amd64.msi when it becomes stable). Using the absolute latest stable helps ensure you get a fully functional, well-tested build.
Run the New Installer:
Run the downloaded .msi installer.
Crucial: Install Go to its default location, typically C:\Program Files\Go or C:\Go. This is the most reliable way to ensure all standard library files are placed correctly and environment variables are configured as expected.
Allow the installer to automatically configure your environment variables.
Phase 3: Verify and Rebuild
Open a BRAND NEW Command Prompt:
This is absolutely essential to ensure that your system loads the newly configured environment variables.
Verify New Go Installation:
Run: go version
Confirm it shows the new Go version you just installed (e.g., go version go1.22.x windows/amd64).
Run: go env
Crucially, verify that GOROOT now points to the new default installation path (e.g., C:\Program Files\Go).
Also, confirm that GOPATH, GOCACHE, and GOMODCACHE are now pointing to standard locations under your user profile (e.g., C:\Users\YourUser\go).
Perform the pkg.go Existence Check Again:
After the new installation, navigate to the expected location of pkg.go:
cd C:\Program Files\Go\src\go\build (or wherever your new GOROOT is)
Run dir or ls to verify that pkg.go is now present in that directory. It MUST be there.
Test Your Go Dependency Analyzer:
Once you've confirmed pkg.go exists, navigate back to your main project directory:
cd K:\Delphi\AI Tests\Gemini Tests\Go Dependency Scanner\version 0.10
Run the build command:
go build -o go-dep-analyzer.exe
I understand this is a laborious process, but it's the most certain way to overcome the unique environmental issue you're facing. Please let me know the results after you've completed these steps.
I'd rather just report this bug, because I think I already installed it like this... I cannot imagine what might have gone wrong, maybe I moved some files, but assuming the installer allows me to install to these custom folders it should be there, maybe this file is lingering somewhere on a C drive default directory ?
You're absolutely right to consider reporting this as a bug, especially given the persistence of the undefined: build.IgnoreTestGoFiles error despite multiple attempts to update and rebuild. This behavior is highly unusual for a standard Go installation, and it's completely understandable why you're frustrated.
The core issue, as we confirmed with the directory listing, is that the pkg.go file—which defines build.IgnoreTestGoFiles and many other critical components of the go/build package—is missing from your G:\GOFOLDERS\version 1.24.3\GOROOT\src\go\build directory. The Go compiler literally cannot find the definition because the source file containing it isn't there.
While it's theoretically possible for installer remnants or antivirus software to interfere, the most common reason for a standard library file to be missing after an installation, particularly to a non-default path, is an issue during the installation process itself (permissions, disk errors, or the installer not fully overwriting/placing files in a custom location).
Before Reporting the Bug (Crucial Step)
For the Go team to take your bug report seriously, they will almost certainly ask you to perform a clean installation to the default Go path (C:\Program Files\Go or C:\Go). This is because custom GOROOT paths are a common source of environment-related issues, and they need to rule that out.
Therefore, before you report the bug, please attempt one final, very rigorous clean installation to the default path:
Close Everything: Close all command prompts, IDEs, and any programs that might be using Go files.
Manual Deletion: Manually delete your entire G:\GOFOLDERS\version 1.24.3\ folder. This is critical to ensure no remnants from your custom installation path interfere.
Clean PATH/Environment Variables: Double-check your system and user environment variables (PATH, GOROOT, GOPATH, GOCACHE, GOMODCACHE) and remove any entries related to G:\GOFOLDERS\version 1.24.3\ or any custom Go paths.
Download Latest Official: Download the latest stable Go installer for Windows (AMD64) directly from go.dev/dl/.
Install to Default: Run the installer and explicitly choose the default installation path (e.g., C:\Program Files\Go). Let the installer manage the environment variables.
New Command Prompt: Open a brand new command prompt.
Verify New Installation:
go version (confirm latest)
go env (confirm GOROOT points to the default path, e.g., C:\Program Files\Go)
Crucially, check for pkg.go: Navigate to C:\Program Files\Go\src\go\build (or your new GOROOT's src\go\build directory) and run dir. Confirm that pkg.go now exists.
Retest test_build.go: If pkg.go is present, go to your K:\Delphi\AI Tests\Gemini Tests\Go Dependency Scanner\version 0.10\test directory and run go build -o test_build.exe.
If, and only if, pkg.go is confirmed to be missing even after a clean installation to the default path, or if the test_build.go still fails after that, then you have a strong case for a Go bug report.
How to Report a Go Bug
If you proceed with reporting, here's a template for a good bug report on the Go issue tracker on GitHub:
Title: build.IgnoreTestGoFiles undefined after clean installation (Windows/AMD64)
Problem:
The Go compiler reports undefined: build.IgnoreTestGoFiles when attempting to build a simple Go program that imports go/build, even after a clean installation of the latest stable Go version to the default path. This indicates a missing or inaccessible standard library file.
Steps to Reproduce:
Environment Setup:
Perform a complete manual uninstallation of Go (including deleting GOROOT, GOPATH, caches, and cleaning PATH environment variable entries).
Download the latest stable Go installer for Windows (AMD64) from go.dev/dl/.
Install Go to the default path (C:\Program Files\Go).
Open a new command prompt.
Verify go version and go env show the correct, clean installation paths.
Manually verify G:\GOFOLDERS\version 1.24.3\GOROOT\src\go\build\pkg.go is missing (this is the key observation).
(If you've reinstalled to default, update this path to the new default GOROOT, e.g., C:\Program Files\Go\src\go\build\pkg.go and state whether it is still missing or now present)
Create Minimal Reproduction:
Create a new empty directory (e.g., C:\temp\test_go_build).
Create a file named test_build.go inside it with the following content:
Go
package main
import (
"fmt"
"go/build"
)
func main() {
fmt.Println("build.ImportComment value:", build.ImportComment)
fmt.Println("build.IgnoreTestGoFiles value:", build.IgnoreTestGoFiles)
}
Attempt Build:
In the command prompt, navigate to C:\temp\test_go_build and run:
go build -o test_build.exe
Expected Behavior:
The program should compile successfully and print the values of build.ImportComment and build.IgnoreTestGoFiles.
Actual Behavior:
The compilation fails with the error:
.\test_build.go:11:54: undefined: build.IgnoreTestGoFiles
(Include the full error output you provided: K:\Delphi\AI Tests\Gemini Tests\Go Dependency Scanner\version 0.10\test>go build -o test_build.exe output here)
Go Version:
go version go1.24.3 windows/amd64
(Confirm this is still your version after final re-installation)
Go Environment (go env output):
(Paste the full output of go env from your newly installed, verified Go environment here)
System Details:
Operating System: Windows 10/11 (specify exact version if known)
Architecture: AMD64
Antivirus Software (if any): [e.g., Windows Defender, Avast, etc.]
Disk Type: [e.g., SSD, HDD, NVMe]
Any unusual file system configurations or network drives: [Yes/No, describe if yes]
This detailed approach gives the Go team all the information they need to investigate a genuine environmental or distribution bug.
What did you see happen?
Error, see above.
What did you expect to see?
Not an error.