Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x/website: Tutorial: Get started with Go is not working correctly #44021

Closed
mansilktov opened this issue Jan 30, 2021 · 4 comments
Closed

x/website: Tutorial: Get started with Go is not working correctly #44021

mansilktov opened this issue Jan 30, 2021 · 4 comments

Comments

@mansilktov
Copy link

What version of Go are you using (go version)?

$ go version
go version go1.15.7 linux/amd64

Does this issue reproduce with the latest release?

I do not know. But it reproduces on Windows.

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/stanislav/.cache/go-build"
GOENV="/home/stanislav/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/stanislav/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/stanislav/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/stanislav/hello/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build278194846=/tmp/go-build -gno-record-gcc-switches"

What did you do?

I am starting to learn Go.
I follow instruction from https://golang.org/doc/tutorial/getting-started

What did you expect to see?

After running step 4 of the instruction 4 Run your code to see the message generated by the function you're calling I want to see:

$ go run .
go: finding module for package rsc.io/quote
go: found rsc.io/quote in rsc.io/quote v1.5.2
Don't communicate by sharing memory, share memory by communicating.

What did you see instead?

stanislav@vb:~/hello$ nano hello.go 
stanislav@vb:~/hello$ cat hello.go 
package main

import "fmt"

import "rsc.io/quote"

func main() {
    fmt.Println(quote.Go())
}
stanislav@vb:~/hello$ go mod init hello.go
go: creating new go.mod: module hello.go
stanislav@vb:~/hello$ go run .
go: finding module for package rsc.io/quote
go: downloading rsc.io/quote v1.5.2
go: found rsc.io/quote in rsc.io/quote v1.5.2
go: rsc.io/quote@v1.5.2 requires
	rsc.io/sampler@v1.3.0 requires
	golang.org/x/text@v0.0.0-20170915032832-14c0d48ead0c: Get "https://proxy.golang.org/golang.org/x/text/@v/v0.0.0-20170915032832-14c0d48ead0c.mod": read tcp 10.0.2.15:39782->172.217.16.49:443: read: connection reset by peer

And on Windows it is:

C:\Users\Admin\hello>go run .
go: finding module for package rsc.io/quote
go: downloading rsc.io/quote v1.5.2
go: found rsc.io/quote in rsc.io/quote v1.5.2
go: rsc.io/quote@v1.5.2 requires
        rsc.io/sampler@v1.3.0 requires
        golang.org/x/text@v0.0.0-20170915032832-14c0d48ead0c: Get "https://proxy.golang.org/golang.org/x/text/@v/v0.0.0-20170915032832-14c0d48ead0c.mod": read tcp 192.168.1.4:1959->172.217.16.49:443: wsarecv: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.

So it does not print the line: Don't communicate by sharing memory, share memory by communicating. as stated in the step 4 of the tutorial.

@gopherbot gopherbot added this to the Unreleased milestone Jan 30, 2021
@seankhliao
Copy link
Member

this looks like a problem with your internet connection

@mansilktov
Copy link
Author

@seankhliao

I guess it was not a problem with my internet connection.
I am starting with clear environment.

stanislav@vb:~$ pwd
/home/stanislav
stanislav@vb:~$ ls go
ls: cannot access 'go': No such file or directory

As you can see there is no "go" folder in my home directory.

stanislav@vb:~$ cd hello/
stanislav@vb:~/hello$ ls
hello.go
stanislav@vb:~/hello$ cat hello.go 
package main

import "fmt"

import "rsc.io/quote"

func main() {
    fmt.Println(quote.Go())
}

As you can see I have a file "hello.go" the same as in the step 2 of the section "Call code in an external package".
Then I run a command from the step 3 of "Call code in an external package".

stanislav@vb:~/hello$ go mod init hello
go: creating new go.mod: module hello
stanislav@vb:~/hello$ ls
go.mod  hello.go
stanislav@vb:~/hello$ cat go.mod 
module hello

go 1.15

Then I run a command from the step 4 of "Call code in an external package".

stanislav@vb:~/hello$ go run .
go: finding module for package rsc.io/quote
go: downloading rsc.io/quote v1.5.2
go: found rsc.io/quote in rsc.io/quote v1.5.2
go: rsc.io/quote@v1.5.2 requires
	rsc.io/sampler@v1.3.0 requires
	golang.org/x/text@v0.0.0-20170915032832-14c0d48ead0c: Get "https://proxy.golang.org/golang.org/x/text/@v/v0.0.0-20170915032832-14c0d48ead0c.mod": read tcp 10.0.2.15:37716->172.217.20.17:443: read: connection reset by peer

