Skip to content

chore: refactor formatter and value functions#3

Merged
rjfonseca merged 1 commit into
mainfrom
chore/refactor-formatter
Jun 13, 2025
Merged

chore: refactor formatter and value functions#3
rjfonseca merged 1 commit into
mainfrom
chore/refactor-formatter

Conversation

@rjfonseca
Copy link
Copy Markdown
Member

Refactor the Value functions and the formatter to fix an error with the formatter when the key was not a string.

The Value* functions were refactored to be more consistent. Now Value* returnas always the first occurrence and Values* returns all occurrences of a key.

Now the formatter will print all the keys in the reverse order of creation (most recent first).

Other formatters were added for convenience.

Refactor the Value functions and the formatter to fix an error with the
formatter when the key was not a string.

The Value* functions were refactored to be more consistent. Now Value*
returnas always the first occurrence and Values* returns all occurrences
of a key.

Now the formatter will print all the keys in the reverse order of
creation (most recent first).

Other formatters were added for convenience.
Copilot AI review requested due to automatic review settings June 11, 2025 20:48
@rjfonseca rjfonseca requested a review from xico42 as a code owner June 11, 2025 20:48
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR refactors how key-value pairs are retrieved and formatted in errors, fixes a formatter error when keys aren’t strings, and adds convenience formatters.

  • Extracted and unified Value*/Values* helpers into value.go to consistently return most recent or all occurrences.
  • Revised formatter logic in formatter.go to use ValueAllSlice with new write* helpers and introduced RootErrorFormatter and RootErrorKVFormater.
  • Updated KV constructor and stringify in kv.go and adjusted tests in formatter_test.go for multi-type values.

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
value.go New dedicated file for Value/Values/Map helpers
kv.go Adjusted KV constructor and improved stringify
formatter.go Refactored main formatter, added helper writers & new formatters
formatter_test.go Test updated for mixed-type key-value formatting
error.go Removed duplicate retrieval functions, streamlined Error
error_test.go Removed empty test file
Comments suppressed due to low confidence (2)

formatter.go:8

  • The comment refers to FullFormatter but the actual function and constant are named FullFormater (one ‘t’). Update the comment to match the code or rename the function for consistency.
// DefaultFormatter is the default formatter used when no custom formatter is set.

formatter.go:46

  • The function name FullFormater (and similarly RootErrorKVFormater) is misspelled—‘Formatter’ is typically spelled with two ‘t’s. Consider renaming to FullFormatter for clarity.
func FullFormater(err error) string {

Comment thread value.go
Comment thread formatter.go
@rjfonseca rjfonseca self-assigned this Jun 12, 2025
@rjfonseca rjfonseca merged commit 43abef7 into main Jun 13, 2025
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.

3 participants