A simple command-line banking application built in Go that handles basic loan management and account operations
- Create and manage bank accounts
- Check loan status and eligibility
- Process loan applications up to 5000 token
- Track and process loan repayments
- Account management and deletion
- Account number lookup by first name
- Phone number validation
- Go 1.19 or higher
- Make (for using the Makefile)
- Clone the respository
git clone https://github.com/Ng1n3/go-loan-app cd go-loan-bank
- Install dependencies
go mod download
├── account/
│ └── account.go # Account structure and methods
├── fileops/
│ └── fileops.go # File operations for data persistence
├── menu/
│ └── menu.go # CLI menu and user interaction
├── main.go # Application entry point
└── Makefile # Build and run automation
Use the Makefile to build and run the application:
make run
This will:
- Format the code
- Run go vet
- Build the binary
- Execute the program
The application presents a CLI menu with the following options:
- Create an Account
- Check Loan Status
- Get a Loan
- Repay Loan
- Close an Account
- Check account number
- Exit
When creating an account, you'll need to provide:
- First name
- Last name
- Phone number (must be exactly 10 digits)
The system will automatically:
- Generate a unique 4-digit account number
- Set initial loan amount available to 5000
- Set loan status to false
- Initialize loan counter and current loan amount
- Maximum initial loan amount: 5000 tokens
- Loans are tracked per account
- Multiple loans are not allowed (must repay current loan first)
- Partial repayments are supported
Account data is stored in account.json
file, which maintains:
- Personal information (name, phone number)
- Account details (account number, creation date)
- Loan information (status, available amount, current loan)
The application handles various error cases:
- Invalid phone numbers
- Empty required fields
- Non-existent accounts
- Invalid loan amounts
- Outstanding loan checks
- github.com/Pallinder/go-randomdata: For generating random account numbers
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add some amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
- Thanks to the Go community for the excellent standard library
- The randomdata package for account number generation