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: Found an important typo in the text on first tutorial page. #51511

Closed
differentstuff opened this issue Mar 6, 2022 · 6 comments
Closed

Comments

@differentstuff
Copy link

What is the URL of the page with the issue?

https://go.dev/doc/tutorial/create-module

What is your user agent?

Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:97.0) Gecko/20100101 Firefox/97.0

Screenshot

not needed

What did you do?

I tried to learn about golang, and read the first Tutorial page "Tutorial: Create a Go module".
At the end of the page it is explained with the sentence "In Go, the := operator is a shortcut for declaring..."
I found it very confusing that the following example does not contain a colon at all.
"message = fmt.Sprintf("Hi, %v. Welcome!", name)"
But, in the example above there is a colon.
"message := fmt.Sprintf("Hi, %v. Welcome!", name)"
That's how I finally understood that part.

That's just a small typo I think, but as a programming starter (as me) it can be very difficult to understand.
If ever this is NOT a typo, I hope someone could explain me the meaning of this part.

What did you expect to see?

A colon

What did you see instead?

nothing

@gopherbot gopherbot added this to the Unreleased milestone Mar 6, 2022
@nerdrobot
Copy link

nerdrobot commented Mar 6, 2022

I believe that's not a typo but actually how you declare and use the variables in the go language.

If I am understanding this right, you are referring to the following piece of code on the page:

var message string
message = fmt.Sprintf("Hi, %v. Welcome!", name

This is another way of declaring variables and using them without using the ":=" operator. Also, it is mentioned that this is a long way of doing it just before the code block

@differentstuff
Copy link
Author

If I am understanding this right, you are referring to the following piece of code on the page:

Yes.
Under "5. Paste the following code into your greetings.go file and save the file. " they use the declaration with a colon ":=" but later it is used without colon.
I don't understand the difference.

[Please someone confirm if that's right]
If I first declare a variable as "existant", then I dont use the colon. I may "fill" it later or leave it empty.
If I want to declare and "fill" the variable at the same time, I need to use the colon ":" just before the equal sign ":="

@seankhliao
Copy link
Member

The tutorial is correct.

Unlike many projects, the Go project does not use GitHub Issues for general discussion or asking questions. GitHub Issues are used for tracking bugs and proposals only.

For questions please refer to https://github.com/golang/go/wiki/Questions

@differentstuff
Copy link
Author

differentstuff commented Mar 7, 2022

The tutorial is correct.

If you can't explain an answer you admit that you don't understand the topic or didn't read the question.
It is natural to explain an answer reasonably before blocking a legitimate request.
As long as this is not given, it may still be an error and my request is correct.

@ianlancetaylor
Copy link
Contributor

ianlancetaylor commented Mar 7, 2022

@differentstuff I'm sorry you feel disappointed. We've learned over the years that the GitHub issue tracker is a poor place for answering questions. The Go project has several active forums with more people who will respond faster and more interactively. So we direct people with questions to those forums, rather than the issue tracker. See https://go.dev/wiki/Questions. This has been a clearly better experience for most Go users. I'm sorry it doesn't feel that way in this instance.

In Go a := is used to declare and initialize a variable. A = is used to assign to an existing variable that is already declared, either through an earlier := or a var, or a function parameter.

@differentstuff
Copy link
Author

differentstuff commented Mar 7, 2022

In Go...

Thank you for the explanation. That confirms my question.

We've learned over the years...

I totally understand the decission. I don't criticize this part.
There's nothing wrong closing a request that's not correct; as I learned mine is.
Whereas it should be normal to explain "why". Or where the mistake was.
Just saying "you're wrong" doesn't help. "You're wrong, because you misunderstood something. The tutorial is correct." would at least give a hint why. (Even a simple "Yes" would have at least confirmed my doubts.)

@golang golang locked and limited conversation to collaborators Mar 7, 2023
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

5 participants