Skip to content

refactor: different things - #15

Open
IceflowRE wants to merge 20 commits into
we11adam:masterfrom
IceflowRE:refactor
Open

IceflowRE wants to merge 20 commits into
we11adam:masterfrom
IceflowRE:refactor

Conversation

@IceflowRE

@IceflowRE IceflowRE commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

if you do not want a thing to change, i can remove that commit.

Greptile Summary

This PR modernizes the codebase with idiomatic Go patterns across 58 files, targeting Go 1.26. It is a pure refactoring with no intended behavior changes.

  • Error construction: fmt.Errorf("static string") replaced with errors.New(...) throughout, and octal literals normalized to the 0o prefix form.
  • Go 1.22–1.26 idioms: for i := range N integer ranges, strings.SplitSeq, slices.SortFunc, maps.Keys, sync.WaitGroup.Go, and new(false) for pointer initialization.
  • Test quality: t.Parallel() added to nearly every test, global mutable state (SERVICES map, http.DefaultTransport) replaced with per-instance state, and log-cleanup tests switched from time.Local to time.UTC for determinism.

Confidence Score: 5/5

Safe to merge — all changes are refactoring with no logic regressions found.

Every functional change is a clean substitution of newer stdlib APIs for older ones (slices/maps/iter, errors.New, range-over-int, sync.WaitGroup.Go, strings.SplitSeq) with equivalent semantics. The removal of the global SERVICES map reduces shared mutable state, making tests and production code safer. The only substantive deviation is that the error message listing supported IP services is now non-deterministically ordered, which is cosmetic.

Files Needing Attention: provider/ip_service/ip_service.go — the slices.Collect(maps.Keys(...)) call in the error message produces a non-deterministic list of supported services.

Important Files Changed

Filename Overview
provider/ip_service/ip_service.go Removes global mutable SERVICES map, moves service URL map into a per-instance field and defaultServiceUrls() factory. Signature of New() changes from pointer to value receiver. Minor: supported-services list in error messages is now non-deterministically ordered.
logging.go parseRotatedLogDate gains a location parameter instead of hardcoding time.Local; callers pass now.Location(), preserving production behaviour. Tests switch to time.UTC for determinism.
internal/redact/redact.go sort.Slice replaced with slices.SortFunc using len(b)-len(a) comparator; descending-length sort order is preserved correctly.
notifier/discord/discord.go Response-status handling collapsed into IsSuccess() first, then explicit 429 check. Semantically equivalent: 429 is not 2xx, so the order change has no effect on observable behaviour.
internal/dnsname/dnsname.go strings.Split replaced with strings.SplitSeq (Go 1.24 iterator); for-range syntax updated accordingly. Logic unchanged.
internal/registry/registry_test.go Uses sync.WaitGroup.Go (Go 1.25) to replace the wg.Add(1)/go func()/defer wg.Done() pattern. t.Parallel() added to all test functions.
updater/cloudflare/cloudflare_test.go TestHTTPClientSupportsCustomDefaultTransport refactored to avoid mutating http.DefaultTransport; now sets client.Transport directly, eliminating a global-state hazard for parallel tests.
app/app.go Removes two unused jobStatus constants (jobStatusIPChange, jobStatusUpdateSuccess).

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[New IpService] --> B{len names == 0?}
    B -- yes --> C[error: no IP service names provided]
    B -- no --> D[build ipService with defaultServiceUrls]
    D --> E{each name in urls?}
    E -- no --> F[error: unsupported IP service
maps.Keys order non-deterministic]
    E -- yes --> G[return ipService]

    H[getIP ctx client family] --> I{for each name}
    I --> J[lookup in ipService.urls]
    J --> K[HTTP request via resty client]
    K -- success --> L[return IP string]
    K -- failure --> M[append to failures
try next name]
    M --> I
    I -- exhausted --> N[return joined errors]
Loading

Reviews (4): Last reviewed commit: "refactor(logging): use time location fro..." | Re-trigger Greptile

@IceflowRE
IceflowRE marked this pull request as draft July 27, 2026 22:17
@IceflowRE

Copy link
Copy Markdown
Contributor Author

Will fix race conditions later.

Comment thread updater/cloudflare/cloudflare.go
Comment thread selfupdate_command.go Outdated
@IceflowRE
IceflowRE marked this pull request as ready for review July 30, 2026 14:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant