Skip to content

Commit

Permalink
an updated commit message
Browse files Browse the repository at this point in the history
  • Loading branch information
Thiago Zilli authored and thiagozs committed Apr 9, 2024
1 parent 6ff83f6 commit 54142e9
Show file tree
Hide file tree
Showing 4 changed files with 390 additions and 44 deletions.
81 changes: 37 additions & 44 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,72 +1,65 @@
# XUtils - a Golang Toolkit for Development

# XUtils - A Comprehensive Golang Toolkit for Developers

## Introduction

A collection of tools designed to improve your day-to-day development tasks.
XUtils embodies a versatile collection of Golang tools crafted to streamline and enhance your development workflow. This toolkit is meticulously organized into specialized directories, each serving a distinct aspect of development needs, from data encryption and geographical computations to string manipulations and beyond.

### Toolkit Components:

- **aes**: Home to scripts for implementing the Advanced Encryption Standard (AES), this directory provides robust solutions for encrypting and securing your data, ensuring privacy and protection in your applications.

- **bools**: Contains utilities that extend the capabilities of boolean logic operations, offering advanced tools for intricate logical expressions and boolean algebra, crucial for decision-making logic in software development.

- **calc**: This segment offers a suite of calculators and mathematical tools, enabling complex calculations and numerical analysis, indispensable for applications requiring mathematical computations.

- **cep**: Dedicated to handling CEP (Postal Addressing Code in Brazil), this directory includes constants, validation, and parsing tools specifically designed for Brazilian postal codes, enhancing localization and geographic targeting.

- **cnpj**: Focuses on the validation and generation of CNPJ numbers, catering to Brazilian business entities' needs. These tools are essential for applications that require integration with Brazilian corporate registries.

* **aes**: This directory contains code or scripts related to the Advanced Encryption Standard (AES), a symmetric encryption algorithm used to secure data.
- **convs**: A hub for conversion utilities, facilitating seamless transitions between various data types and units, thereby simplifying data manipulation and enhancing interoperability across different systems.

* **bools**: This folder includes utilities or functions that operate on boolean values, such as logical operations or boolean algebra tools.
- **cpf**: Similar to the `cnpj` directory but tailored for individuals, offering scripts for CPF number validation and generation, crucial for applications processing Brazilian individual taxpayer information.

* **calc**: Short for "calculator," this directory houses programs or scripts that perform various mathematical calculations.
- **csv**: Specializes in processing Comma-Separated Values (CSV) files, equipped with readers, writers, and sample data, making it an invaluable resource for data import/export and analysis tasks.

* **cnpj**: Specific to Brazil's National Registry of Legal Entities (Cadastro Nacional da Pessoa Jurídica), this contains validation or generation scripts for CNPJ numbers.
- **email**: Provides libraries for comprehensive email handling, including sending, receiving, and validating email addresses, essential for communication and notification systems within applications.

* **convs**: Likely shorthand for "conversions," this folder contains code that handles the conversion between different data types or units.
- **examples**: This folder is a treasure trove of example scripts and code snippets, demonstrating the practical application of the XUtils toolkit, serving as a valuable resource for developers.

* **cpf**: Similar to `cnpj`, this directory relates to the Brazilian Individual Taxpayer Registry (Cadastro de Pessoas Físicas), with scripts for CPF number validation or generation.
- **files**: Contains utilities for file operations, such as reading, writing, and searching, addressing common file manipulation tasks in software projects.

* **csv**: Known for "Comma-Separated Values," this folder includes tools or scripts for processing CSV files, with a `data` subdirectory that may contain actual CSV files.
- **geo**: Offers tools for geographical data processing, including location validation and coordinates conversion, vital for mapping, navigation, and location-based services.

* **email**: This directory contains scripts or libraries for handling email operations, such as sending, receiving, or validating email addresses.
- **hash**: Equipped with functions for generating and verifying hash values, this directory is crucial for ensuring data integrity, secure password storage, and cryptographic operations.

* **examples**: Typically, this folder includes example scripts or code snippets demonstrating how to use the libraries or functions found in the other directories.
- **ip**: This collection of utilities is designed for IP address management, including validation and network calculations, fundamental for networking and cybersecurity applications.

* **geo**: This folder deals with geographical computations or data processing, such as location validation, coordinates conversion, or mapping functions.
- **phone**: Focuses on phone number processing, providing formatting and validation tools, essential for applications that require standardizing and validating international phone numbers.

* **hash**: This directory contains functions for generating or verifying hash values, used in cryptography, data integrity, and password storage.
- **rsa**: Contains RSA cryptographic code, facilitating secure data encryption and decryption using the RSA algorithm, key for secure communications and data protection.

* **ip**: This is a collection of utilities for handling IP addresses, including validation, conversion, or network calculations.
- **slices**: Offers utilities for manipulating Go slices, enhancing the ease and efficiency of working with this fundamental data structure in Go programming.

