gpt4 book ai didi

go - 超慢的编译时间

转载 作者:行者123 更新时间:2023-12-02 11:26:32 25 4
gpt4 key购买 nike

我通常在计算机上使用Go,并且编译速度非常快(不到1秒),但是不幸的是,在Visual Studio代码Go插件要求我安装一堆东西之后,Go变得非常慢,这是一个简单的代码,如下所示:

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(Idea)

  • 现在,我正在使用最新的Go版本:
    $ 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
    有没有人经历过这个问题,可以让我对这个问题有所了解?谢谢!

    最佳答案

    首先检查问题是否仍然存在于命令行(CLI)
    如果是这样,请通过在同一CMD session 中设置简化的PATH来确保这不是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%

    关于go - 超慢的编译时间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64142785/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com