For example:
1: var I * int light this way, you will know it is a pointer to nil, pointing to the memory address is 0, I==nil, use it to call a method, assignment, are wrong, because the go in 0-255 memory address is the retention system, does not allow for any operation, do you want to know the null pointer!=nil, only the pointer type of dynamic and dynamic value is empty, only equal to nil, null pointer is dynamic value is empty, dynamic type is not null, then it is!=nil, it is likely to go wrong in be used actually,
2: the for k, v:=range t, t you know is just a copy a copy of the v just duplicate values at a time, will not change the address, so don't use & amp; V or take forever to the address of the last cycle v,
3: slice, for example, you use from the array s [I:] j to intercept generate slice, slice the bottom in a while might actually be an array, and the original array is Shared, so you changed slice an element value, the value of an element corresponding to the original array is also changed,
4: slice, for example, to append elements, plus more than capacity, will generate a new memory address section, if you are the original section in the main, append in a function, not return a new section, you will happen in the main old section will not have any change,
5: for example, a function func test () r int {
Defer func () {
.
} ()
The return of 6
}
Return r=6 is not atomic operations
It can be decomposed into three step
A: r=6
2: perform the defer
Three: empty return
.
Too many, so don't be so quick to research framework, research code, others have any free time to play good foundation first, or make something, once there is a problem, it's difficult to find the reason, I have it, a go exe program service, always run a few days to collapse, the last for a long time didn't grasp the good thing is basis,
CodePudding user response:
Go on fire for a moment, then no then
CodePudding user response: