You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
go-library/vendor/github.com/gogf/gf/v2/util/gutil/gutil_default.go

28 lines
912 B

// Copyright GoFrame Author(https://goframe.org). All Rights Reserved.
//
// This Source Code Form is subject to the terms of the MIT License.
// If a copy of the MIT was not distributed with this file,
// You can obtain one at https://github.com/gogf/gf.
package gutil
// GetOrDefaultStr checks and returns value according whether parameter `param` available.
// It returns `param[0]` if it is available, or else it returns `def`.
func GetOrDefaultStr(def string, param ...string) string {
value := def
if len(param) > 0 && param[0] != "" {
value = param[0]
}
return value
}
// GetOrDefaultAny checks and returns value according whether parameter `param` available.
// It returns `param[0]` if it is available, or else it returns `def`.
func GetOrDefaultAny(def interface{}, param ...interface{}) interface{} {
value := def
if len(param) > 0 && param[0] != "" {
value = param[0]
}
return value
}