Skip to content

Fix: fixed bug in go example #1595

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

Merged
merged 2 commits into from
Jul 18, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go/example/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func printAboutMe(sdk *v4.LookerSDK) {
fmt.Printf("Error getting myself %v\n", err)
}
if len(users) != 1 {
fmt.Printf("Found %d users with my email expected 1\n")
fmt.Printf("Found %d users with my email expected 1\n", len(users))

Choose a reason for hiding this comment

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

medium

The fix to include len(users) is correct, thanks for catching that.

To improve this, I suggest writing this warning message to stderr instead of stdout, which is a common practice for diagnostic messages in Go. This separates them from the program's primary output.

Also, please note that if sdk.SearchUsers returns an error, this line will still be executed. It would be more robust to check len(users) only when the API call is successful. While I can't suggest a change for the surrounding logic due to PR constraints, here's a suggestion for the current line:

Suggested change
fmt.Printf("Found %d users with my email expected 1\n", len(users))
fmt.Fprintf(os.Stderr, "Warning: Found %d users with my email, expected 1\n", len(users))

}
}

Expand Down
Loading