Delete struct with slice from map

I have a question for map deletion, when I delete User from the map, will the User object be GCed since SubID is slice and referred by User object?

Do I need to set SubID in User object to nil before deleting it from map to avoid mem leak?


type User struct {
  ID    int64   `json:"id"`
  Email string  `json:"email"`
  SubID []int64 `json:"sub_id"`
var emailToUserMap map[string]User

delete(emailToUserMap, email)

You don’t need to nil out the slice for it to be collected.