Go version
1.24.3
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=on
set GOAMD64=v1
set GOARCH=amd64
set GOAUTH=netrc
set GOBIN=
set GOCACHE=C:\Users\1008255\AppData\Local\go-build
set GOCACHEPROG=
set GODEBUG=
set GOENV=C:\Users\1008255\AppData\Roaming\go\env
set GOEXE=.exe
set GOEXPERIMENT=
set GOFIPS140=off
set GOFLAGS=
set GOGCCFLAGS=-m64 -mthreads -fno-caret-diagnostics -Qunused-arguments -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=C:\Users\1008255\AppData\Local\Temp\go-build2628681816=/tmp/go-build -gno-record-gcc-switches
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
go: stripping unprintable or unescapable characters from %"GOMOD"%
set GOMOD=D:\���档\Go\Project\G50������系���\G50\backend\go.mod
go: stripping unprintable or unescapable characters from %"GOMODCACHE"%
set GOMODCACHE=D:\���档\Go\pkg\mod
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
go: stripping unprintable or unescapable characters from %"GOPATH"%
set GOPATH=D:\���档\Go
set GOPRIVATE=
set GOPROXY=https://goproxy.cn,direct
set GOROOT=E:\Go
set GOSUMDB=sum.golang.org
set GOTELEMETRY=local
set GOTELEMETRYDIR=C:\Users\1008255\AppData\Roaming\go\telemetry
set GOTMPDIR=
set GOTOOLCHAIN=auto
set GOTOOLDIR=E:\Go\pkg\tool\windows_amd64
set GOVCS=
set GOVERSION=go1.24.3
go: stripping unprintable or unescapable characters from %"GOWORK"%
set GOWORK=D:\���档\Go\Project\G50������系���\G50\backend\go.work
set PKG_CONFIG=pkg-config
What did you do?
Three days ago, running go run main.go
started reporting the error below. However, everything worked fine before that.
I tried repairing the Go installer, then ran go clean -modcache && go mod tidy
, which temporarily fixed it. But after restarting Windows, the error returned. The same issue occurs with both Go 1.21 and 1.24.
Today, I discovered that running go run main.go in VS Code's terminal works correctly. This makes me suspect it's a bug.
What did you see happen?
package command-line-arguments imports github.com/gofiber/fiber/v2 imports crypto/tls imports crypto/internal/boring: C source files not allowed when not using cgo or SWIG: div_test.c package command-line-arguments imports github.com/gofiber/fiber/v2 imports crypto/tls imports crypto/internal/hpke imports golang.org/x/crypto/chacha20poly1305 imports golang.org/x/sys/cpu: C source files not allowed when not using cgo or SWIG: cpu_gccgo_x86.c
What did you expect to see?
See nothing.
Comment From: mknyszek
Not sure exactly who to route this to, so maybe the Go command folks like @matloob and @samthanawalla might be able to help.
I think we're going to need more information to reproduce the issue, though. This sounds like the sort of thing that would happen if some environment variable is accidentally set, though nothing really stands out to me in go env
.
Comment From: Zxilly
Can you provide the content of main.go
? Or provide a minimally reproducible sample.
Comment From: 8188
@Zxilly Even a simple "Hello, World" style Fiber script (or any other example requiring cgo) would lead to this issue.
Comment From: Zxilly
package main
import (
"log"
"github.com/gofiber/fiber/v3"
)
func main() {
app := fiber.New()
app.Get("/", func(c fiber.Ctx) error {
return c.SendString("Hello, World 👋!")
})
log.Fatal(app.Listen(":3000"))
}
This script works well for me, can you try moving the project to a folder with no Chinese characters in the path and try again? Also move the go sdk in D:\���档\Go
Comment From: Zxilly
And, can you check the output of go env
in VS Code's terminal? I suspect that your default go
is pointing to a broken installation.
Comment From: 8188
After moving the project to a directory without Chinese characters, there's still no improvement.
I compared go env
outputs between VS Code's terminal and other terminals, and found no differences except for the following:
Comment From: Zxilly
Try also move your go installation and point such path to a pure ascii path.
You can use go env -w GOMODCACHE=C:\Users\1008255\go\pkg\mod
Comment From: 8188
Still ineffective.
Comment From: Zxilly
please try go run -x -a -v -work main.go
, and provide a full log of what was generated.
If possible, this step should be done using a fresh install of go
Comment From: 8188
Comment From: Zxilly
Is thia a fresh new go install?
Comment From: 8188
No,I have reinstalled go yesterday. The same after reboot.
Comment From: Zxilly
I can't see what's happening, so let us see if other members have any ideas.
Comment From: 8188
Sorry for the trouble. The reason is that my fucked company's encryption software encrypted the C code without any notice, and the only way to access it is by opening it in VSCode or Keil.