Documentation
¶
Index ¶
- Constants
- 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 DownloadDocument(url string, filePath string, client *http.Client) error
- func DownloadDocumentReturnHash(url string, filePath string, client *http.Client) (string, error)
- func GetBy[T any](odb *gorm.DB, key string, value string) (*T, error)
- func GetContent(url string, client *http.Client) ([]byte, error)
- func GetMysql(user string, password string, host string, port string, dbName string) (string, string)
- func GetParsedContent(url string, client *http.Client) (*html.Node, error)
- func GetPostgres(host string, user string, password string, dbName string, port int, ...) (string, string)
- func GetSqlite(filePath string) (string, string)
- func GetTable[T any](odb *gorm.DB) ([]*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(odb *gorm.DB, models ...any) error
- func OnionClient() (*http.Client, error)
- func OpenEnv(tags ...string) []string
- func OpenEnvFilenames(filenames []string, tags ...string) []string
- func OpenSqliteDatabase(dbPath string) (*gorm.DB, error)
- func UpdateTable[T any](odb *gorm.DB, key string, value string, newColumn string, newValue string) (*T, error)
- type FileParser
- type HashKeyFactory
Constants ¶
View Source
const ( KB = 1024 MB = KB * 1024 )
Variables ¶
View Source
var FileRegistry = map[string]FileParser{ "json": json.Unmarshal, "yaml": yaml.Unmarshal, "toml": toml.Unmarshal, "xml": xml.Unmarshal, }
View Source
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} }, }
View Source
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 DownloadDocument ¶ added in v0.2.3
download a document give the url, the filepath where you want to store the document and the client
func DownloadDocumentReturnHash ¶
download a document and return its hash value
func GetContent ¶
Get the body of a webpage. Give the url and it will return the html body
func GetMysql ¶ added in v0.2.3
func GetMysql(user string, password string, host string, port string, dbName string) (string, string)
Todo
func GetParsedContent ¶
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
func OpenEnvFilenames ¶
Merge several .env files and Return results in a slice of string
Types ¶
type FileParser ¶ added in v0.2.5
Click to show internal directories.
Click to hide internal directories.