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/blog:Tutorial not working #34232

Open
lazybutbusy opened this issue Sep 11, 2019 · 5 comments

Comments

@lazybutbusy
Copy link

commented Sep 11, 2019

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

$ go version
go version go1.13 windows/amd64

Does this issue reproduce with the latest release?

Yes

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

go env Output
$ go env
set GO111MODULE=
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\DELL\AppData\Local\go-build
set GOENV=C:\Users\DELL\AppData\Roaming\go\env
set GOEXE=.exe
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=C:\go-work
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\DELL\AppData\Local\Temp\go-build164497938=/tmp/go-build -gno-record-gcc-switches

What did you do?

I think the example on the tutorial is wrong

https://blog.golang.org/gos-declaration-syntax
At the end sector 'Pointer':
they declare a variable that i think it a integer nil pointer like this: []int("hi")
but i think the author is mistook with the : []int(nil)

What did you expect to see?

It run, cause it's a tutorial

What did you see instead?

the compiler throw back with the error:

command-line-arguments

.\test.go:10:14: cannot convert "hi" (type string) to type []int

@gopherbot gopherbot added this to the Unreleased milestone Sep 11, 2019

@ALTree

This comment has been minimized.

Copy link
Member

commented Sep 11, 2019

Back in 2010, when that article was written, there was no rune, and unicode strings were made of ints.

So in pre-1 Go releases, []int("hi") was perfectly valid. Then in Go1 rune was introduced as an alias for int32, so today you would write []rune("hi") (which works), and now []int("hi") is a compilation error.

@ALTree

This comment has been minimized.

Copy link
Member

commented Sep 11, 2019

A (very old) blog post is not really a tutorial, so I'm not sure we want to go back and retroactively change posts that were correct at the time but are not now. Labelling this as "NeedsDecision".

cc @robpike

@edulopezTriv

This comment has been minimized.

Copy link

commented Sep 11, 2019

A (very old) blog post is not really a tutorial, so I'm not sure we want to go back and retroactively change posts that were correct at the time but are not now. Labelling this as "NeedsDecision".

cc @robpike

I think if those post are still used as "valid and formal documentation" they should be updated. When I say "Formal" I mean that is given by a reliable source as google, not just a dev that works with the language. If is that not the case, I give a +1 to close the issue.

@robpike

This comment has been minimized.

Copy link
Contributor

commented Sep 11, 2019

I'd leave it alone for historical reasons and also because that whole section is built around int and introducing rune might be distracting. But I'm not certain about that decision, so other opinions welcome.

@go101

This comment has been minimized.

Copy link

commented Sep 12, 2019

How about adding a note box for all old blog articles before Go 1 to address such problems?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
6 participants
You can’t perform that action at this time.