From 16d3399ee9b5afc6fdc80262e0a9765e86693a59 Mon Sep 17 00:00:00 2001 From: xdrm-brackets Date: Wed, 1 May 2019 11:28:55 +0200 Subject: [PATCH] ref 0: internal.checker renamed typecheck (no more internal) --- {internal/checker => typecheck}/builtin/any.go | 6 ++---- {internal/checker => typecheck}/builtin/bool.go | 4 ++-- {internal/checker => typecheck}/builtin/float64.go | 4 ++-- {internal/checker => typecheck}/builtin/string.go | 4 ++-- {internal/checker => typecheck}/set.go | 5 ++--- {internal/checker => typecheck}/type.go | 2 +- 6 files changed, 11 insertions(+), 14 deletions(-) rename {internal/checker => typecheck}/builtin/any.go (75%) rename {internal/checker => typecheck}/builtin/bool.go (78%) rename {internal/checker => typecheck}/builtin/float64.go (79%) rename {internal/checker => typecheck}/builtin/string.go (96%) rename {internal/checker => typecheck}/set.go (94%) rename {internal/checker => typecheck}/type.go (96%) diff --git a/internal/checker/builtin/any.go b/typecheck/builtin/any.go similarity index 75% rename from internal/checker/builtin/any.go rename to typecheck/builtin/any.go index 5f0352b..e56a886 100644 --- a/internal/checker/builtin/any.go +++ b/typecheck/builtin/any.go @@ -1,8 +1,6 @@ package builtin -import ( - "git.xdrm.io/go/aicra/internal/checker" -) +import "git.xdrm.io/go/aicra/typecheck" // Any is a permissive type checker type Any struct{} @@ -13,7 +11,7 @@ func NewAny() *Any { } // Checker returns the checker function -func (Any) Checker(typeName string) checker.Checker { +func (Any) Checker(typeName string) typecheck.Checker { // nothing if type not handled if typeName != "any" { return nil diff --git a/internal/checker/builtin/bool.go b/typecheck/builtin/bool.go similarity index 78% rename from internal/checker/builtin/bool.go rename to typecheck/builtin/bool.go index 90caa19..0fdc483 100644 --- a/internal/checker/builtin/bool.go +++ b/typecheck/builtin/bool.go @@ -1,6 +1,6 @@ package builtin -import "git.xdrm.io/go/aicra/internal/checker" +import "git.xdrm.io/go/aicra/typecheck" // Bool checks if a value is a boolean type Bool struct{} @@ -11,7 +11,7 @@ func NewBool() *Bool { } // Checker returns the checker function -func (Bool) Checker(typeName string) checker.Checker { +func (Bool) Checker(typeName string) typecheck.Checker { // nothing if type not handled if typeName != "bool" { return nil diff --git a/internal/checker/builtin/float64.go b/typecheck/builtin/float64.go similarity index 79% rename from internal/checker/builtin/float64.go rename to typecheck/builtin/float64.go index 9ff3dea..69c4948 100644 --- a/internal/checker/builtin/float64.go +++ b/typecheck/builtin/float64.go @@ -1,6 +1,6 @@ package builtin -import "git.xdrm.io/go/aicra/internal/checker" +import "git.xdrm.io/go/aicra/typecheck" // Float64 checks if a value is a float64 type Float64 struct{} @@ -11,7 +11,7 @@ func NewFloat64() *Float64 { } // Checker returns the checker function -func (Float64) Checker(typeName string) checker.Checker { +func (Float64) Checker(typeName string) typecheck.Checker { // nothing if type not handled if typeName != "float64" && typeName != "float" { return nil diff --git a/internal/checker/builtin/string.go b/typecheck/builtin/string.go similarity index 96% rename from internal/checker/builtin/string.go rename to typecheck/builtin/string.go index e82e5ea..5bc9fc2 100644 --- a/internal/checker/builtin/string.go +++ b/typecheck/builtin/string.go @@ -4,7 +4,7 @@ import ( "regexp" "strconv" - "git.xdrm.io/go/aicra/internal/checker" + "git.xdrm.io/go/aicra/typecheck" ) var fixedLengthRegex = regexp.MustCompile(`^string\((\d+))$`) @@ -19,7 +19,7 @@ func NewString() *String { } // Checker returns the checker function. Availables type names are : `string`, `string(length)` and `string(minLength, maxLength)`. -func (s String) Checker(typeName string) checker.Checker { +func (s String) Checker(typeName string) typecheck.Checker { isSimpleString := typeName == "string" fixedLengthMatches := fixedLengthRegex.FindStringSubmatch(typeName) variableLengthMatches := variableLengthRegex.FindStringSubmatch(typeName) diff --git a/internal/checker/set.go b/typecheck/set.go similarity index 94% rename from internal/checker/set.go rename to typecheck/set.go index c9d5090..b3a4a6f 100644 --- a/internal/checker/set.go +++ b/typecheck/set.go @@ -1,4 +1,4 @@ -package checker +package typecheck // Set of type checkers type Set struct { @@ -35,9 +35,8 @@ func (s *Set) Run(typeName string, value interface{}) error { // check value if checkerFunc(value) { return nil - } else { - return ErrDoesNotMatch } + return ErrDoesNotMatch } return ErrNoMatchingType diff --git a/internal/checker/type.go b/typecheck/type.go similarity index 96% rename from internal/checker/type.go rename to typecheck/type.go index e5b0747..a278091 100644 --- a/internal/checker/type.go +++ b/typecheck/type.go @@ -1,4 +1,4 @@ -package checker +package typecheck import "errors"