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

proposal: affected/package: Normalized reflect function #60140

Closed
lee157953 opened this issue May 12, 2023 · 1 comment
Closed

proposal: affected/package: Normalized reflect function #60140

lee157953 opened this issue May 12, 2023 · 1 comment

Comments

@lee157953
Copy link

lee157953 commented May 12, 2023

// Indirect returns the value that v points to.
// If v is a nil pointer, Indirect returns a zero Value.
// If v is not a pointer, Indirect returns v.
// Deprecated: use Value.Indirect
func Indirect(v Value) Value {
	if v.Kind() != Pointer {
		return v
	}
	return v.Elem()
}

// Indirect returns the value that v points to.
// If v is a nil pointer, Indirect returns a zero Value.
// If v is not a pointer, Indirect returns v.
func (v Value) Indirect() Value {
	if v.Kind() != Pointer {
		return v
	}
	return v.Elem()
}

“Indirect()” have a similar function to “Elem()”,
Unified invocation mode is recommended

@gopherbot gopherbot added this to the Proposal milestone May 12, 2023
@seankhliao
Copy link
Member

reflect has operations that the language has. Go does not have such an operation.

See also https://go.dev/doc/faq#x_in_std

@seankhliao seankhliao closed this as not planned Won't fix, can't repro, duplicate, stale May 12, 2023
@golang golang locked and limited conversation to collaborators May 11, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants