M
M
Michail Wowtschuk2017-03-31 00:53:17
go
Michail Wowtschuk, 2017-03-31 00:53:17

How to pass a pointer to a structure to a function?

It is necessary to pass a pointer to a structure to a function, I kind of figured out how to do it, but I don’t know what internal type the struct has, should I substitute it in *Type?
package main
import "fmt"
func out(k *Type) {
fmt.Println(k)
}
func main() {
type Data struct{ Title string }
D := Data{"Title"}
out(&D)
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dasha Tsiklauri, 2017-03-31
@dasha_programmist

func out(k *Data) {
fmt.Println(k)
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question