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

log/slog: Documented value type for slog.SourceKey is wrong #62294

Closed
lostluck opened this issue Aug 25, 2023 · 3 comments
Closed

log/slog: Documented value type for slog.SourceKey is wrong #62294

lostluck opened this issue Aug 25, 2023 · 3 comments
Labels
Documentation NeedsFix The path to resolution is known, but the work has not been done.

Comments

@lostluck
Copy link

lostluck commented Aug 25, 2023

What version of Go are you using (go version)?

1.21.0

Does this issue reproduce with the latest release?

Yes

What operating system and processor architecture are you using (go env)?

N/A

What did you do?

Follow the documentation of slog.SourceKey and use it with a string value.

The constant slog.SourceKey is documented to have string values.

However, the wrapping example demonstrates that is has a *slog.Source value.

A different package used the example code to remove the directory from log lines. https://github.com/proullon/ramsql/blob/master/engine/log/log.go#L22, which my code indirectly depended on, triggering a type assertion error the error on log.

This problem exists in the [exp/slog package as well](https://pkg.go.dev/golang.org/x/exp/slog#SourceKey

What did you expect to see?

Document the type for SourceKey values as *slog.Source, which is the correct expected value.

Alternatively, the example needs to change.

What did you see instead?

SourceKey values are documented as strings. https://pkg.go.dev/log/slog#SourceKey)

@ianlancetaylor
Copy link
Contributor

CC @jba

@seankhliao seankhliao added the NeedsFix The path to resolution is known, but the work has not been done. label Aug 26, 2023
@gopherbot
Copy link

Change https://go.dev/cl/523215 mentions this issue: slog: fix documented type for SourceKey

@gopherbot
Copy link

Change https://go.dev/cl/523195 mentions this issue: log/slog: fix documented value type for SourceKey

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Documentation NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

4 participants