utils

package
v0.0.0-...-158c053 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2024 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateConfigFile

func CreateConfigFile() safego.Option[error]

CreateConfigFile creates the config file.

func CreateDir

func CreateDir(dir string) safego.Option[error]

CreateDir creates a directory.

func CreateFile

func CreateFile(path string) safego.Option[error]

CreateFile creates a file.

func DoesConfigFileExists

func DoesConfigFileExists() (bool, safego.Option[error])

DoesConfigFileExists checks if the config file exists. It returns true if the file exists, false otherwise.

func ExtractExpressions

func ExtractExpressions(str string, expr string) []string

ExtractExpressions extracts expressions from a string.

func GetConfigData

func GetConfigData() (types.Config, safego.Option[error])

GetConfigData extracts the database connection string from the config file.

func GetConfigFilePathBasedOnOS

func GetConfigFilePathBasedOnOS() (string, safego.Option[error])

GetConfigFilePathBasedOnOS returns the config file path based on the OS.

func GetDataDirBasedOnOS

func GetDataDirBasedOnOS() (string, safego.Option[error])

func GetTimestamp

func GetTimestamp() int64

GetTimestamp returns the current timestamp in nanoseconds.

func JsonifyQueryData

func JsonifyQueryData(rows *sql.Rows) []string

JsonifyQueryData converts the data from a sql query to json.

func Log

func Log(str ...string)

Log logs a string or more to the console.

func ParseHandleBars

func ParseHandleBars(template string, data map[string]any) (string, safego.Option[error])

ParseHandleBars parses a handlebars template with the given template string and data.

func ParseRequestBody

func ParseRequestBody(ctx *fiber.Ctx, body any)

ParseRequestBody parses the body of a request.

func PromptForDbConfig

func PromptForDbConfig(dbConfig *types.DbConfig) safego.Option[error]

PromptForDbConfig prompts the user for their database configuration. It returns a DbConfig and an error.

func ReadJSONFile

func ReadJSONFile(filePath string, valRef any) safego.Option[error]

ReadJSONFile reads a JSON file and unmarshals it into a value reference.

func WriteFile

func WriteFile(path string, data []byte) safego.Option[error]

WriteFile writes data to a file.

func WriteToJSONFile

func WriteToJSONFile(filePath string, content any) safego.Option[error]

WriteToJSONFile writes a value to a JSON file.

Types

This section is empty.

Jump to

Keyboard shortcuts

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