-
Notifications
You must be signed in to change notification settings - Fork 2
release 0.6 (#48) #49
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: master
Are you sure you want to change the base?
Conversation
Signed-off-by: 百里(barry) <kookshine@gmail.com> Signed-off-by: barry <kooksee@163.com> Signed-off-by: barry <kookshine@gmail.com>
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 represents a substantial update focused on improving the foundational aspects of the funk
Go module. It introduces a more robust and centralized approach to error handling and logging, streamlines configuration and environment variable management, and provides new command-line utilities for better application control and introspection. The changes also include crucial dependency updates and a Go version bump, ensuring the project remains current and performant.
Highlights
- Core Library Refactoring: The error handling and assertion mechanisms have undergone a significant overhaul. The
assert
package now uses an internalmust
helper, centralizing panic and logging logic. Theerrors
package has been refactored to leverage new interfaces and utility functions moved into a dedicatederrinter
sub-package, promoting cleaner separation of concerns. - Enhanced Configuration and Environment Management: New capabilities for handling configuration and environment variables have been introduced. This includes a new
config/envs.go
file for defining and loading environment-specific configurations, and an improvedenv
package with explicit reload functionality and support for environment variable prefixes. Custom expression functions can now be registered for use within configuration files. - New Utility Packages and CLI Commands: Several new utility packages have been added:
cliutils
for command-line argument parsing,component/lifecycle
for managing application component lifecycles,log/logfields
for standardized log field names,log/logutil
for common logging helpers,log/impl.slog.go
forslog.Handler
integration, andsyncutil
for context-aware function calls. New CLI commands (envcmd
,versioncmd
,testmain
) provide better introspection and management of the application. - Dependency Updates and Go Version Bump: The project's Go version has been updated to 1.23.0, and numerous core dependencies, including
envsubst
,expr
,pp
,term
,machineid
,lo
,slog-common
,testify
, andurfave/cli/v3
, have been upgraded to their latest versions, ensuring compatibility and leveraging new features. - Improved Logging and Debugging: The logging system has been refined with a new
slog.Handler
implementation, standardized log field names, and enhanced error detail logging. Therecovery
package now explicitly prints stack traces during panics and exits, aiding in debugging.
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 several changes across multiple files, primarily focusing on error handling, logging, configuration loading, and code generation. The changes include refactoring error handling with a new errinter
package, enhancing logging with zerolog, improving configuration loading with environment variable substitution and patching, and updating code generation for cloud events and enums. The review comments address potential issues related to error handling, logging verbosity, and code clarity.
|
||
func RegisterExpr(name string, expr any) { | ||
if registerMap[name] != nil { | ||
panic(fmt.Sprintf("expr:%s has existed", name)) |
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.
os.Exit(1) | ||
} | ||
|
||
func Exit1[T any](ret T, err error) T { |
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.
v, err := strconv.ParseBool(dt) | ||
if err != nil { | ||
log.Printf("env: failed to parse string to bool, err=%v\n", err) | ||
slog.Error(fmt.Sprintf("env: failed to parse string to bool, keys=%q value=%s err=%v", names, dt, err)) |
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.
Consider using slog's structured logging capabilities instead of fmt.Sprintf
to improve log readability and searchability.
slog.Error(fmt.Sprintf("env: failed to parse string to bool, keys=%q value=%s err=%v", names, dt, err)) | |
slog.Error("env: failed to parse string to bool", "keys", names, "value", dt, "err", err) |
}) | ||
|
||
configBytes = result.Of(os.ReadFile(cfgPath)).Expect("failed to read config data: %s", cfgPath) | ||
configBytes = cfgFormat(configBytes, &config{workDir: filepath.Dir(cfgPath)}) |
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.
if message == "" { | ||
message = err.Error() | ||
} else { | ||
message = fmt.Sprintf("msg:%s err:%s", message, err.Error()) |
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.
v, err := strconv.ParseFloat(dt, 64) | ||
if err != nil { | ||
log.Printf("env: failed to parse string to float, err=%v\n", err) | ||
slog.Error(fmt.Sprintf("env: failed to parse string to float, keys=%q value=%s err=%v", names, dt, err)) |
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.
Consider using slog's structured logging capabilities instead of fmt.Sprintf
to improve log readability and searchability.
slog.Error(fmt.Sprintf("env: failed to parse string to float, keys=%q value=%s err=%v", names, dt, err)) | |
slog.Error("env: failed to parse string to float", "keys", names, "value", dt, "err", err) |
} | ||
} | ||
|
||
func AsA[T any](err error) (*T, bool) { |
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.
e.Str("error_detail", errDetail(err)) | ||
e.Str(zerolog.ErrorFieldName, err.Error()) |
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.
) | ||
|
||
func NewSlog(log Logger) slog.Handler { | ||
return &slogImpl{l: log.WithCallerSkip(3)} |
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.
|
||
DeviceID = InstanceID |
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.
No description provided.