Skip to content

chore: update go version#41

Merged
rodneyosodo merged 4 commits intomainfrom
update
Dec 22, 2025
Merged

chore: update go version#41
rodneyosodo merged 4 commits intomainfrom
update

Conversation

@rodneyosodo
Copy link
Member

@rodneyosodo rodneyosodo commented Dec 22, 2025

What type of PR is this?

  • Refactor
  • Feature
  • Bug Fix
  • Optimization
  • Documentation Update
  • Dependency Update

Related Tickets & Documents

  • Related Issue #
  • Closes #

Added/updated tests?

  • Yes
  • No, and this is why:
  • I need help with writing tests

Added/updated documentation

  • Yes
  • No, and this is why:
  • I need help with writing documentation

Notes

Summary by Sourcery

Update Go tooling and CI configuration while making name generation options non-mutating.

Bug Fixes:

  • Ensure name generator options are applied to a copy so Generate no longer mutates the original generator.

Build:

  • Update pre-commit hooks and switch to tekwizely/pre-commit-golang with additional Go formatting, linting, build, and test hooks.

CI:

  • Add Go 1.25 to the test matrix, set Go 1.25 as the primary CI version, and bump golangci-lint GitHub Action to v9 with a pinned linter version.

Chores:

  • Simplify Dependabot configuration by removing scheduling, timezone, assignee, and reviewer settings.

Summary by CodeRabbit

Release Notes

  • Chores

    • Updated CI/CD workflow to support Go 1.25
    • Upgraded linting and pre-commit development tools
    • Simplified dependabot configuration
  • Refactor

    • Improved code generation process to prevent unintended state mutations

✏️ Tip: You can customize this high-level summary in your review settings.

Also update base precommit hooks to latest version
Also update golang ci lint action to use pinned version rather than latest
create a temporary copy of generator for applying options
This follows the principle of least surprise - when you pass options to a function call, you expect them to apply only to that call, not permanently mutate the object
@sourcery-ai
Copy link

sourcery-ai bot commented Dec 22, 2025

Reviewer's Guide

Updates the Go toolchain version and CI tooling, and refactors the name generator to apply options on a cloned instance instead of mutating the original receiver during name generation.

Class diagram for updated nameGenerator.Generate behavior

classDiagram
    class NameGenerator {
    <<interface>>
      +WithSeparator(separator string) NameGenerator
      +Generate(options Options) string
    }

    class nameGenerator {
      -Gender gender
      -string prefix
      -string suffix
      -int lenOfRandomString
      -string separator
      +WithSeparator(separator string) NameGenerator
      +Generate(options Options) string
      -generateRandomString(length int) string
      -generateRandomNumber(limit int) int
    }

    NameGenerator <|.. nameGenerator

    class Gender {
      <<enum>>
      Male
      Female
      NonBinary
    }

    nameGenerator --> Gender

    class Options {
      <<function type>>
      +apply(generator *nameGenerator)
    }

    Options ..> nameGenerator
Loading

File-Level Changes

Change Details Files
Refactor name generator to apply Options on a cloned configuration instead of mutating the receiver during Generate
  • Instantiate a new nameGenerator inside Generate copying the current receiver configuration
  • Apply all provided Options to the new instance instead of the original receiver
  • Use the cloned instance for random-string generation, gender-based name selection, and string assembly for all gender branches
generator.go
Modernize pre-commit configuration for Go tooling
  • Upgrade pre-commit-hooks repo from v4.6.0 to v6.0.0
  • Switch Go-related hooks from dnephin/pre-commit-golang to tekwizely/pre-commit-golang
  • Replace basic go-fmt and go-imports hooks with a more comprehensive set of Go build, mod, test, vet, fmt, imports, and golangci-lint hooks targeting module and repo scopes
.pre-commit-config.yaml
Update CI pipeline to target Go 1.25 and newer golangci-lint action
  • Extend Go test matrix to include version 1.25
  • Bump actions/setup-go configured version from 1.24 to 1.25
  • Upgrade golangci-lint GitHub Action from v8 to v9 and pin golangci-lint version to v2.7.2
.github/workflows/ci.yaml
Simplify Dependabot configuration for Go module updates
  • Remove scheduled update time and timezone configuration
  • Remove default assignee and reviewer configuration for Dependabot PRs
.github/dependabot.yml

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@coderabbitai
Copy link

coderabbitai bot commented Dec 22, 2025

Walkthrough

This pull request updates the project's CI/CD tooling and Go development environment. It bumps the supported Go version to 1.25 in CI, updates linting and pre-commit hook versions, simplifies the dependabot configuration, and refactors the generator to apply options to a copy rather than mutating the original instance.

Changes

