util

package
v0.0.0-...-0425f76 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2024 License: MIT Imports: 34 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeleteDir

func DeleteDir(dirName string) error

func ErrorJsonResponse

func ErrorJsonResponse(w http.ResponseWriter, status int, err error)

func ExistUserID

func ExistUserID(userID string) (bool, error)

func GenerateRandomScore

func GenerateRandomScore() float32

GenerateRandomScore generates a random score between 10.0000 ~ 99.9999

func GenerateRoomID

func GenerateRoomID(digits int, id string) (string, error)

func GenerateToken

func GenerateToken(id ulid.ULID) (string, error)

func GenerateUserUniqueID

func GenerateUserUniqueID() ulid.ULID

func GetEnv

func GetEnv(keys ...string) map[string]string

func GetEnvVar

func GetEnvVar(name string) string

func GetPhotoDescription

func GetPhotoDescription(photoUrl string) (descriptionJa []string, descriptionEn []string, err error)

func GetPhotoScore

func GetPhotoScore(gameMasterPhotoUrl string, playerPhotoUrl1 string, playerPhotoUrl2 string) (string, error)

func GetSubmitUnixSeconds

func GetSubmitUnixSeconds() int

func Init

func Init()

func LoadImage

func LoadImage(data []byte, fileType string) (image.Image, error)

Readable image formats: jpeg, png

func MakeDir

func MakeDir(dirName string) error

func ParseAndValidateUser

func ParseAndValidateUser(r *http.Request, validateFuncs ...func(user model.User) error) (model.User, error)

func ReadFormFile

func ReadFormFile(r *http.Request) ([]byte, error)

func Resize

func Resize(data []byte, maxHeight int) []byte

Aspect ratio preserving image resizing

func SanitizeString

func SanitizeString(input string) string

func SaveFile

func SaveFile(data []byte, path string, extension string) (string, error)

func SetUpRedisClient

func SetUpRedisClient() (context.Context, *redis.Client)

func SetUserTtl

func SetUserTtl(id ulid.ULID, ttl int) (string, error)

func SuccessJsonResponse

func SuccessJsonResponse(w http.ResponseWriter, status int, k string, v interface{})

func ValidateFileType

func ValidateFileType(r *http.Request) (string, error)

func ValidateIDRequired

func ValidateIDRequired(user model.User) error

Individual validation functions

func ValidateLangRequired

func ValidateLangRequired(user model.User) error

func ValidateMaxFileSize

func ValidateMaxFileSize(r *http.Request) error

func ValidateNameRequired

func ValidateNameRequired(user model.User) error

func ValidateRounds

func ValidateRounds(rounds string) bool

func ValidateStatusRequired

func ValidateStatusRequired(user model.User) error

func ValidateToken

func ValidateToken(tokenString string) (model.Token, error)

Types

This section is empty.

Jump to

Keyboard shortcuts

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