utils

package
v0.0.0-...-68b20d9 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2023 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Overview

******************************************************************************

  • Copyright 2017 Dell Inc.
  • Copyright (c) 2019 Intel Corporation *
  • Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
  • in compliance with the License. You may obtain a copy of the License at *
  • http://www.apache.org/licenses/LICENSE-2.0 *
  • Unless required by applicable law or agreed to in writing, software distributed under the License
  • is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
  • or implied. See the License for the specific language governing permissions and limitations under
  • the License. ******************************************************************************

******************************************************************************

  • Copyright 2017 Dell Inc.
  • Copyright (c) 2019 Intel Corporation *
  • Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
  • in compliance with the License. You may obtain a copy of the License at *
  • http://www.apache.org/licenses/LICENSE-2.0 *
  • Unless required by applicable law or agreed to in writing, software distributed under the License
  • is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
  • or implied. See the License for the specific language governing permissions and limitations under
  • the License. ******************************************************************************

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AvailablePort

func AvailablePort(address *net.TCPAddr) (int, error)

func CheckFileValid

func CheckFileValid(fileName string) bool

检查文件名是有效-是否有/ \等

func CheckNetIface

func CheckNetIface(ethName string) bool

CheckNetIface 检查网卡

func CreateDirIfNotExist

func CreateDirIfNotExist(filePath string) error

func Decrypt

func Decrypt(crypted []byte, mac string) (origData []byte, err error)

func DecryptAuthPassword

func DecryptAuthPassword(encryptPassword string, saltKey string) (string, error)

DecryptAuthPassword 账号密码解密

func Encrypt

func Encrypt(src []byte, mac string) (crypted []byte, err error)

func EncryptAuthPassword

func EncryptAuthPassword(rawPassword string, saltKey string) (string, error)

EncryptAuthPassword 账号密码加密

func FilePathIsExist

func FilePathIsExist(path string) bool

func FormatDockerTime

func FormatDockerTime(value string) (*time.Time, error)

func FromContext

func FromContext(ctx context.Context, key string) string

FromContext allows for the retrieval of the specified key's value from the supplied Context. If the value is not found, an empty string is returned.

func GcmDecrypt

func GcmDecrypt(ciphertext []byte, key []byte) (plaintext []byte, err error)

使用aes gcm解密信息

func GcmEncrypt

func GcmEncrypt(plaintext []byte, key []byte) (ciphertext []byte, err error)

使用aes gcm加密信息

func GenUUID

func GenUUID() string

func GenerateDeviceSecret

func GenerateDeviceSecret(n int) string

func GenerateSaltKey

func GenerateSaltKey() string

func Get0ClockTimeStamp

func Get0ClockTimeStamp(d time.Time) int64

获取当天0时的时间戳

func GetAvailablePort

func GetAvailablePort(port string) (int, error)

获取系统可用的的端口号, 如果传入的端口号可用,那就直接返回

func GetLocalIP

func GetLocalIP() (ip string, err error)

func GetNowTimestamp

func GetNowTimestamp() int64

生成当前时间戳

func GetOutBoundIP

func GetOutBoundIP() (ip string, err error)

func GetPwdDir

func GetPwdDir() string

func InStringSlice

func InStringSlice(key string, keys []string) bool

func InterfaceToString

func InterfaceToString(value interface{}) string

func MakeTimestamp

func MakeTimestamp() int64

func NetIfaces

func NetIfaces() ([]string, error)

NetIfaces 获取网卡

func NetMacs

func NetMacs() ([]string, error)

func RandomNum

func RandomNum() string

func ReadJsonFile

func ReadJsonFile(filepath string) ([]byte, error)

func RemoveFileOrDir

func RemoveFileOrDir(path string) error

func SliceStringUnique

func SliceStringUnique(strings []string) []string

Types

This section is empty.

Jump to

Keyboard shortcuts

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