From 9f12059c8b173cdc76073a6bf3c97b10eb5ac367 Mon Sep 17 00:00:00 2001 From: Charles Iliya Krempeaux Date: Thu, 20 Jun 2019 21:57:03 -0700 Subject: [PATCH] renamed patternmatch.Pattern.MatchAndLoad() to patternmatch.Pattern.FindAndLoad() --- README.md | 2 +- bad_request.go | 2 +- doc.go | 4 ++-- example_compile_test.go | 2 +- pattern.go | 4 ++-- pattern_load.go | 2 +- pattern_load_test.go | 4 ++-- 7 files changed, 10 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 2008b0d..5ab3bd5 100644 --- a/README.md +++ b/README.md @@ -62,7 +62,7 @@ data := struct{ 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 { //@TODO diff --git a/bad_request.go b/bad_request.go index d64d374..31e3eaf 100644 --- a/bad_request.go +++ b/bad_request.go @@ -1,7 +1,7 @@ package pathmatch // 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. // // For example, maybe the uncompiled pattern passed to the pathmatch.Compile() func had diff --git a/doc.go b/doc.go index 3e137c0..31dd7f4 100644 --- a/doc.go +++ b/doc.go @@ -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). 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: @@ -43,7 +43,7 @@ Alternate Example Usage: 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 { //@TODO diff --git a/example_compile_test.go b/example_compile_test.go index 2d2832b..2d66835 100644 --- a/example_compile_test.go +++ b/example_compile_test.go @@ -22,7 +22,7 @@ func ExampleCompile() { var path = "/v1/users/123/contacts/e-mail" - matched, err := pattern.MatchAndLoad(path, &target) + matched, err := pattern.FindAndLoad(path, &target) if nil != err { fmt.Printf("ERROR: %s\n", err) return diff --git a/pattern.go b/pattern.go index 6c17f74..7e200d6 100644 --- a/pattern.go +++ b/pattern.go @@ -9,7 +9,7 @@ import ( // Pattern represents a compiled pattern. It is what is returned // 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: // @@ -35,7 +35,7 @@ import ( type Pattern interface { Glob() string Find(string, ...interface{}) (bool, error) - MatchAndLoad(string, interface{}) (bool, error) + FindAndLoad(string, interface{}) (bool, error) MatchNames() []string } diff --git a/pattern_load.go b/pattern_load.go index 85ab349..1978d64 100644 --- a/pattern_load.go +++ b/pattern_load.go @@ -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: Also, can the struct fields be put in here directly instead? diff --git a/pattern_load_test.go b/pattern_load_test.go index 10887f5..6e79692 100644 --- a/pattern_load_test.go +++ b/pattern_load_test.go @@ -8,7 +8,7 @@ import ( ) -func TestMatchAndLoad(t *testing.T) { +func TestFindAndLoad(t *testing.T) { tests := []struct{ 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) continue } else if !didMatch {