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

Common variables declaration syntax #4

Open
lucasmenendez opened this issue Apr 9, 2018 · 0 comments
Open

Common variables declaration syntax #4

lucasmenendez opened this issue Apr 9, 2018 · 0 comments
Assignees
Labels
info Tips

Comments

@lucasmenendez
Copy link
Collaborator

Golang provides three syntaxes for the variable declaration:

  • The most comfortable way is foo := "foo" but with this syntax you probably makes mistakes like binary_address := []byte{0} (wallet.go:62) or s := "" (transaction.go:70).

  • Other way consists in using the keyword var to the memory allocation and waits for the compiler to infer the variable type from the right side of declaration: var foo = "foo". I think its better way that the first one because allows to the developer to allocate memory without occupying them.

  • The last way its an extended version of the second one that includes variable type: var foo string = "foo". This way forces the developer to write more code, but make it more legible (and it's my favorite way).

What do you think about it?

@lucasmenendez lucasmenendez added the bug Something isn't working label Apr 9, 2018
@lucasmenendez lucasmenendez added info Tips and removed bug Something isn't working labels May 9, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
info Tips
Projects
None yet
Development

No branches or pull requests

5 participants