* **phone**: This directory is dedicated to phone number processing, such as formatting, validating, or extracting information from phone numbers.
- **strings**: This directory is rich in functions for string manipulation, enabling sophisticated text processing, parsing, and formatting, crucial for text-heavy applications and data processing tasks.

* **rsa**: Named after the Rivest-Shamir-Adleman algorithm, this folder contains cryptographic code related to RSA encryption and decryption.
- **structs**: Provides definitions and utilities for working with Go structs, aiding in the organization and manipulation of complex data types, enhancing code clarity and efficiency.

* **slices**: In programming, especially in languages like Go, slices are a data structure. This directory includes utilities for manipulating these structures.
- **xls**: Specializes in Excel spreadsheet processing, with tools for reading, writing, and manipulating `.xls` and `.xlsx` files, key for applications that interact with spreadsheet data.

* **strings**: This folder contains functions and utilities for string manipulation, such as formatting, parsing, or analyzing text data.
### Project Structure

* **structs**: In languages like Go, structs are a way of defining complex data types. This directory includes definitions and utilities for working with structs.
The project is structured with clarity and precision, ensuring each component is easily accessible and well-documented. The inclusion of test files (`*_test.go`) alongside each utility underscores the toolkit's reliability and readiness for production use.

* **xls**: This directory is related to Excel spreadsheet processing, with tools for reading, writing, or manipulating `xls` files. The `data` subdirectory might contain sample spreadsheets or data sets.
[Project directory structure omitted for brevity]

Each directory serves a specific purpose, reflecting the modular and organized structure of a well-designed software project.
## Commitment to Quality

## Project folders
Adhering to Semantic Versioning, XUtils ensures backward compatibility and clear communication through its versioning scheme. The project's dedication to quality and reliability is evident in its comprehensive documentation and structured testing approach.

```
├── aes
├── bools
├── calc
├── cnpj
├── convs
├── cpf
├── csv
│   └── data
├── email
├── examples
├── geo
├── hash
├── ip
├── phone
├── rsa
├── slices
├── strings
├── structs
└── xls
└── data
For detailed insights into our licensing terms and to explore the wealth of functionalities offered by XUtils, please refer to the LICENSE file and delve into the repository's extensive documentation.

```
Empower your development with XUtils - where efficiency meets innovation.

## Versioning and License

Expand Down
93 changes: 93 additions & 0 deletions files/files.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
package files

import (
"os"
"path/filepath"
)

type Files struct{}

func New() *Files {
return &Files{}
}

// SaveFile writes data to a file specified by filePath. If the file doesn't exist, it is created. If it exists, it's overwritten.
func (f *Files) SaveFile(filePath string, data []byte) error {
return os.WriteFile(filePath, data, 0644)
}

// OpenFile reads and returns the contents of the file specified by filePath.
func (f *Files) OpenFile(filePath string) ([]byte, error) {
return os.ReadFile(filePath)
}

// AppendFile appends data to a file specified by filePath. If the file doesn't exist, it's created.
func (f *Files) AppendFile(filePath string, data []byte) error {
file, err := os.OpenFile(filePath, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)
if err != nil {
return err
}
defer file.Close()

_, err = file.Write(data)
return err
}

// DirectoryExist checks if a specified directory exists.
func (f *Files) DirectoryExist(dirPath string) bool {
info, err := os.Stat(dirPath)
if err != nil {
return os.IsExist(err)
}
return info.IsDir()
}

// IsDirectory checks if the specified path is a directory.
func (f *Files) IsDirectory(path string) bool {
info, err := os.Stat(path)
if err != nil {
return false
}
return info.IsDir()
}

// IsFile checks if the specified path is a file.
func (f *Files) IsFile(path string) bool {
info, err := os.Stat(path)
if err != nil {
return false
}
return !info.IsDir()
}

// FileSearch searches for files recursively starting from rootDir and returns a slice of file paths that match the provided fileName.
func (f *Files) FileSearch(rootDir, fileName string) ([]string, error) {
var filesFound []string
err := filepath.Walk(rootDir, func(path string, info os.FileInfo, err error) error {
if err != nil {
return err // return error to stop the walk
}
if !info.IsDir() && info.Name() == fileName {
filesFound = append(filesFound, path)
}
return nil
})

return filesFound, err
}

// DirSearch searches for directories recursively starting from rootDir and returns a slice of directory paths that match the provided dirName.
func (f *Files) DirSearch(rootDir, dirName string) ([]string, error) {
var dirsFound []string
err := filepath.Walk(rootDir, func(path string, info os.FileInfo, err error) error {
if err != nil {
return err // return error to stop the walk
}
if info.IsDir() && info.Name() == dirName {
dirsFound = append(dirsFound, path)
}
return nil
})

return dirsFound, err
}
Loading

0 comments on commit 54142e9

Please sign in to comment.