0

I have a []*Cookie array, but how to get []Cookie array? I tried to use the * symbol but there was a syntax error.

Flimzy
  • 68,325
  • 15
  • 126
  • 165
Jinnrry
  • 355
  • 1
  • 3
  • 14

1 Answers1

7

Go does not provide an automatic conversion from slice of pointers to values to a slice of values.

Write a loop to do the conversion:

result := make([]Cookie, len(source))
for i := range result {
    result[i] = *source[i]
}
Bayta Darell
  • 101,448
  • 10
  • 207
  • 215