Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Super slow compile time

Tags:

go

I was using Go normally in my computer and it was compiling really fast (< 1s), but unfortunately after the visual studio code Go plugin asked me to install a bunch of things my Go become super slow, a simple code like this:

package main

import (
    "fmt"
)

func main() {
    fmt.Println("Hello")
}

Is taking more than 10 seconds to execute:

[Running] go run "c:\dev\workspace\go\test\src\main.go"
Hello

[Done] exited with code=0 in 45.596 seconds

[Running] go run "c:\dev\workspace\go\test\src\main.go"
Hello

[Done] exited with code=0 in 16.242 seconds

[Running] go run "c:\dev\workspace\go\test\src\main.go"
Hello

[Done] exited with code=0 in 14.759 seconds

[Running] go run "c:\dev\workspace\go\test\src\main.go"
Hello

[Done] exited with code=0 in 15.492 seconds

[Running] go run "c:\dev\workspace\go\test\src\main.go"
Hello

[Done] exited with code=0 in 16.047 seconds

What I already have tried:

  • Uninstalled everything and installed again;
  • Changed Go version to 1.4 (it improved the compile time, but nothing really big, like in this version it compiled in ~7 seconds, what still making it slow)
  • Tried other IDE (Idea)

Now I'm using the latest Go version:

$ go version
go version go1.15.2 windows/amd64

My "go env":

$ go env
set GO111MODULE=
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\ticunha\AppData\Local\go-build
set GOENV=C:\Users\ticunha\AppData\Roaming\go\env
set GOEXE=.exe
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GOMODCACHE=C:\dev\workspace\go\pkg\mod
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=C:\dev\workspace\go
set GOPRIVATE=
set GOPROXY=https://proxy.golang.org,direct
set GOROOT=c:\go
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLDIR=c:\go\pkg\tool\windows_amd64
set GCCGO=gccgo
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=C:\Users\ticunha\AppData\Local\Temp\1\go-build323480842=/tmp/go-build -gno-record-gcc-switches

Has anyone been through this and could give me some light on this problem? Thank you!

like image 629
tiagomac Avatar asked Feb 10 '26 04:02

tiagomac


1 Answers

Check first if the issue persists in command line (CLI)

If it does, then make sure this is not a PATH issue, by setting in that same CMD session a simplified PATH:

set PATH=C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\
set GH=C:\path\to\git
set PATH=%GH%\bin;%GH%\usr\bin;%GH%\mingw64\bin;%PATH%
set PATH=%USERPROFILE%\go\bin;%PATH%
set PATH=c:\go\bin;%PATH%
like image 166
VonC Avatar answered Feb 13 '26 10:02

VonC