Cohort / File(s) Summary
CI/CD Configuration
.github/dependabot.yml
Removed time, timezone, assignees, and reviewers fields from the dependabot schedule configuration
CI Workflow Updates
.github/workflows/ci.yaml
Upgraded Go matrix and test job version to 1.25; bumped golangci-lint-action from v8 to v9 and set linting version to v2.7.2
Pre-commit Hooks
.pre-commit-config.yaml
Updated primary hooks repo to v6.0.0; replaced golang hook repository and expanded Go-related hooks set (go-build-mod, go-mod-tidy, go-test-mod, go-vet-mod, go-fmt-repo, go-imports-repo, golangci-lint-mod variants)
Generator Refactoring
generator.go
Changed Generate() to apply options to a local copy of generator state instead of mutating the original receiver; all internal references updated to use the copy

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • .github/workflows/ci.yaml: Verify Go 1.25 compatibility and that linting action v9 with v2.7.2 runs without issues
  • .pre-commit-config.yaml: Confirm the new golang hook repository (tekwizely/pre-commit-golang@v1.0.0-rc.4) provides equivalent or improved functionality; the expanded hooks set warrants quick verification against actual pre-commit execution
  • generator.go: While the refactoring is straightforward, verify that option application remains idempotent and that no callers depend on the previous mutation behavior

Possibly related PRs

Poem

🐰 Version bumps hop along the way,
Pre-commit hooks dance and play,
Copies made, mutations stay,
Generator fresh, no mess today!
🌟

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Title check ⚠️ Warning The PR title 'chore: update go version' only partially captures the changeset. While Go version updates are present, the PR includes significant changes to pre-commit hooks, dependabot configuration, CI workflows, and a functional bug fix in generator.go. Consider a more comprehensive title like 'chore: update dependencies and go version' or 'chore: update go 1.25 and tooling' that better reflects the multiple categories of changes.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch update

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've found 1 issue, and left some high level feedback:

  • In nameGenerator.Generate, instead of manually cloning the struct into gen, consider changing the receiver to a value receiver (or adding a clone() helper) so options are applied to a copy more idiomatically and without manual field-by-field copying.
  • The new pre-commit-golang configuration enables many *-mod and *-repo hooks (build, test, vet, lint, fmt, imports); you may want to trim this set to only the hooks that add value to keep pre-commit runs fast and avoid redundant checks.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- In `nameGenerator.Generate`, instead of manually cloning the struct into `gen`, consider changing the receiver to a value receiver (or adding a `clone()` helper) so options are applied to a copy more idiomatically and without manual field-by-field copying.
- The new `pre-commit-golang` configuration enables many `*-mod` and `*-repo` hooks (build, test, vet, lint, fmt, imports); you may want to trim this set to only the hooks that add value to keep pre-commit runs fast and avoid redundant checks.

## Individual Comments

