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
4 changes: 2 additions & 2 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@

<!-- How was this tested? -->

- [ ] Unit tests pass (`go test ./...`)
- [ ] Lint passes (`golangci-lint run ./...`)
- [ ] fmt, vet, lint, test, build passes (make all)
- [ ] New code has tests where appropriate
- [ ] Generated code compiles for affected scenarios

## Related Issues
Expand Down
54 changes: 46 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,24 +1,62 @@
.PHONY: deps test lint bench vet fmt ci
GOLANGCI_LINT_VERSION := v2.10.1

.PHONY: all setup deps test test-v vet lint bench build fmt cover clean ci

all: fmt vet lint test build

## Install development tools (skips if already present)
setup:
@command -v golangci-lint >/dev/null 2>&1 || { \
echo "Installing golangci-lint $(GOLANGCI_LINT_VERSION)..."; \
go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@$(GOLANGCI_LINT_VERSION); \
}
@command -v goimports >/dev/null 2>&1 || { \
echo "Installing goimports..."; \
go install golang.org/x/tools/cmd/goimports@latest; \
}

## Download module dependencies
deps:
go mod download
go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@latest
go install golang.org/x/tools/cmd/goimports@latest

## Run all tests with race detector
test:
go test -race -count=1 -p 1 ./...
go test -race -count=1 ./...

lint:
golangci-lint run
## Run tests with verbose output
test-v:
go test -race -v -count=1 ./...

## Run go vet
vet:
go vet ./...

## Run golangci-lint
lint: setup
golangci-lint run ./...

## Run benchmarks
bench:
go test -bench=. -benchmem ./...

vet:
go vet ./...
## Build all packages
build:
go build ./...

## Format code
fmt:
gofmt -w .
goimports -w .

## Run tests with coverage report
cover:
go test -race ./... -coverprofile=coverage.out
go tool cover -html=coverage.out -o coverage.html
@echo "Coverage report: coverage.html"

## Remove build artifacts
clean:
rm -f coverage.out coverage.html

## CI pipeline: vet, lint, test
ci: vet lint test
28 changes: 14 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
Code generation tool that parses Go struct definitions and generates type-safe mapping functions. Zero reflection, zero runtime cost. In `func` mode (default), the generated code has zero dependencies.

[![Go Reference](https://pkg.go.dev/badge/github.com/KARTIKrocks/gomapper.svg)](https://pkg.go.dev/github.com/KARTIKrocks/gomapper)
[![CI](https://github.com/KARTIKrocks/gomapper/actions/workflows/ci.yml/badge.svg)](https://github.com/KARTIKrocks/gomapper/actions/workflows/ci.yml)
[![Go Report Card](https://goreportcard.com/badge/github.com/KARTIKrocks/gomapper)](https://goreportcard.com/report/github.com/KARTIKrocks/gomapper)
[![Go Version](https://img.shields.io/github/go-mod/go-version/KARTIKrocks/gomapper)](go.mod)
[![CI](https://github.com/KARTIKrocks/gomapper/actions/workflows/ci.yml/badge.svg)](https://github.com/KARTIKrocks/gomapper/actions/workflows/ci.yml)
[![License](https://img.shields.io/github/license/KARTIKrocks/gomapper)](LICENSE)
[![GitHub tag](https://img.shields.io/github/v/tag/KARTIKrocks/gomapper)](https://github.com/KARTIKrocks/gomapper/releases)

Expand Down Expand Up @@ -39,19 +39,19 @@ This produces a `mapper_gen.go` file with pure mapping functions — no runtime

### Flags

| Flag | Default | Description |
|------|---------|-------------|
| `-src` | | Source type name |
| `-dst` | | Destination type name |
| `-pairs` | | Comma-separated `Src:Dst` pairs |
| `-output` | `mapper_gen.go` | Output file name |
| `-mode` | `func` | `func` (pure functions), `register`, or `both` |
| `-bidirectional` | `false` | Generate both S→D and D→S mappings |
| `-tag` | `map` | Struct tag key for field renaming |
| `-strict` | `false` | Fail if any destination field is unmapped |
| `-ci` | `false` | Case-insensitive field name matching |
| `-nil-safe` | `false` | Generate nil checks for pointer dereferences |
| `-v` | `false` | Verbose output |
| Flag | Default | Description |
| ---------------- | --------------- | ---------------------------------------------- |
| `-src` | | Source type name |
| `-dst` | | Destination type name |
| `-pairs` | | Comma-separated `Src:Dst` pairs |
| `-output` | `mapper_gen.go` | Output file name |
| `-mode` | `func` | `func` (pure functions), `register`, or `both` |
| `-bidirectional` | `false` | Generate both S→D and D→S mappings |
| `-tag` | `map` | Struct tag key for field renaming |
| `-strict` | `false` | Fail if any destination field is unmapped |
| `-ci` | `false` | Case-insensitive field name matching |
| `-nil-safe` | `false` | Generate nil checks for pointer dereferences |
| `-v` | `false` | Verbose output |

### Modes

Expand Down
25 changes: 25 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
codecov:
require_ci_to_pass: true

coverage:
precision: 2
round: down
range: "70...100"
status:
project:
default:
target: auto
threshold: 5%
patch:
default:
target: auto
threshold: 5%

comment:
layout: "reach,diff,flags,files"
behavior: default
require_changes: true

ignore:
- "examples/**"
- "vendor/**"
4 changes: 2 additions & 2 deletions integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ func TestIntegration_ExpectedOutputMatch(t *testing.T) {
}

gen := readGenerated(t, dir, out)
expected, err := os.ReadFile(filepath.Join(dir, "expected_gen.go"))
expected, err := os.ReadFile(filepath.Join(dir, "expected_gen.go.golden"))
if err != nil {
t.Fatalf("reading expected output: %v", err)
}
Expand Down Expand Up @@ -731,7 +731,7 @@ func TestIntegration_AdvancedExpectedOutputMatch(t *testing.T) {
}

gen := readGenerated(t, dir, out)
expected, err := os.ReadFile(filepath.Join(dir, "expected_gen.go"))
expected, err := os.ReadFile(filepath.Join(dir, "expected_gen.go.golden"))
if err != nil {
t.Fatalf("reading expected output: %v", err)
}
Expand Down
File renamed without changes.
Loading