I am new to go and I'm trying to extract a bit of specific data (Employee.ID) from an array and insert it into another (new) array.
So far I've had no luck in doing so, the code I use is as follows:
package main
import (
"fmt"
)
type Employee struct {
ID int64
Name string
Department string
}
func main() {
employees := []Employee{{1, "Ram", "India"}, {2, "Criest", "Europe"}}
ids := []int64{}
for i, v := range employees {
fmt.Println(i, v)
}
}
In short, I want to extract ID from the employees
array and copy those to the ids
array. The size of employees
array is not fixed at any point in time.
Thanks for all your help.