Skip to content

feat: Add Nix DevShell and fix all lint issues#3

Merged
kalbasit merged 6 commits intomainfrom
fix-lint-issues
Feb 23, 2026
Merged

feat: Add Nix DevShell and fix all lint issues#3
kalbasit merged 6 commits intomainfrom
fix-lint-issues

Conversation

@kalbasit
Copy link
Owner

No description provided.

@gemini-code-assist
Copy link

Summary of Changes

Hello @kalbasit, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the project's development workflow and code quality. It establishes a reproducible development environment using Nix, ensuring all developers work with the same tool versions and dependencies. Concurrently, it enforces strict code style and identifies potential issues through a newly configured golangci-lint setup, integrated with pre-commit hooks. The internal code generation logic has also been refactored for improved maintainability and clarity, alongside updates to Go language features and error handling.

Highlights

  • Nix Development Environment: Introduced a Nix DevShell configuration, including flake.nix, flake.lock, and related modules, to provide a reproducible development environment with pinned dependencies for Go, linters, and other tools.
  • Linting and Formatting Enforcement: Added a comprehensive .golangci.yml configuration to enable a wide array of Go linters and formatters, and integrated these checks into pre-commit hooks via Nix modules to ensure consistent code quality.
  • Code Refactoring and Modularity: Refactored the generator package by extracting parseQuerierInterface and parseStructType functions, improving code organization and readability. Exported internal helper functions as func instead of var for better testability.
  • Improved Type Handling and Error Management: Added new constants for common Go types and sql.Null types, and introduced specific error types for better error handling within the generator logic, particularly for unsupported slice domain structs.
  • Go Version Update: Updated the project's Go version requirement from 1.25.5 to 1.25.6 in go.mod.
Changelog
  • .envrc
    • Added direnv configuration to watch the nix directory and use Nix flakes.
  • .gitignore
    • Added new entries to ignore Nix-related build artifacts (/ncps, /result*, /.direnv), pre-commit configuration (/.pre-commit-config.yaml), Python cache directories, and agent settings.
  • .golangci.yml
    • Added a new golangci-lint configuration file, enabling numerous linters and formatters like gci, gofumpt, err113, gosec, lll, misspell, and staticcheck, with specific exclusions for generated files.
  • flake.lock
    • Added a new Nix flake lock file, pinning all Nix dependencies for reproducible builds.
  • flake.nix
    • Added a new Nix flake definition, including inputs for flake-parts, git-hooks-nix, nixpkgs, and treefmt-nix, and defining outputs for devshells, formatters, and pre-commit hooks across multiple systems.
  • generator/constants.go
    • Added new constants for common Go primitive types and sql.Null types to centralize type definitions.
  • generator/errors.go
    • Added new error variables (errInvalidDictCall, errDictKeysMustBeStrings, errSliceDomainStructNotSupported) and a helper function errUnsupportedSliceDomainStruct for improved error handling.
  • generator/exports.go
    • Converted exported var declarations to func declarations for all helper functions (e.g., ExprToString, IsDomainStructFunc, ZeroValue), and imported the go/ast package.
  • generator/generator.go
    • Moved the engines slice from a global variable to a local variable within the Run function.
    • Added new helper functions parseQuerierInterface and parseStructType to encapsulate parsing logic for interfaces and structs.
    • Refactored the parsePackage function to utilize the new parseQuerierInterface and parseStructType functions, improving modularity.
    • Added blank lines for better code formatting and readability.
  • generator/generator_test.go
    • Updated imports to use errors package instead of fmt for error creation.
    • Added t.Parallel() calls to all test functions to enable parallel test execution.
    • Replaced fmt.Errorf with errors.New for test-specific error definitions.
    • Adjusted the joinParamsCall mock in TestWrapperTemplate to accept an unused _ string parameter.
  • generator/helpers.go
    • Refactored toSnakeCase function to pre-allocate slice capacity for efficiency and improved logic for handling consecutive uppercase letters.
    • Added //nolint:gosec comment to os.WriteFile call in writeFile.
    • Extracted logic for joining domain struct parameters into a new joinDomainStructParam function.
    • Extracted logic for joining non-domain parameters into a new joinNonDomainParam function.
    • Introduced a new parseGoMod helper function to read module names from go.mod files.
    • Updated isDomainStructFunc to use the typeQuerier constant.
    • Updated zeroValue to use new type constants (typeAny, typeBool, typeString, zeroNil, typeQuerier).
    • Updated isNumeric, isStructType, isSQLNullType, getPrimitiveFromNullType, getNullTypeFromPrimitive, and getFieldNameForNullType to utilize the new type constants for consistency and clarity.
    • Refined generateFieldConversion logic to use new type constants and improve formatting for multi-line conversions.
  • generator/types.go
    • Updated comments for Engine and MethodInfo structs for better clarity.
  • go.mod
    • Updated the required Go version from 1.25.5 to 1.25.6.
  • main.go
    • Added a blank line for formatting.
  • nix/devshells/flake-module.nix
    • Added a new Nix flake module to define a default development shell, including delve, go, golangci-lint, and pre-commit as build inputs.
    • Configured hardeningDisable = [ "fortify" ] for Delve compatibility.
    • Added a shellHook to install pre-commit hooks and update go.mod with the correct Go version.
  • nix/formatter/flake-module.nix
    • Added a new Nix flake module for code formatting using treefmt-nix, enabling actionlint, deadnix, gofumpt, mdformat, nixfmt, statix, and yamlfmt.
  • nix/pre-commit/flake-module.nix
    • Added a new Nix flake module for pre-commit hooks using git-hooks-nix, enabling checks for merge conflicts, deadnix, golangci-lint, no-commit-to-branch, nixfmt-rfc-style, statix, and trim-trailing-whitespace.
Ignored Files
  • Ignored by pattern: .github/workflows/** (1)
    • .github/workflows/flake-update.yml
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@codecov-commenter
Copy link

Welcome to Codecov 🎉

Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests.

Thanks for integrating Codecov - We've got you covered ☂️

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

The pull request introduces a Nix development environment and addresses various linting issues in the Go codebase. The refactoring of the generator logic into smaller, more focused functions is a significant improvement for maintainability. I have identified a potential panic in the AST parsing logic and some minor efficiency improvements.

@kalbasit kalbasit merged commit 10fd7c6 into main Feb 23, 2026
3 checks passed
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.

2 participants