1

What does this statement mean in Go:

Student.bookMap=map[string][]*model.Books{}

Where Student is:

type Student struct{
    bookMap map[string][]*model.Books
}

and we have a model package

package model

type Books struct {
    bookName   string  `db:"Name"`
    bookAuthor string  `db:"Author"`
}

2 Answers 2

1

That statement is initializing the map Student.bookMap to an empty map (which has the following structure: key -> string, value -> slice of pointers of model.Books).

Sign up to request clarification or add additional context in comments.

Comments

0

It means the member bookMap of a struct Student contains a map which takes a string as a key, and an array (slice) of pointers to instances of model.Books as value.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.