Home >Backend Development >Golang >Passing of reference type parameters in golang

Passing of reference type parameters in golang

王林
王林Original
2024-04-22 17:36:02393browse

In Go language, variable names are used directly when passing reference type parameters without pointers.

Passing of reference type parameters in golang

Transfer of reference type parameters in Go language

In Go language, function parameters can be value types or reference types. Value types make a copy when a function is called, while reference types pass a reference to the underlying data.

Passing reference type parameters

To pass reference type parameters, you only need to specify the variable name as a parameter, without using a pointer (*). For example:

type Book struct {

The above is the detailed content of Passing of reference type parameters in golang. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn