Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/gohugoio/hugo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2019-06-02 12:11:46 +0300
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2020-09-29 18:48:07 +0300
commit97987e5c0254e35668dca7f89e67b79553e617c8 (patch)
tree3ea30314a22d25f8ffa0caad5db129fc977657b0 /common
parent111344113bf8c16ae45528d67ff408da15961727 (diff)
langs/i18n: Upgrade to go-i18n v2
Fixes #5242
Diffstat (limited to 'common')
-rw-r--r--common/hreflect/helpers.go36
1 files changed, 36 insertions, 0 deletions
diff --git a/common/hreflect/helpers.go b/common/hreflect/helpers.go
index db7b208b5..d936da19c 100644
--- a/common/hreflect/helpers.go
+++ b/common/hreflect/helpers.go
@@ -22,6 +22,42 @@ import (
"github.com/gohugoio/hugo/common/types"
)
+// TODO(bep) replace the private versions in /tpl with these.
+// IsInt returns whether the given kind is a number.
+func IsNumber(kind reflect.Kind) bool {
+ return IsInt(kind) || IsUint(kind) || IsFloat(kind)
+}
+
+// IsInt returns whether the given kind is an int.
+func IsInt(kind reflect.Kind) bool {
+ switch kind {
+ case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
+ return true
+ default:
+ return false
+ }
+}
+
+// IsUint returns whether the given kind is an uint.
+func IsUint(kind reflect.Kind) bool {
+ switch kind {
+ case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64:
+ return true
+ default:
+ return false
+ }
+}
+
+// IsFloat returns whether the given kind is a float.
+func IsFloat(kind reflect.Kind) bool {
+ switch kind {
+ case reflect.Float32, reflect.Float64:
+ return true
+ default:
+ return false
+ }
+}
+
// IsTruthful returns whether in represents a truthful value.
// See IsTruthfulValue
func IsTruthful(in interface{}) bool {