mirror of
https://github.com/moonD4rk/HackBrowserData.git
synced 2026-05-19 18:58:03 +02:00
feat: rename browser layout and add generics util function
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
package fileutil
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"os"
|
||||
)
|
||||
|
||||
// FileExists checks if the file exists in the provided path
|
||||
func FileExists(filename string) bool {
|
||||
info, err := os.Stat(filename)
|
||||
if os.IsNotExist(err) {
|
||||
return false
|
||||
}
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
return !info.IsDir()
|
||||
}
|
||||
|
||||
// FolderExists checks if the folder exists
|
||||
func FolderExists(foldername string) bool {
|
||||
info, err := os.Stat(foldername)
|
||||
if os.IsNotExist(err) {
|
||||
return false
|
||||
}
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
return info.IsDir()
|
||||
}
|
||||
|
||||
// ReadFile reads the file from the provided path
|
||||
func ReadFile(filename string) (string, error) {
|
||||
s, err := ioutil.ReadFile(filename)
|
||||
return string(s), err
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package typeutil
|
||||
|
||||
// Keys returns a slice of the keys of the map. based with go 1.18 generics
|
||||
func Keys[K comparable, V any](m map[K]V) []K {
|
||||
r := make([]K, 0, len(m))
|
||||
for k := range m {
|
||||
r = append(r, k)
|
||||
}
|
||||
return r
|
||||
}
|
||||
@@ -53,11 +53,6 @@ func TimeEpochFormat(epoch int64) time.Time {
|
||||
return t
|
||||
}
|
||||
|
||||
func ReadFile(filename string) (string, error) {
|
||||
s, err := ioutil.ReadFile(filename)
|
||||
return string(s), err
|
||||
}
|
||||
|
||||
func WriteFile(filename string, data []byte) error {
|
||||
err := ioutil.WriteFile(filename, data, 0644)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user