超慢的编译时间 [英] Super slow compile time

查看:35
本文介绍了超慢的编译时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我通常在计算机上使用Go,并且编译速度非常快(<1秒),但是不幸的是,在Visual Studio代码Go插件要求我安装一堆东西之后,我的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")
}

执行时间超过10秒:

[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

我已经尝试过的东西:

  • 卸载所有内容并重新安装;
  • 将Go版本更改为1.4(它缩短了编译时间,但是没什么大不了的,就像在这个版本中,它编译成〜7秒,仍然让它变慢了)
  • 尝试了其他IDE(想法)

现在我正在使用最新的Go版本:

Now I'm using the latest Go version:

$ go version
go version go1.15.2 windows/amd64

我的进入环境":

$ 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!

推荐答案

请首先检查问题是否在命令行(CLI)中仍然存在

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

如果确实如此,则通过在同一CMD会话中设置简化的PATH来确保这不是 PATH 问题:

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%

这篇关于超慢的编译时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