问题
I am defined a function using pointer, like the following
func concat(head1, head2 *Node) Node {
}
and pass in pointer. but I am wondering if Go supports pass by reference like C++ which I could use like the following
func concat(head1, head2 &Node) Node
回答1:
The Go Programming Language Specification
Calls
In a function call, the function value and arguments are evaluated in the usual order. After they are evaluated, the parameters of the call are passed by value to the function and the called function begins execution. The return parameters of the function are passed by value back to the calling function when the function returns.
No. Parameters are passed by value.
来源:https://stackoverflow.com/questions/47340934/is-there-pass-by-referencec-in-go