I want to complete the build faster

Uninstalling Go for an upgrade
I installed go1.15.5 on windows/amd64.
To be sure, when I run go run main.go

, the build does not complete.
I waited 40 minutes and it’s not done.
Is there a cause or has the specification changed?
How to finish go ru main.go faster?

It is impossible to tell you what is happening wihtout more information.

  • What exactly is main.go? Is it small or large?
  • Do you use any modules or libraries? Which?
  • What happens if you execute go build?
1 Like

hi lutzhorn
Sorry for the lack of information …
What exactly is main.go? Is it small or large? A. Yes it is small 795 bytes
Do you use any modules or libraries? Which? A. Yes yes is the next library

"fmt"
"regexp"
"net/http"
 "io/ioutil"
 "log"
 "strings"

What happens if you execute go build ? A. I tried the go build and it didn’t complete as well as the go run.

code


package main

import (
	"fmt"
	"regexp"
	"net/http"
  "io/ioutil"
  "log"
  "strings"
)

func CheckError(err error) {
  if err != nil {
    fmt.Println(a)
    log.Fatal(err)
  }
}

var (
  recmp        = regexp.MustCompile("\\<([\\w\\W])+?\\>")
  recmp_script = regexp.MustCompile("\\<script([\\w\\W])>([\\w\\W])<script\\>")
  inp_deletion = strings.NewReplacer("\n","","\t",""," ","")
)

func main(){
  url := "https://youtube.com"
  resp, err := http.Get(url)
  CheckError(err)
  defer resp.Body.Close()
  bodys, err := ioutil.ReadAll(resp.Body)
  CheckError(err)
  a := recmp.ReplaceAllString(inp_deletion.Replace(recmp_script.ReplaceAllString(string(bodys),"")),"")
  fmt.Println(a)
}

The OS I use is windows 10

I am unable to reproduce your issue, even after I fixed the compile error in your program.

Provide precise instructions on how to reproduce your issue.

I installed go1.15.5 on windows/amd64.

Did you follow the official instructions for Windows precisely?

Go: Download and install

What happens if you rerun the download and install using the official instructions for Windows?

What is your output from the go version command?

Microsoft Windows [Version 10.0.19041.572]
(c) 2020 Microsoft Corporation. All rights reserved.

>go version
go version go1.15.5 windows/amd64

You are making things far too complicated. Keep it simple.

What happens when you run this simple hello.go program?

package main

import "fmt"

func main() {
    fmt.Println("Hello, Gophers!")
}

.

>go run hello.go
Hello, Gophers!

What happens when you run this simple example.go program?

package main

import (
    "fmt"
    "io/ioutil"
    "log"
    "net/http"
)

func main() {
    url := "https://example.com"
    resp, err := http.Get(url)
    if err != nil {
	    log.Fatal(err)
    }
    defer resp.Body.Close()
    body, err := ioutil.ReadAll(resp.Body)
    if err != nil {
	    log.Fatal(err)
    }
    fmt.Println(len(body))
    fmt.Println(string(body))
}

.

>go run example.go
1256
<!doctype html>
<html>
<head>
    <title>Example Domain</title>

    <meta charset="utf-8" />
    <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <style type="text/css">
    body {
        background-color: #f0f0f2;
        margin: 0;
        padding: 0;
        font-family: -apple-system, system-ui, BlinkMacSystemFont, "Segoe UI", "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif;

    }
    div {
        width: 600px;
        margin: 5em auto;
        padding: 2em;
        background-color: #fdfdff;
        border-radius: 0.5em;
        box-shadow: 2px 3px 7px 2px rgba(0,0,0,0.02);
    }
    a:link, a:visited {
        color: #38488f;
        text-decoration: none;
    }
    @media (max-width: 700px) {
        div {
            margin: 0 auto;
            width: auto;
        }
    }
    </style>
</head>

<body>
<div>
    <h1>Example Domain</h1>
    <p>This domain is for use in illustrative examples in documents. You may use this
    domain in literature without prior coordination or asking for permission.</p>
    <p><a href="https://www.iana.org/domains/example">More information...</a></p>
</div>
</body>
</html>

What is your output from the go env command?

A. YesI uninstalled and re-installed it firmly because there might be a mistake somewhere.

A. This is how it went out

Microsoft Windows [Version 10.0.18363.1198]
(c) 2019 Microsoft Corporation. All rights reserved.

>go version
go version go1.15.5 windows/amd64

A. It worked beautifully!And this is the output

>go run hello.go
Hello, Gophers!

A. Nothing came up! The error didn’t even happen!

>go run example.go

A. Go env has successfully output the following(*User eyes for privacy protection)

set GO111MODULE=
set GOARCH=amd64
set GOBIN=GOPATH/bin
set GOCACHE=C:\Users\UsersName\AppData\Local\go-build
set GOENV=C:\Users\UsersName\AppData\Roaming\go\env
set GOEXE=.exe
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GOMODCACHE=C:\Users\UsersName\go\pkg\mod
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=C:\Users\UsersName\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 -fmessage-length=0 -fdebug-prefix-map=C:\Users\UsersName\AppData\Local\Temp\go-build210965470=/tmp/go-build -gno-record-gcc-switches