utils

package
v0.7.4 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2022 License: AGPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Config
	DATBASE_VERSION     = "database_version"
	TITLE_CONF          = "title"
	FLAG_PREFIX_CONF    = "flag_prefix"
	FLAG_SUFFIX_CONF    = "flag_suffix"
	ANIMATE_ASTEROID    = "animate_asteroid"
	SHOW_OTHERS_GAMEBOX = "show_others_gamebox"
	DEFAULT_LANGUAGE    = "default_language"

	BOOLEAN_TRUE  = "true"
	BOOLEAN_FALSE = "false"
)
View Source
const (
	// Config type
	STRING = iota
	BOOLEAN
	SELECT
)

Variables

View Source
var (
	VERSION    string
	COMMIT_SHA string
	BUILD_TIME string
)

These variable will be assigned in CI.

Functions

func AddSalt

func AddSalt(input string) string

AddSalt uses the config salt as key to HmacSha1Encode.

func CheckPassword

func CheckPassword(inputPassword string, realPassword string) bool

CheckPassword adds salt and check the password.

func CompareVersion

func CompareVersion(v1 string, v2 string) bool

CompareVersion used to compare the cardinal version.

func FileIsExist

func FileIsExist(path string) bool

FileIsExist check the file or folder existed.

func FileSize

func FileSize(size int64) string

FileSize returns the formatter text of the giving size.

func GenerateToken

func GenerateToken() string

GenerateToken returns UUID v4 string.

func HmacSha1Encode

func HmacSha1Encode(input string, key string) string

HmacSha1Encode HMAC SHA1 encode

func InputString

func InputString(str *string, hint string)

InputString used in the install.go for the config file guide.

func MakeErrJSON

func MakeErrJSON(httpStatusCode int, errCode int, msg interface{}) (int, interface{})

MakeErrJSON makes the error response JSON for gin.

func MakeSuccessJSON

func MakeSuccessJSON(data interface{}) (int, interface{})

MakeSuccessJSON makes the successful response JSON for gin.

func SSHExecute

func SSHExecute(ip string, port string, user string, password string, command string) (string, error)

func Sha1Encode

func Sha1Encode(input string) string

Sha1Encode Sha1 encode input string.

Types

This section is empty.

Jump to

Keyboard shortcuts

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