utils

package
v0.0.104 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2025 License: 0BSD Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TRACE logLevelValue = iota
	DEBUG
	INFO
	WARN
	ERROR
)

Variables

View Source
var (
	DataDir = "data"
)
View Source
var Logger = ProvideLogger(os.Getenv("LOG_LEVEL"))

Functions

func AnalyzeCode added in v0.0.56

func AnalyzeCode(dir string)

func Close added in v0.0.55

func Close(r Closable)

func CollectBuildTags added in v0.0.68

func CollectBuildTags(dir string) ([]string, error)

func DoesMatchSaltedHash added in v0.0.45

func DoesMatchSaltedHash(clearText, saltedHash string) bool

func Execute added in v0.0.45

func Execute(commandStr string)

func ExecuteShellCommand added in v0.0.45

func ExecuteShellCommand(shellCommand string) error

func FindDir added in v0.0.49

func FindDir(dirName string) string

func GenerateCookie added in v0.0.22

func GenerateCookie() (*http.Cookie, error)

func GetCorsDisablingHandler added in v0.0.21

func GetCorsDisablingHandler(next http.Handler) http.Handler

GetCorsDisablingHandler This is necessary to allow cross-origin requests.

func GetErrMsg

func GetErrMsg(actualStatusCode int, respBodyMsg string) string

func GetLogLevel added in v0.0.68

func GetLogLevel() string

func GetTimeInSevenDays added in v0.0.93

func GetTimeInSevenDays() time.Time

func Hash added in v0.0.23

func Hash(clearText string) (string, error)

func RemoveDir added in v0.0.57

func RemoveDir(path string)

func RunMigrations added in v0.0.50

func RunMigrations(migrationsDir, host, port string)

func SaltAndHash added in v0.0.23

func SaltAndHash(clearText string) (string, error)

func SendJsonResponse

func SendJsonResponse(w http.ResponseWriter, data interface{})

func SetCookieHeaders added in v0.0.35

func SetCookieHeaders(req *http.Request, c *ComponentClient)

func SetHideCallerInLogs added in v0.0.68

func SetHideCallerInLogs(hide bool)

func UnpackResponse added in v0.0.32

func UnpackResponse[T any](object interface{}) (*T, error)

func UnzipToTempDir added in v0.0.42

func UnzipToTempDir(zipBytes []byte) (string, error)

UnzipToTempDir unzips the given zip bytes to a temporary directory and returns the path to the directory.

func WaitForPostgresDb added in v0.0.51

func WaitForPostgresDb(host, port string) (*sql.DB, error)

func ZipDirectoryToBytes added in v0.0.30

func ZipDirectoryToBytes(dirPath string) ([]byte, error)

Types

type Closable added in v0.0.55

type Closable interface {
	Close() error
}

type ComponentClient

type ComponentClient struct {
	Cookie            *http.Cookie
	SetCookieHeader   bool
	RootUrl           string
	Origin            string
	VerifyCertificate bool
}

func (*ComponentClient) DoRequest

func (c *ComponentClient) DoRequest(path string, payload interface{}) ([]byte, error)

func (*ComponentClient) DoRequestWithFullResponse

func (c *ComponentClient) DoRequestWithFullResponse(path string, payload interface{}) (*http.Response, error)

type LoggerType added in v0.0.68

type LoggerType interface {
	Trace(message string, v ...any)
	Debug(message string, v ...any)
	Info(message string, v ...any)
	Warn(message string, v ...any)
	Error(message string, v ...any)
	Fatal(message string, v ...any)
}

func ProvideLogger added in v0.0.68

func ProvideLogger(logLevel string) LoggerType

Jump to

Keyboard shortcuts

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