Skip to content
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

[documentation] <Scope Issue in Example Code for retrieval and type-assertion> #283

Open
1 task done
apxamccallum opened this issue Nov 12, 2024 · 0 comments
Open
1 task done
Labels

Comments

@apxamccallum
Copy link

apxamccallum commented Nov 12, 2024

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

sessions/doc.go

Lines 140 to 145 in bb4cd60

// Retrieve our struct and type-assert it
val := session.Values["person"]
var person = &Person{}
if person, ok := val.(*Person); !ok {
// Handle the case that it's not an expected type
}

In this example val.(*Person) will not be assigned to person as it is outside of the if statement scope.

Suggested Correction

// Retrieve our struct and type-assert it
val := session.Values["person"]
person, ok := val.(*Person)
if !ok {
	// Handle the case that it's not an expected type
}
@apxamccallum apxamccallum changed the title [documentation] <Scope Issue in Example Code for Flashes> [documentation] <Scope Issue in Example Code for retrieval and type-assertion> Nov 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant