util

package
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 6, 2019 License: Apache-2.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

View Source
const ADMIN = "admin"

Variables

This section is empty.

Functions

func ApiResponse

func ApiResponse(status bool, info interface{}) map[string]interface{}

API响应信息

func AuthServerConfigFile

func AuthServerConfigFile() string

获取认证服务器的配置文件路径 2018-01-21 10:29

func Base64Decoding

func Base64Decoding(encodeString string) string

base64 解密 2018-01-21 18:40

func Base64Encoding

func Base64Encoding(str string) string

base64 加密 2018-01-21 18:39

func DeleteResponse

func DeleteResponse(err error, ctx context.Context, info string, username interface{}, cluster string, r gosql.Result) map[string]interface{}

删除时返回的响应数据

func GetClientIp

func GetClientIp(r *http.Request) string

获取客户端IP地址

func GetDate

func GetDate() string

获取时间

func GetMinTime

func GetMinTime(ctime string) string

2018-01-15 13:30 获取时间简单格式 util.GetMinTime("2018-01-15 14:40:49")

func GetReferer

func GetReferer(ctx context.Context) string

获取来源页面

func GetResponseResult

func GetResponseResult(err error, draw interface{}, returnData interface{}, totle interface{}) map[string]interface{}

2018-01-31 09:30 获取响应数据

func GetSelectOption

func GetSelectOption(name string, value string, title string) string

生成htmlselect的内容 2018-01-26 10:57

func GetSelectOptionName

func GetSelectOptionName(name string) string

生成htmlselect的内容 2018-02-07

func GetTableRows

func GetTableRows(table string)

2018-01-15

获取表的行数

func GetUri

func GetUri(ctx context.Context) string

获取来源页面

func GetUser

func GetUser(user interface{}) string

获取用户名

func HttpGetJson

func HttpGetJson(data string, url string) map[string]interface{}

2018-03-24 17:03 发送json请求

func Json2Yaml

func Json2Yaml(jsondata string) string

将json转换成yaml格式 2018-01-11 22:10

func LdapLoginAuth

func LdapLoginAuth(username string, passowrd string) (bool, error)

ldap登录验证 2018-01-19 09:59

func ListExistsInt

func ListExistsInt(arr []int, value int) bool

检查某个slice有某个数据 2018-01-14 14:26

func ListExistsString

func ListExistsString(arr []string, value string) bool

检查某个slice有某个数据 2018-02-05 21:06

func MakeImageTag

func MakeImageTag() string

2018-01-26 15:11 生成镜像tag按时间戳

func Md5String

func Md5String(str string) string

func Md5Uuid

func Md5Uuid() string

获取一个 MD5 穿

func MergerStruct

func MergerStruct(a interface{}, b interface{})

2018-02-14 10:22 将2个struct数据合并

func Namespace

func Namespace(appname string, resource string) string

获取namespace 2018-01-13 07:02

func ObjToString

func ObjToString(v interface{}) string

2018-01-20 9:30 将对象转成字符串

func ReadFile

func ReadFile(filename string) string

2018-01-21 07:39 读取文件内容

func RedisCacheClient

func RedisCacheClient(key string) (cache.Cache, error)

2018-01-20 redis写入数据

func RedisObj2Obj

func RedisObj2Obj(r interface{}, o interface{}) bool

2018-02-19 08:51 redis数据转换到对象中

func ReplaceTime

func ReplaceTime(t string) string

替换时间的T和Z

func ResponseMap

func ResponseMap(listResult interface{}, total interface{}, draw interface{}) map[string]interface{}

为表格提供的数据 return

func ResponseMapError

func ResponseMapError(err string) map[string]interface{}

响应错误信息

func SaveOperLog

func SaveOperLog(user interface{}, ctx context.Context, info string, clusterName string)

记录操作日志

func SaveResponse

func SaveResponse(err error, errmsg string) (map[string]interface{}, string)

保存成功提示信息

func SetPublicData

func SetPublicData(src interface{}, username string, obj interface{})

2018-02-04 将一些公共数据写好

func StringToInt

func StringToInt(v string) interface{}

将字符串转成int类型 2018-01-12 10:19

func StringsToJSON

func StringsToJSON(str string) string

func TimeToStamp

func TimeToStamp(ctime string) int64

时间转成时间戳 2018-01-15 13:40

func WriteLock

func WriteLock(key string, lock *Lock, timeout int64) bool

2018-02-12 21:01 避免频繁更新,加锁n秒后可操作

func Yaml2Json

func Yaml2Json(input []byte) (map[string]interface{}, error)

将yaml配置转换成json

Types

type Lock

type Lock struct {
	Lock sync.RWMutex
	Data map[string]interface{}
}

func (*Lock) Get

func (m *Lock) Get(key string) (interface{}, bool)

获取数据

func (*Lock) GetData

func (m *Lock) GetData() map[string]interface{}

func (*Lock) GetV

func (m *Lock) GetV(key string) interface{}

获取数据 2018-01-14 18:09

func (*Lock) GetVString

func (m *Lock) GetVString(key string) string

获取数据 2018-01-26 14:57

func (*Lock) Put

func (m *Lock) Put(k string, v interface{})

添加数据

func (*Lock) String

func (m *Lock) String() string

将对象转字符串 2018-01-13 7:33

type MapLock

type MapLock struct {
	Data map[string]interface{}
	Lock sync.RWMutex
}

func (*MapLock) Set

func (m *MapLock) Set(k string, v interface{})

type Param

type Param struct {
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL