-
Notifications
You must be signed in to change notification settings - Fork 2
Fix/version #50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: release/0.6
Are you sure you want to change the base?
Fix/version #50
Conversation
There was a problem hiding this 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, containingv0.5.69
, and aGetReleaseVersion
function infunk.go
now exposes this version using thego:embed
directive. - Error Handling & Assertions Refinement: The
assert
package introduces a newMustEqual
function for deep equality checks usinggo-cmp
. Error handling utilities inerrors/errinter
have been significantly refactored, including improvedParseError
to handleproto.Message
, simplifiedGetErrorId
usingxid
, and enhanced error logging withpp/v3
printers. TheEnablePrintStack
global variable has been removed and replaced with a more controlledstack.PrintStack
utility. - Variable Management System Overhaul: The
vars
package has undergone a major refactor, transitioning fromexpvar
types togo.uber.org/atomic
types for various data structures (Bool, Float64, Int64, String, Duration, Time, Error). TheValue
type has been renamed toFunc
, and theAny
andRegister
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 forzerolog.Event
objects and a deep copy mechanism for logger fields and content in theloggerImpl.copy()
method. TheCreateCtxWithLogger
function has been renamed toCreateCtx
, andWithEvent
has been deprecated in favor ofWithFields
. - 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, andassert.If
calls inrecovery
have been replaced withlo.Assert
. Theerrors/errinter/color_name.go
file was removed and replaced byerrors/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
-
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. ↩
There was a problem hiding this 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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
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) |
pp.Println("a: ", a) | ||
pp.Println("b: ", b) | ||
must(fmt.Errorf("a,b not equal")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
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))) |
97af335
to
b1efe48
Compare
ced3545
to
fd035b3
Compare
fd035b3
to
5030e67
Compare
535017b
to
4aee6c0
Compare
4aee6c0
to
5921f06
Compare
4712538
to
a0d0dcb
Compare
a0d0dcb
to
42e184c
Compare
7bdcd0d
to
a29734e
Compare
a29734e
to
60706fd
Compare
6cd7ddd
to
f8f36a4
Compare
f8f36a4
to
db141c1
Compare
6cb5582
to
b85157b
Compare
b85157b
to
83b32e5
Compare
No description provided.