Documentation
¶
Index ¶
- Variables
- func CompareFiles(hash string, fileA string, fileB string) (bool, error)
- func CompareFilesKey(hash string, keyA []byte, fileA string, keyB []byte, fileB string) (bool, error)
- func CountRows[T any](ctx context.Context, db *gorm.DB) (int64, error)
- func DeleteRowBy[T any](ctx context.Context, db *gorm.DB, key string, value any) error
- func DownloadDocument(ctx context.Context, url string, filePath string, client *http.Client, ...) error
- func DownloadDocumentReturnHash(ctx context.Context, url string, filePath string, client *http.Client, ...) (string, error)
- func GetColumn[T any, C any](ctx context.Context, odb *gorm.DB, columnName string) ([]C, error)
- func GetContent(ctx context.Context, url string, client *http.Client, req CustomReq) ([]byte, error)
- func GetEnv[T any](filename string) (*T, error)
- func GetMysql(user, password, host, port, dbName string) (string, string)
- func GetParsedContent(ctx context.Context, url string, client *http.Client, req CustomReq) (*html.Node, error)
- func GetPostgres(host, user, password, dbName, port string) (string, string)
- func GetRowBy[T any](ctx context.Context, db *gorm.DB, key string, value any) (*T, error)
- func GetRowsBy[T any](ctx context.Context, db *gorm.DB, key string, value any) ([]T, error)
- func GetSqlite(filePath string) (string, string)
- func GetTable[T any](ctx context.Context, db *gorm.DB, limit int) ([]T, error)
- func HashData(hash string, data []byte) (string, error)
- func HashFile(hash, filePath string) (string, error)
- func HashFileKey(hash string, key []byte, filePath string) (string, error)
- func HttpClient() *http.Client
- func LoadFile[S any](filePath string, limit int, validation bool) ([]S, error)
- func Migrate(ctx context.Context, odb *gorm.DB, models ...any) error
- func OnionClient() (*http.Client, error)
- func OpenDatabase(driver, dsn string) (*gorm.DB, error)
- func Unzip(ctx context.Context, source, destination string) error
- func UpdateRowBy[T any](ctx context.Context, db *gorm.DB, key string, value any, field string, ...) error
- type CustomReq
- type FactoryDB
- type FileParser
- type HashKeyFactory
Constants ¶
This section is empty.
Variables ¶
var FileRegistry = map[string]FileParser{ "json": json.Unmarshal, "yaml": yaml.Unmarshal, "toml": toml.Unmarshal, "xml": xml.Unmarshal, }
var Registry = map[string]func() hash.Hash{ "sha256": sha256.New, "sha384": sha512.New384, "sha512": sha512.New, "sha3-224": sha3.New224, "sha3-256": sha3.New256, "sha3-384": sha3.New384, "sha3-512": sha3.New512, "shake-128": func() hash.Hash { return &shakeAdapter{shake: sha3.NewShake128(), length: 32} }, "shake-256": func() hash.Hash { return &shakeAdapter{shake: sha3.NewShake256(), length: 64} }, }
var RegistryKey = map[string]HashKeyFactory{ "blake2b-256": func(key []byte) (hash.Hash, error) { return blake2b.New256(key) }, "blake2b-384": func(key []byte) (hash.Hash, error) { return blake2b.New384(key) }, "blake2b-512": func(key []byte) (hash.Hash, error) { return blake2b.New512(key) }, "blake2s-128": func(key []byte) (hash.Hash, error) { return blake2s.New128(key) }, "blake2s-256": func(key []byte) (hash.Hash, error) { return blake2s.New256(key) }, }
Legacy hash not supported yet.
Functions ¶
func CompareFiles ¶
compare two files
func CompareFilesKey ¶
func DeleteRowBy ¶ added in v1.1.0
Deletes rows where column `key` equals `value`
func DownloadDocument ¶ added in v0.2.3
func DownloadDocument(ctx context.Context, url string, filePath string, client *http.Client, req CustomReq) error
download a document give the url, the filepath where you want to store the document and the client
func DownloadDocumentReturnHash ¶
func DownloadDocumentReturnHash(ctx context.Context, url string, filePath string, client *http.Client, req CustomReq) (string, error)
download a document and return its hash value
func GetContent ¶
func GetContent(ctx context.Context, url string, client *http.Client, req CustomReq) ([]byte, error)
Get the body of a webpage. Give the url and it will return the html body
func GetEnv ¶ added in v1.2.0
GetEnv retrieve the env var in your .env file Give a struct, as a generic, with the following tag : `env:"VARIABLE_NAME"` beside each fields.
func GetParsedContent ¶
func GetParsedContent(ctx context.Context, url string, client *http.Client, req CustomReq) (*html.Node, error)
Get the body and parse it. The package net/html allow to parse a html body into nodes to easily retrieve every html tags
func GetPostgres ¶ added in v0.2.3
Get a postgres string with its associate dns for fast connection
func GetRowBy ¶ added in v1.1.0
GetRowBy returns the first record of type T where column `key` equals `value`.
func GetRowsBy ¶ added in v1.1.1
GetRowsBy returns every record of type T where column `key` equals `value`.
func GetSqlite ¶ added in v0.2.3
Get a mysql string with its associate dns for fast connection Specify either the path of your file or open it in memory
func GetTable ¶ added in v0.2.6
GetTable return every rows of the given table `T` Set the limit of rows with `limit`. Use -1 to get every rows
func HashFileKey ¶
hash a file with the given hash algorithm from the RegistryKey
func OpenDatabase ¶
Open a database with custom dsn or use function GetMysql(), GetPostgres() anb GetSqlite()