### Comment 1
<location> `generator.go:193-198` </location>
<code_context>
 }

 func (namegen *nameGenerator) Generate(options ...Options) string {
+	gen := &nameGenerator{
+		gender:            namegen.gender,
+		prefix:            namegen.prefix,
+		suffix:            namegen.suffix,
+		lenOfRandomString: namegen.lenOfRandomString,
+		separator:         namegen.separator,
+	}
+
</code_context>

<issue_to_address>
**suggestion (bug_risk):** Copying individual fields risks missing new fields on nameGenerator and breaking Generate behavior.

Constructing `gen` with an explicit field list means any future fields added to `nameGenerator` (e.g., RNG, config, or internal state) won’t be copied, and `Generate` may behave incorrectly in subtle ways. Instead, shallow-copy the struct and apply options on that copy, for example:

```go
func (namegen *nameGenerator) Generate(options ...Options) string {
    gen := *namegen
    gptr := &gen
    for _, option := range options {
        option(gptr)
    }
    // use gptr (or gen) below
}
```

This preserves non-mutating behavior while keeping all current and future fields intact.

Suggested implementation:

```golang
}

func (namegen *nameGenerator) Generate(options ...Options) string {
	gen := *namegen
	gptr := &gen

	for _, option := range options {
		option(gptr)

```

1. Ensure the remainder of the `Generate` function uses `gptr` (or `gen`) consistently for any fields it reads or methods it calls, rather than `namegen`, if the intent is to work on the per-call copy.
2. If `Generate` currently refers to the old `gen` variable in code not shown in the snippet, update those references to `gptr` (or `gen`) according to whether a pointer or value receiver is required.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
generator.go (1)

232-243: Critical: GenerateMultiple still mutates the original generator, creating API inconsistency.

While Generate now uses a copy-on-write pattern (lines 193-199), GenerateMultiple still mutates the original generator at lines 233-235. This creates inconsistent behavior:

// Case 1: Generate is non-mutating ✓
gen := NewGenerator()
name := gen.Generate(WithGender(Male))
// gen is unchanged

// Case 2: GenerateMultiple is mutating ✗
gen := NewGenerator()
names := gen.GenerateMultiple(10, WithGender(Male))
// gen is now mutated with Male gender

This violates the functional options pattern and contradicts the PR's stated objective to "fix functional option behavior by creating a temporary copy."

🔎 Proposed fix to align GenerateMultiple with Generate's copy-on-write pattern
 func (namegen *nameGenerator) GenerateMultiple(count int, options ...Options) []string {
+	gen := &nameGenerator{
+		gender:            namegen.gender,
+		prefix:            namegen.prefix,
+		suffix:            namegen.suffix,
+		lenOfRandomString: namegen.lenOfRandomString,
+		separator:         namegen.separator,
+	}
+
 	for _, option := range options {
-		option(namegen)
+		option(gen)
 	}
 
 	names := make([]string, count)
 	for i := 0; i < count; i++ {
-		names[i] = namegen.Generate()
+		names[i] = gen.Generate()
 	}
 
 	return names
 }
🧹 Nitpick comments (1)
.pre-commit-config.yaml (1)

18-32: Consider the stability implications of using a release candidate version.

The pre-commit hook repository has been migrated from dnephin/pre-commit-golang to tekwizely/pre-commit-golang and pinned to v1.0.0-rc.4 (a release candidate). While the expanded hook set (12 hooks vs 2) significantly improves Go tooling coverage, using an RC version in production may introduce instability or breaking changes before the stable v1.0.0 release.

Verify whether a stable version is available:

#!/bin/bash
# Description: Check if tekwizely/pre-commit-golang has a stable v1.0.0 or later release

echo "Checking available releases for tekwizely/pre-commit-golang..."
gh api repos/tekwizely/pre-commit-golang/releases | jq -r '.[].tag_name' | head -10

echo -e "\nChecking if the repository is actively maintained..."
gh api repos/tekwizely/pre-commit-golang | jq '{
  name: .name,
  stars: .stargazers_count,
  last_updated: .updated_at,
  archived: .archived
}'
📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between cc9de5f and 1c73744.

📒 Files selected for processing (4)
  • .github/dependabot.yml
  • .github/workflows/ci.yaml
  • .pre-commit-config.yaml
  • generator.go
💤 Files with no reviewable changes (1)
  • .github/dependabot.yml
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: rodneyosodo
Repo: 0x6flab/namegenerator PR: 36
File: .github/workflows/ci.yaml:57-57
Timestamp: 2025-06-30T08:33:06.277Z
Learning: Go 1.24 is available in actions/go-versions repository with multiple patch releases (1.24.0, 1.24.1, 1.24.2, 1.24.3, 1.24.4) as of June 2025, so actions/setup-gov5 supports Go 1.24.
📚 Learning: 2025-06-30T08:33:06.277Z
Learnt from: rodneyosodo
Repo: 0x6flab/namegenerator PR: 36
File: .github/workflows/ci.yaml:57-57
Timestamp: 2025-06-30T08:33:06.277Z
Learning: Go 1.24 is available in actions/go-versions repository with multiple patch releases (1.24.0, 1.24.1, 1.24.2, 1.24.3, 1.24.4) as of June 2025, so actions/setup-gov5 supports Go 1.24.

Applied to files:

  • .github/workflows/ci.yaml
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: build-across-platforms (windows-latest, 1.25)
  • GitHub Check: build-across-platforms (macos-latest, 1.22)
  • GitHub Check: testing
🔇 Additional comments (4)
.github/workflows/ci.yaml (3)

58-58: LGTM: Go version update aligns with matrix expansion.

The testing job now uses Go 1.25, which is consistent with the matrix addition at line 32. This ensures the CI tests against the latest version.


61-63: LGTM: Pinning golangci-lint version eliminates nondeterminism.

Excellent change to pin the golangci-lint version instead of using "latest". This ensures reproducible CI builds and prevents unexpected breakage from new linter versions.


32-32: Go 1.25 is available and properly added to the test matrix.

Go 1.25 was released in August 2025, and Go 1.25.5 was released on December 2, 2025, confirming multiple stable patch versions are available with actions/setup-go@v6. The test matrix addition is appropriate.

generator.go (1)

193-228: LGTM: Copy-on-write pattern correctly implemented in Generate.

The refactor creates a local copy of the generator state and applies options to the copy rather than mutating the receiver. This ensures that calling Generate with options does not modify the original generator instance.

However, note that GenerateMultiple (lines 232-243) still mutates the original generator, creating an API inconsistency (see separate comment).

@rodneyosodo rodneyosodo merged commit 42d06dc into main Dec 22, 2025
37 checks passed
@coderabbitai coderabbitai bot mentioned this pull request Dec 22, 2025
1 task
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