package pathmatch import ( "errors" "fmt" "reflect" "strings" ) var ( errExpectedAPointerToAStruct = newUnsupportedArgumentType("Expected a pointer to a struct, but wasn't.") ) // FindAndLoad compares ‘path’ against its (compiled) pattern template; if it matches // it loads the matches into ‘dest’, and then returns true. // // ‘dest’ can be a pointer struct, or a pointer to a []string. // // Find may set some, or all of the items or fields in ‘dest’ even if it returns false, and even if it returns an error. func (pattern *Pattern) FindAndLoad(path string, dest interface{}) (bool, error) { if nil == pattern { return false, errNilReceiver } pattern.mutex.RLock() defer pattern.mutex.RUnlock() //@TODO: Is it a good idea to be dynamically creating this? //@TODO: Also, can the struct fields be put in here directly instead? args := []interface{}{} numNames := len(pattern.MatchNames()) for i:=0; i