Answer the question
In order to leave comments, you need to log in
How to access structure from structure function?
type T struct {
Count int
Func func(string) err
}
type T struct {
Count int
Func func(*T, string) err
}
Answer the question
In order to leave comments, you need to log in
Yes, there is no way you can access the struct unless you explicitly pass it to the function.
You are doing something weird, maybe you wanted to do this:
type T struct {
Count int
}
func (t *T) Func(s string) error {
t.Count // <- получение доступа к полю структуры
}
in go, the methods of structures are declared like this , and there access to the structure will be
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question