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
diff options
context:
space:
mode:
Diffstat (limited to 'common/types/convert.go')
-rw-r--r--common/types/convert.go14
1 files changed, 7 insertions, 7 deletions
diff --git a/common/types/convert.go b/common/types/convert.go
index 0560eda0d..fbeab5b91 100644
--- a/common/types/convert.go
+++ b/common/types/convert.go
@@ -25,13 +25,13 @@ import (
// ToDuration converts v to time.Duration.
// See ToDurationE if you need to handle errors.
-func ToDuration(v interface{}) time.Duration {
+func ToDuration(v any) time.Duration {
d, _ := ToDurationE(v)
return d
}
// ToDurationE converts v to time.Duration.
-func ToDurationE(v interface{}) (time.Duration, error) {
+func ToDurationE(v any) (time.Duration, error) {
if n := cast.ToInt(v); n > 0 {
return time.Duration(n) * time.Millisecond, nil
}
@@ -44,14 +44,14 @@ func ToDurationE(v interface{}) (time.Duration, error) {
// ToStringSlicePreserveString is the same as ToStringSlicePreserveStringE,
// but it never fails.
-func ToStringSlicePreserveString(v interface{}) []string {
+func ToStringSlicePreserveString(v any) []string {
vv, _ := ToStringSlicePreserveStringE(v)
return vv
}
// ToStringSlicePreserveStringE converts v to a string slice.
// If v is a string, it will be wrapped in a string slice.
-func ToStringSlicePreserveStringE(v interface{}) ([]string, error) {
+func ToStringSlicePreserveStringE(v any) ([]string, error) {
if v == nil {
return nil, nil
}
@@ -86,7 +86,7 @@ func ToStringSlicePreserveStringE(v interface{}) ([]string, error) {
// TypeToString converts v to a string if it's a valid string type.
// Note that this will not try to convert numeric values etc.,
// use ToString for that.
-func TypeToString(v interface{}) (string, bool) {
+func TypeToString(v any) (string, bool) {
switch s := v.(type) {
case string:
return s, true
@@ -110,13 +110,13 @@ func TypeToString(v interface{}) (string, bool) {
}
// ToString converts v to a string.
-func ToString(v interface{}) string {
+func ToString(v any) string {
s, _ := ToStringE(v)
return s
}
// ToStringE converts v to a string.
-func ToStringE(v interface{}) (string, error) {
+func ToStringE(v any) (string, error) {
if s, ok := TypeToString(v); ok {
return s, nil
}