Skip to content

Conversation

kooksee
Copy link
Contributor

@kooksee kooksee commented Sep 13, 2025

No description provided.

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.

Summary of Changes

Hello @kooksee, 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 focuses on a comprehensive set of improvements across core utilities, including error handling, logging, and variable management. The changes aim to modernize the codebase by adopting newer libraries like go-cmp and go.uber.org/atomic, enhance debugging capabilities, and streamline internal APIs for better maintainability and robustness. It also includes general cleanup and deprecation of outdated patterns.

Highlights

  • Version Management: A new .version file has been added to the project, containing v0.5.69, and a GetReleaseVersion function in funk.go now exposes this version using the go:embed directive.
  • Error Handling & Assertions Refinement: The assert package introduces a new MustEqual function for deep equality checks using go-cmp. Error handling utilities in errors/errinter have been significantly refactored, including improved ParseError to handle proto.Message, simplified GetErrorId using xid, and enhanced error logging with pp/v3 printers. The EnablePrintStack global variable has been removed and replaced with a more controlled stack.PrintStack utility.
  • Variable Management System Overhaul: The vars package has undergone a major refactor, transitioning from expvar types to go.uber.org/atomic types for various data structures (Bool, Float64, Int64, String, Duration, Time, Error). The Value type has been renamed to Func, and the Any and Register functions have been updated to support this new atomic-based system, providing more robust and thread-safe variable management.
  • Logging Improvements: The logging implementation has been enhanced with a new cloneEvent function for zerolog.Event objects and a deep copy mechanism for logger fields and content in the loggerImpl.copy() method. The CreateCtxWithLogger function has been renamed to CreateCtx, and WithEvent has been deprecated in favor of WithFields.
  • Code Cleanup and Deprecation: Several deprecated functions and unused imports have been removed or updated across the codebase. Notably, the try.Result function has been removed, and assert.If calls in recovery have been replaced with lo.Assert. The errors/errinter/color_name.go file was removed and replaced by errors/errinter/colorfield.go with minor refactoring.
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 in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

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 issue 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.

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

This pull request introduces a number of refactorings and bug fixes across the codebase. Key changes include updating the versioning mechanism, refactoring the vars package to use atomic types for better concurrency, and improving the assert package with a new MustEqual function. I've found a couple of areas for improvement. Specifically, I've suggested enhancing the error message in MustEqual to be more descriptive by including a diff of the non-equal values. I also pointed out a regression in error reporting within the try utility function and proposed a fix to restore more meaningful stack information. Additionally, several critical bug fixes were made, such as correcting inverted logic in result.Map and result.FlatMap, and ensuring deep copies in the logger implementation to prevent concurrency issues, which are great improvements.

assert/util.go Outdated
defer func() {
if gErr != nil {
gErr = fmt.Errorf("stack:%s, err:%w", stack.CallerWithFunc(fn).String(), gErr)
gErr = fmt.Errorf("stack:%s, err:%w", reflect.TypeOf(fn).String(), gErr)

Choose a reason for hiding this comment

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

high

Using reflect.TypeOf(fn).String() for the stack information in the error message is a regression from the previous implementation. It only provides the function's type signature (e.g., func() error), which is not very helpful for identifying where the error occurred. The previous implementation likely provided more specific caller information. To improve this, you could use runtime.FuncForPC to get the name of the function.

Note: You'll need to add "runtime" to your imports for this suggestion to work.

Suggested change
gErr = fmt.Errorf("stack:%s, err:%w", reflect.TypeOf(fn).String(), gErr)
gErr = fmt.Errorf("stack:%s, err:%w", runtime.FuncForPC(reflect.ValueOf(fn).Pointer()).Name(), gErr)

Comment on lines +18 to +20
pp.Println("a: ", a)
pp.Println("b: ", b)
must(fmt.Errorf("a,b not equal"))

Choose a reason for hiding this comment

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

medium

The error message "a,b not equal" is not very descriptive. When an equality check fails, it's very helpful for debugging to see the difference between the two values. The cmp.Diff function is great for this. Also, the pp.Println calls print to standard output, but their output is not part of the error that gets logged or panicked. Including the diff in the error message would make debugging much easier.

Suggested change
pp.Println("a: ", a)
pp.Println("b: ", b)
must(fmt.Errorf("a,b not equal"))
must(fmt.Errorf("a,b not equal (-a +b):\n%s", cmp.Diff(a, b)))

@kooksee kooksee force-pushed the fix/version branch 4 times, most recently from 97af335 to b1efe48 Compare September 15, 2025 15:51
@kooksee kooksee force-pushed the fix/version branch 5 times, most recently from ced3545 to fd035b3 Compare September 16, 2025 10:03
@kooksee kooksee force-pushed the fix/version branch 3 times, most recently from 4712538 to a0d0dcb Compare September 18, 2025 05:48
@kooksee kooksee force-pushed the fix/version branch 5 times, most recently from 7bdcd0d to a29734e Compare September 18, 2025 14:52
@kooksee kooksee force-pushed the fix/version branch 2 times, most recently from 6cd7ddd to f8f36a4 Compare September 23, 2025 05:26
@kooksee kooksee force-pushed the fix/version branch 2 times, most recently from 6cb5582 to b85157b Compare September 23, 2025 14:29
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