Closed SimFG closed 2 years ago
I'm not sure to understand your issue.
If a "for" loop looks better, why not using it?
2 cases not supported by "for" loop:
When I use some lo
method, I don't know how many parameters this function takes and what are the parameter types. If I don't look at the source implementation of this function, I will not be able to use this function. But if the parameter of a function is a function type, I only need to enter func
, goland will give a prompt, and then press Enter, I can complete the structure of the function, including which parameters are required, what types of parameters, and return results.
About the second case, "copy" problem: in a "for" loop, next value has the same memory address, so you cannot use it as a pointer. ForEach solves that issue.
I can't understand it. Can you can write an example to explain it. Thank you.
I can't understand it. Can you can write an example to explain it. Thank you.
https://github.com/golang/go/wiki/CommonMistakes#using-reference-to-loop-iterator-variable
About autocompletion in your code editor:
[T]
is of type string
, since it should be inferred from the names
variable.About the autocompletion settings, can you share me about this part of settings or plugins in the VSCode.
I use the following extension: https://marketplace.visualstudio.com/items?itemName=golang.Go
Thanks for your detailed answers.
For example, if I want to iterate over the
names
collection, I will typelo.ForEach(names, func...)
. I need to complete the generics type and look that the function need to fill those params in theGoLand
.I will spend more time filling relevant content than using a for statement. I don't know if there is a suitable plugin here to solve this problem.