Skip to content

feat: a more convenient Result interface - #42

Open
volmedo wants to merge 1 commit into
mainfrom
vic/feat/result-convenient-interface
Open

feat: a more convenient Result interface#42
volmedo wants to merge 1 commit into
mainfrom
vic/feat/result-convenient-interface

Conversation

@volmedo

@volmedo volmedo commented Apr 21, 2025

Copy link
Copy Markdown
Contributor

Make Results easier to use by allowing access to Ok and Err values.

@volmedo
volmedo requested a review from a team April 21, 2025 15:43
@volmedo volmedo self-assigned this Apr 21, 2025
@codecov

codecov Bot commented Apr 21, 2025

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 4 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
core/result/result.go 0.00% 4 Missing ⚠️
Files with missing lines Coverage Δ
core/result/result.go 74.75% <0.00%> (-1.49%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@alanshaw

Copy link
Copy Markdown
Member

You're goign to have to check both of these values anyways, is unwrap not sufficient?

@volmedo

volmedo commented Apr 23, 2025

Copy link
Copy Markdown
Contributor Author

I have seen myself just checking one of them, depending on the use case, and having something you can just inline in an if feels more convenient.

@alanshaw

Copy link
Copy Markdown
Member

It's just more API surface area to maintain and IMO Unwrap suffices. Even if you're only using 1 value - just assign to underscore, that way you're at least acknowledging you're choosing to ignore the other value it could be.

data, _ := result.Unwrap(myresult)
_, err := result.Unwrap(myresult)

@volmedo

volmedo commented Apr 25, 2025

Copy link
Copy Markdown
Contributor Author

ok, I just wanted to streamline ifs without having to unwrap explicitly. Also, Unwrap returns the plain types (rather than pointer), which prevents you from doing a comparison with nil unless you use pointers yourself in all the type parameters when declaring receipts and results.

If the API surface is the issue, I can remove Unwrap 😝

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