package kmb import ( "strings" query "github.com/tgckpg/golifehk/query" ) func Query( lang string, message string ) query.IQueryResult { var qo *query.QueryObject var err error qr := QueryResult{ Lang: lang } routeStops, err := getRouteStops() if err != nil { qr.Error = err goto qrReturn } qo, err = query.Parse( strings.ToUpper( message ), routeStops ) if err != nil { qr.Error = err goto qrReturn } qr.Query = qo if 0 < len( *qo.Results ) && 1 < len( *qo.SearchTerms ) { rSchedules := map[*RouteStop] *[] *Schedule{} for _, item := range *qo.Results { var r *RouteStop r = any( item ).( *RouteStop ) schedules, err := getSchedule( r ) if err != nil { qr.Error = err break } rSchedules[r] = schedules } qr.Schedules = &rSchedules } qrReturn: var iqr query.IQueryResult iqr = &qr return iqr }