As you can see there is some error happened.
But at the same time in my home directory the folder "go" is now created with some files in it.

stanislav@vb:~/hello$ ls -R ~/go
/home/stanislav/go:
pkg

/home/stanislav/go/pkg:
mod  sumdb

/home/stanislav/go/pkg/mod:
cache  rsc.io

/home/stanislav/go/pkg/mod/cache:
download  lock

/home/stanislav/go/pkg/mod/cache/download:
rsc.io  sumdb

/home/stanislav/go/pkg/mod/cache/download/rsc.io:
quote  sampler

/home/stanislav/go/pkg/mod/cache/download/rsc.io/quote:
@v

/home/stanislav/go/pkg/mod/cache/download/rsc.io/quote/@v:
list  list.lock  v1.5.2.info  v1.5.2.lock  v1.5.2.mod  v1.5.2.zip  v1.5.2.ziphash

/home/stanislav/go/pkg/mod/cache/download/rsc.io/sampler:
@v

/home/stanislav/go/pkg/mod/cache/download/rsc.io/sampler/@v:
list  list.lock  v1.3.0.mod

/home/stanislav/go/pkg/mod/cache/download/sumdb:
sum.golang.org

/home/stanislav/go/pkg/mod/cache/download/sumdb/sum.golang.org:
lookup  tile

/home/stanislav/go/pkg/mod/cache/download/sumdb/sum.golang.org/lookup:
rsc.io

/home/stanislav/go/pkg/mod/cache/download/sumdb/sum.golang.org/lookup/rsc.io:
quote@v1.5.2  sampler@v1.3.0

/home/stanislav/go/pkg/mod/cache/download/sumdb/sum.golang.org/tile:
8

/home/stanislav/go/pkg/mod/cache/download/sumdb/sum.golang.org/tile/8:
0  1  2

/home/stanislav/go/pkg/mod/cache/download/sumdb/sum.golang.org/tile/8/0:
001  003  x010

/home/stanislav/go/pkg/mod/cache/download/sumdb/sum.golang.org/tile/8/0/x010:
372.p

/home/stanislav/go/pkg/mod/cache/download/sumdb/sum.golang.org/tile/8/0/x010/372.p:
207  208

/home/stanislav/go/pkg/mod/cache/download/sumdb/sum.golang.org/tile/8/1:
000  040.p

/home/stanislav/go/pkg/mod/cache/download/sumdb/sum.golang.org/tile/8/1/040.p:
132

/home/stanislav/go/pkg/mod/cache/download/sumdb/sum.golang.org/tile/8/2:
000.p

/home/stanislav/go/pkg/mod/cache/download/sumdb/sum.golang.org/tile/8/2/000.p:
40

/home/stanislav/go/pkg/mod/rsc.io:
quote@v1.5.2

/home/stanislav/go/pkg/mod/rsc.io/quote@v1.5.2:
buggy  go.mod  LICENSE  quote.go  quote_test.go  README.md

/home/stanislav/go/pkg/mod/rsc.io/quote@v1.5.2/buggy:
buggy_test.go

/home/stanislav/go/pkg/sumdb:
sum.golang.org

/home/stanislav/go/pkg/sumdb/sum.golang.org:
latest

So, I guess, it cannot be a problem with my internet connection, because these files are somehow fetched from somewhere, I guess from the internet.

@oiooj
Copy link
Member

oiooj commented Feb 1, 2021

@akimovstv Your problem is that you can not access proxy.golang.org, you can try goproxy.io to confirm:

export GOPROXY=https://goproxy.io,direct

then run go run .

The goproxy.io's servers deployed in Europe, USA and HongKong.

@mansilktov
Copy link
Author

mansilktov commented Feb 2, 2021

@oiooj
I tried as you advised here #44021 (comment).
but it didn't help me - the problem was the same and the error messages were the same.

So, lately I've been doing some testing on other computers connected to different networks. Everything was fine and worked as expected.

In the long last I found the source of the problem. It seems that the problem is with my router and, as I may guess, my host OS. My router has 2 channels: 2.4G (slower one) and 5G (faster one). When I connect to the Internet wirelessly using 5G channel of my router the problem is there, when I change connection to 2.4G channel the problem is gone. I am not an expert and cannot possilbly understand the reason of this. I tried to fix the problem by setting my network and firewall settings of my os to default state, and set the 5G channel settings on my router in accordance with the 2.4G channel settings. It helped a bit, but still sometimes packages do not download. It is very very strange 😦. I shall use 2.4G wifi for futher learning.

Anyway, thank for help everyone!

@golang golang locked and limited conversation to collaborators Feb 4, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants