Skip to content

Hexdec Converter is a fast, efficient command-line utility for converting between hexadecimal and decimal number systems. Built with Go, it offers cross-platform support and easy installation.

License

jenish-rudani/hexdec-converter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Hexadecimal-Decimal Converter

This Go module provides command-line utilities for converting between hexadecimal and decimal numbers.

Table of Contents

Installation

  1. Clone the repository:
git clone https://github.com/jenish-rudani/hexdec-converter.git
cd hexdec-converter
  1. Build the binaries:
make
  1. Install the utilities to your system PATH:
make install

Note: The make install command may require sudo privileges on Linux and macOS. On Windows, you may need to run your terminal as Administrator.

Usage

After installation, you can use the utilities from anywhere in your terminal:

Convert hexadecimal to decimal:

h2d <hexadecimal number>

Convert decimal to hexadecimal:

d2h <decimal number>

Examples

Here are some examples of how to use the utilities:

  1. Hexadecimal to Decimal:

    $ h2d A
    10
    
    $ h2d FF
    255
    
    $ h2d 100
    256
  2. Decimal to Hexadecimal:

    $ d2h 10
    A
    
    $ d2h 255
    FF
    
    $ d2h 256
    100

Building

To build binaries for multiple platforms:

make

This will create binaries in the binary directory, organized by platform.

Testing

To run the unit and integration tests:

make test

This will run tests for the converter package and integration tests for the command-line tools.

Project Structure

hexdec-converter/
├── cmd/
│   ├── h2d/
│   │   └── main.go
│   └── d2h/
│       └── main.go
├── pkg/
│   └── converter/
│       ├── converter.go
│       └── converter_test.go
├── test/
│   └── integration_test.go
├── Makefile
├── go.mod
└── README.md
  • cmd/: Contains the main applications for h2d and d2h.
  • pkg/: Contains the core logic for conversion in the converter package.
  • test/: Contains integration tests for the command-line tools.

Development

Makefile Commands

The project includes a Makefile with the following commands:

  • make: Build the binaries for all supported platforms
  • make test: Run unit and integration tests
  • make clean: Remove all generated binaries
  • make info: Display usage information and examples
  • make install: Install the utilities to your system PATH

To view the usage information and examples in the terminal, run:

make info

This will display:

Hexadecimal-Decimal Converter
Usage:
  h2d <hexadecimal number>  - Convert hex to decimal
  d2h <decimal number>      - Convert decimal to hex

Examples:
  h2d FF  -> 255
  d2h 255 -> FF

Build:   make
Test:    make test
Clean:   make clean
Install: make install

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

GNU General Public License v3.0

See License file for more details

About

Hexdec Converter is a fast, efficient command-line utility for converting between hexadecimal and decimal number systems. Built with Go, it offers cross-platform support and easy installation.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published