refactor: drop trivial helpers, use new(v) and data.DateLayout#958
Merged
cpcloud merged 2 commits intomicasa-dev:mainfrom Apr 19, 2026
Merged
refactor: drop trivial helpers, use new(v) and data.DateLayout#958cpcloud merged 2 commits intomicasa-dev:mainfrom
cpcloud merged 2 commits intomicasa-dev:mainfrom
Conversation
- Remove fmtIntAlways and fmtSize wrappers in cmd/micasa/show.go; inline strconv.Itoa / strconv.FormatInt at call sites. - Replace if-val-"true"/"false" ladder in ops_tree.go with strconv.FormatBool. - Delete ptr[T any] helpers in internal/data and internal/app tests in favor of Go 1.26 new(v) builtin. Deduplicate ptr and ptrTime closures in dashboard_test.go into one package-level ptrTime. - fmtMoney now delegates to fmtMoneyVal instead of duplicating the format string. - Replace hardcoded "2006-01-02" with existing data.DateLayout constant where the same package already used it elsewhere.
The jn helper was a one-line wrapper that returned json.Number(s). Inlining removes the indirection; the result reads the same at call sites and drops an unnecessary name to remember.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
fmtIntAlwaysandfmtSizewrappers incmd/micasa/show.go; inlinestrconv.Itoa/strconv.FormatIntat call sites.if val { return "true" } return "false"inops_tree.gotostrconv.FormatBool.ptr[T any]test helpers ininternal/dataandinternal/appin favor of Go 1.26'snew(v)builtin; deduplicate scatteredptr/ptrTimeclosures indashboard_test.gointo one package-levelptrTime.fmtMoneydelegate tofmtMoneyValinstead of duplicating the format string."2006-01-02"literals with the existingdata.DateLayoutconstant where the same package already used it.jn()test helper ininternal/extract/shadow_test.go; call sites read the same asjson.Number(...)without the indirection.