I need to send a map to a function declared in a imported package, and keep getting this error:
./main.go:21: cannot use m (type map[string]ticket) as type map[string]some_package.ticket in function argument
This is the code of main.go in golang GOPATH folder:
package main
import (
"time"
sp "./some_package"
)
type ticket struct {
Timestamp int64
Identification_number int
}
var m map[string]ticket
func main() {
humans := 10
m = make(map[string]ticket)
m["ticket1"] = ticket{time.Now().Unix(), 1234}
sp_ := sp.New(humans)
sp_.SetTicket(m)
}
And this is the code of some_package.go in /some_package in golang GOPATH folder:
package some_package
type park struct{
card map[string]ticket
people int
}
type ticket struct {
Timestamp int64
Identification_number int
}
func (p *park) SetTicket(m map[string]ticket)(){
}
func New(humans int)(p *park){
p.card = make(map[string]ticket)
p.people = humans
return p
}
How should I pass the value of the map to the imported package function or get the map value inside the function from the parent package? Is this even possible or is there a workaround?