renamed patternmatch.Pattern.MatchAndLoad() to patternmatch.Pattern.FindAndLoad()

master
Charles Iliya Krempeaux 2019-06-20 21:57:03 -07:00
parent 3ad6c17e07
commit 9f12059c8b
7 changed files with 10 additions and 10 deletions

View File

@ -62,7 +62,7 @@ data := struct{
VehicleId string `match:"vehicle_id"` VehicleId string `match:"vehicle_id"`
}{} }{}
didMatch, err := pattern.MatchAndLoad("/users/bMM_kJFMEV/vehicles/o_bcU.RZGK", &data) didMatch, err := pattern.FindAndLoad("/users/bMM_kJFMEV/vehicles/o_bcU.RZGK", &data)
if nil != err { if nil != err {
//@TODO //@TODO

View File

@ -1,7 +1,7 @@
package pathmatch package pathmatch
// BadRequest is used to represent one of the types of errors that could be returned when // BadRequest is used to represent one of the types of errors that could be returned when
// calling the pathmatch.Compile func, the pathmatch.Pattern.Match method, or the pathmatch.Pattern.MatchAndLoad // calling the pathmatch.Compile func, the pathmatch.Pattern.Match method, or the pathmatch.Pattern.FindAndLoad
// method. The meaning of this type of error is that the problem was due to something whomever called the func or method did. // method. The meaning of this type of error is that the problem was due to something whomever called the func or method did.
// //
// For example, maybe the uncompiled pattern passed to the pathmatch.Compile() func had // For example, maybe the uncompiled pattern passed to the pathmatch.Compile() func had

4
doc.go
View File

@ -4,7 +4,7 @@ Package pathmatch provides pattern matching for paths.
For example, a path could be a file system path, or a path could be a path from a URL (such as an HTTP or HTTPS based URL). For example, a path could be a file system path, or a path could be a path from a URL (such as an HTTP or HTTPS based URL).
The matches can be loaded into variables (when using pathmatch.Find()); The matches can be loaded into variables (when using pathmatch.Find());
or can be loaded into a struct (when using pathmatch.Pattern.MatchAndLoad()). or can be loaded into a struct (when using pathmatch.Pattern.FindAndLoad()).
Example Usage: Example Usage:
@ -43,7 +43,7 @@ Alternate Example Usage:
VehicleId string `match:"vehicle_id"` VehicleId string `match:"vehicle_id"`
}{} }{}
didMatch, err := pattern.MatchAndLoad("/users/bMM_kJFMEV/vehicles/o_bcU.RZGK", &data) didMatch, err := pattern.FindAndLoad("/users/bMM_kJFMEV/vehicles/o_bcU.RZGK", &data)
if nil != err { if nil != err {
//@TODO //@TODO

View File

@ -22,7 +22,7 @@ func ExampleCompile() {
var path = "/v1/users/123/contacts/e-mail" var path = "/v1/users/123/contacts/e-mail"
matched, err := pattern.MatchAndLoad(path, &target) matched, err := pattern.FindAndLoad(path, &target)
if nil != err { if nil != err {
fmt.Printf("ERROR: %s\n", err) fmt.Printf("ERROR: %s\n", err)
return return

View File

@ -9,7 +9,7 @@ import (
// Pattern represents a compiled pattern. It is what is returned // Pattern represents a compiled pattern. It is what is returned
// from calling either the Compile to MustCompile funcs. // from calling either the Compile to MustCompile funcs.
// //
// Pattern provides the Match, MatchAndLoad, and MatchNames methods. // Pattern provides the Match, FindAndLoad, and MatchNames methods.
// //
// Example Usage: // Example Usage:
// //
@ -35,7 +35,7 @@ import (
type Pattern interface { type Pattern interface {
Glob() string Glob() string
Find(string, ...interface{}) (bool, error) Find(string, ...interface{}) (bool, error)
MatchAndLoad(string, interface{}) (bool, error) FindAndLoad(string, interface{}) (bool, error)
MatchNames() []string MatchNames() []string
} }

View File

@ -14,7 +14,7 @@ var (
) )
func (pattern *internalPattern) MatchAndLoad(path string, strct interface{}) (bool, error) { func (pattern *internalPattern) FindAndLoad(path string, strct interface{}) (bool, error) {
//@TODO: Is it a good idea to be dynamically creating this? //@TODO: Is it a good idea to be dynamically creating this?
//@TODO: Also, can the struct fields be put in here directly instead? //@TODO: Also, can the struct fields be put in here directly instead?

View File

@ -8,7 +8,7 @@ import (
) )
func TestMatchAndLoad(t *testing.T) { func TestFindAndLoad(t *testing.T) {
tests := []struct{ tests := []struct{
Pattern Pattern Pattern Pattern
@ -144,7 +144,7 @@ func TestMatchAndLoad(t *testing.T) {
} }
} }
if didMatch, err := test.Pattern.MatchAndLoad(test.Path, test.StructPtr); nil != err { if didMatch, err := test.Pattern.FindAndLoad(test.Path, test.StructPtr); nil != err {
t.Errorf("For test #%d, did not expected an error, but actually got one: %v", testNumber, err) t.Errorf("For test #%d, did not expected an error, but actually got one: %v", testNumber, err)
continue continue
} else if !didMatch { } else if !didMatch {