Skip to content

Fix: FileWithLineNum#845

Open
nickxudotme wants to merge 1 commit intogo-gorm:masterfrom
nickxudotme:master
Open

Fix: FileWithLineNum#845
nickxudotme wants to merge 1 commit intogo-gorm:masterfrom
nickxudotme:master

Conversation

@nickxudotme
Copy link

@nickxudotme nickxudotme commented Feb 27, 2026

Explain your user case and expected results

I am creating a issue in GORM for further explain

Copilot AI review requested due to automatic review settings February 27, 2026 17:46
Copy link

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 pull request adds tests to verify the correct behavior of GORM's FileWithLineNum utility function and slog logger caller source reporting. The PR replaces the generic GORM functionality test with two focused tests that validate file/line number reporting works correctly when called from external functions and that the slog logger properly attributes log entries to the calling code rather than internal logger code.

Changes:

  • Added two new tests: TestFileWithLineNumExternal and TestSlogCallerSource to verify file/line number reporting
  • Updated go.mod with dependency version bumps (GORM v1.30.1 → v1.31.1, various driver updates) and added testify for assertions
  • Removed unused dependencies from go.mod

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
main_test.go Replaced generic GORM test with focused tests for FileWithLineNum functionality and slog caller source reporting
go.mod Updated dependencies including GORM core library, added testify, and cleaned up unused dependencies

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +30 to +31
expectedSuffix := fmt.Sprintf("%s:%d", filepath.ToSlash(file), expectedLine)
require.Equal(t, expectedSuffix, got)
Copy link

Copilot AI Feb 27, 2026

Choose a reason for hiding this comment

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

The variable is named 'expectedSuffix' but is used in an exact equality check on line 31. If the intent is to check for an exact match, consider renaming to 'expected' or 'expectedPath' for clarity. If the intent is to verify a suffix match, the assertion should use a suffix check instead of exact equality.

Suggested change
expectedSuffix := fmt.Sprintf("%s:%d", filepath.ToSlash(file), expectedLine)
require.Equal(t, expectedSuffix, got)
expectedPath := fmt.Sprintf("%s:%d", filepath.ToSlash(file), expectedLine)
require.Equal(t, expectedPath, got)

Copilot uses AI. Check for mistakes.
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