Currently Im having something like this
main.go
gojob.NewJob("every 2 second", "pene", func() {
t := gojob.Custom("pene")
log.Println(t)
}, struct {
Id int
}{
1,
})
And my gojob package
func NewJob(t string, name string, c func(), v interface{}) {
e := strings.Split(t, " ")
job := process(e)
job.log = false
job.name = name
job.action = c
job.custom = v
jobs = append(jobs, job)
}
And
func Custom(name string) interface{} {
for i := range jobs {
if jobs[i].name != name {
continue
}
return jobs[i].custom
}
return nil
}
Thing is the function Im passing to NewJob is beeing executed every 2 seconds on a goroutine but I want to access the anonymous struct I passed... however when I try to access
t.Id
Im getting
t.Id undefined (type interface {} is interface with no methods)
However printing t gives me the expected result
{1}