Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Git
.git
.gitignore

# Documentation
*.md
!README.md
LICENSE

# IDE
.vscode
.idea
*.swp
*.swo
*~

# Build artifacts
expense-tracker
*.test
*.out
coverage.out
coverage.html

# Data
expenses.json
data/
*.csv

# OS
.DS_Store
Thumbs.db

# CI/CD
.github

# Docker
Dockerfile
docker-compose.yml
.dockerignore
70 changes: 70 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: CI

on:
push:
branches: [ main, master ]
pull_request:
branches: [ main, master ]

jobs:
build:
name: Build and Test
runs-on: ubuntu-latest
strategy:
matrix:
go-version: ['1.21', '1.22', '1.23']

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go-version }}

- name: Verify dependencies
run: go mod verify

- name: Build
run: go build -v ./cmd/expense-tracker

- name: Run tests
run: go test -v -race -coverprofile=coverage.out ./...

- name: Upload coverage to Codecov
if: matrix.go-version == '1.23'
uses: codecov/codecov-action@v3
with:
file: ./coverage.out
flags: unittests
name: codecov-umbrella

lint:
name: Lint
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.23'

- name: Run golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: latest

security:
name: Security Scan
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Run Gosec Security Scanner
uses: securego/gosec@master
with:
args: './...'
21 changes: 20 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
# If you prefer the allow list template instead of the deny list, see community template:
# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore
#

# Binaries for programs and plugins
*.exe
*.exe~
*.dll
*.so
*.dylib
expense-tracker

# Test binary, built with `go test -c`
*.test

# Output of the go coverage tool, specifically when used with LiteIDE
*.out
coverage.out
coverage.html

# Dependency directories (remove the comment below to include it)
# vendor/
Expand All @@ -23,3 +26,19 @@ go.work.sum

# env file
.env

# Application data
expenses.json
*.csv
data/

# IDE specific files
.vscode/
.idea/
*.swp
*.swo
*~

# OS specific files
.DS_Store
Thumbs.db
112 changes: 112 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
run:
timeout: 5m
tests: true
modules-download-mode: readonly

linters:
enable:
- errcheck # Check for unchecked errors
- gosimple # Simplify code
- govet # Vet examines Go source code
- ineffassign # Detect ineffectual assignments
- staticcheck # Staticcheck is a go vet on steroids
- unused # Check for unused constants, variables, functions and types
- gofmt # Check whether code was gofmt-ed
- goimports # Check import statements are formatted
- misspell # Finds commonly misspelled English words
- unconvert # Remove unnecessary type conversions
- unparam # Find unused function parameters
- gosec # Security problems
- gocritic # The most opinionated Go source code linter
- revive # Fast, configurable, extensible, flexible, and beautiful linter for Go
- stylecheck # Stylecheck is a replacement for golint
- gocyclo # Computes and checks cyclomatic complexity
- dupl # Tool for code clone detection
- funlen # Tool for detection of long functions
- gocognit # Computes and checks cognitive complexity
- nestif # Reports deeply nested if statements
- goconst # Finds repeated strings that could be replaced by a constant
- godot # Check if comments end in a period
- errorlint # Find code that will cause problems with Go 1.13 error wrapping
- whitespace # Detection of leading and trailing whitespace

linters-settings:
errcheck:
check-type-assertions: true
check-blank: true

govet:
check-shadowing: true
enable-all: true

gocyclo:
min-complexity: 15

funlen:
lines: 100
statements: 50

gocognit:
min-complexity: 20

nestif:
min-complexity: 4

goconst:
min-len: 3
min-occurrences: 3

misspell:
locale: US

godot:
scope: declarations
capital: true

revive:
confidence: 0.8
rules:
- name: blank-imports
- name: context-as-argument
- name: dot-imports
- name: error-return
- name: error-strings
- name: error-naming
- name: exported
- name: if-return
- name: increment-decrement
- name: var-naming
- name: package-comments
- name: range
- name: receiver-naming
- name: indent-error-flow
- name: superfluous-else
- name: unreachable-code

issues:
exclude-use-default: false
max-issues-per-linter: 0
max-same-issues: 0

exclude-rules:
# Exclude some linters from running on tests files
- path: _test\.go
linters:
- gocyclo
- errcheck
- dupl
- gosec
- funlen
- gocognit

# Allow main and init functions to be longer
- path: cmd/
linters:
- funlen
- gocyclo

output:
format: colored-line-number
print-issued-lines: true
print-linter-name: true
sort-results: true
72 changes: 72 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [1.0.0] - 2025-11-13

### Added
- Initial release with complete project reorganization
- Standard Go project structure (cmd/, internal/, pkg/)
- Comprehensive test suite with full coverage
- Unique ID generation for all expenses
- Expense model with validation
- Thread-safe JSON storage with mutex locks
- CLI commands:
- `add` - Add new expenses with optional descriptions
- `list` - List all expenses sorted by date
- `delete` - Remove expenses by ID
- `summary` - View category-based summary with percentages
- `categories` - List all unique categories
- `filter` - Filter expenses by category
- `range` - Filter expenses by date range
- `export` - Export expenses to CSV format
- `help` - Display help information
- `version` - Show version information
- Command aliases (del/rm for delete, sum for summary, cats for categories)
- Professional documentation:
- Comprehensive README with examples
- CONTRIBUTING.md with development guidelines
- CODE_OF_CONDUCT.md for community standards
- Inline code documentation
- Build and development tools:
- Makefile with build, test, lint, coverage targets
- GitHub Actions CI/CD workflow
- Multi-version Go testing (1.21, 1.22, 1.23)
- golangci-lint integration
- Security scanning with gosec
- Docker support for containerized deployment
- Enhanced .gitignore with comprehensive exclusions

### Changed
- Migrated from single file to modular architecture
- Replaced deprecated `ioutil` with `os` package
- Improved error handling and validation
- Better separation of concerns

### Breaking Changes
- Complete project restructuring requires rebuild
- Data format remains compatible (JSON)
- Binary location changed from root to `./expense-tracker`

## [0.1.0] - 2025-11-13

### Added
- Initial monolithic implementation
- Basic add and list commands
- JSON file storage
- Simple CLI interface

---

## Versioning Guide

- **MAJOR** version for incompatible API changes
- **MINOR** version for added functionality in a backward compatible manner
- **PATCH** version for backward compatible bug fixes

## Links
- [GitHub Repository](https://github.com/codeforgood-org/go-expense-tracker)
- [Issue Tracker](https://github.com/codeforgood-org/go-expense-tracker/issues)
Loading
Loading