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

github: fix defer in for loop #256

Merged
merged 2 commits into from
Jan 23, 2024
Merged

github: fix defer in for loop #256

merged 2 commits into from
Jan 23, 2024

Conversation

zchee
Copy link
Contributor

@zchee zchee commented Jan 9, 2024

Description

Fix defer in for loop.
In Go idioms, "defer" inside a for loop is not good.

Test results

$ go test -v -race -count=1 -shuffle=on -run=. ./github
-test.shuffle 1704783961903108000
=== RUN   Test_validateAPIObject
=== RUN   Test_validateAPIObject/no_error_=>_nil
=== RUN   Test_validateAPIObject/one_error_=>_MultiError_&_InvalidServerData
--- PASS: Test_validateAPIObject (0.00s)
    --- PASS: Test_validateAPIObject/no_error_=>_nil (0.00s)
    --- PASS: Test_validateAPIObject/one_error_=>_MultiError_&_InvalidServerData (0.00s)
=== RUN   Test_allPages
=== RUN   Test_allPages/one_page_only,_no_error
=== RUN   Test_allPages/two_pages,_no_error
=== RUN   Test_allPages/four_pages,_error_at_second
--- PASS: Test_allPages (0.00s)
    --- PASS: Test_allPages/one_page_only,_no_error (0.00s)
    --- PASS: Test_allPages/two_pages,_no_error (0.00s)
    --- PASS: Test_allPages/four_pages,_error_at_second (0.00s)
=== RUN   Test_getPermissionFromMap
=== RUN   Test_getPermissionFromMap/pull
=== RUN   Test_getPermissionFromMap/push
=== RUN   Test_getPermissionFromMap/admin
=== RUN   Test_getPermissionFromMap/none
=== RUN   Test_getPermissionFromMap/false_data
=== RUN   Test_getPermissionFromMap/not_all_specifed
--- PASS: Test_getPermissionFromMap (0.00s)
    --- PASS: Test_getPermissionFromMap/pull (0.00s)
    --- PASS: Test_getPermissionFromMap/push (0.00s)
    --- PASS: Test_getPermissionFromMap/admin (0.00s)
    --- PASS: Test_getPermissionFromMap/none (0.00s)
    --- PASS: Test_getPermissionFromMap/false_data (0.00s)
    --- PASS: Test_getPermissionFromMap/not_all_specifed (0.00s)
=== RUN   Test_DomainVariations
=== RUN   Test_DomainVariations/github.com_domain
=== RUN   Test_DomainVariations/custom_domain_without_protocol
=== RUN   Test_DomainVariations/custom_domain_with_https_protocol
=== RUN   Test_DomainVariations/custom_domain_with_http_protocol
--- PASS: Test_DomainVariations (0.00s)
    --- PASS: Test_DomainVariations/github.com_domain (0.00s)
    --- PASS: Test_DomainVariations/custom_domain_without_protocol (0.00s)
    --- PASS: Test_DomainVariations/custom_domain_with_https_protocol (0.00s)
    --- PASS: Test_DomainVariations/custom_domain_with_http_protocol (0.00s)
=== RUN   ExampleOrganizationsClient_Get
--- PASS: ExampleOrganizationsClient_Get (0.22s)
=== RUN   ExampleOrgRepositoriesClient_Get
--- PASS: ExampleOrgRepositoriesClient_Get (0.23s)
PASS
ok      github.com/fluxcd/go-git-providers/github       1.477s

@zchee zchee force-pushed the fix-for-loop-defer branch from 2a6b4bb to 0041d94 Compare January 17, 2024 06:17
@zchee
Copy link
Contributor Author

zchee commented Jan 17, 2024

@souleb
Fix to use errors.Join and check errors lazily. PTAL

@zchee zchee requested a review from souleb January 17, 2024 06:19
@souleb
Copy link
Member

souleb commented Jan 22, 2024

That's good to me. Can you rebase your pr?

@zchee zchee force-pushed the fix-for-loop-defer branch from 0041d94 to 5d24c20 Compare January 23, 2024 19:45
@zchee
Copy link
Contributor Author

zchee commented Jan 23, 2024

@souleb rebased. (do you mean "squash"?)
PTALA

Copy link
Member

@souleb souleb left a comment

Choose a reason for hiding this comment

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

LGTM! thanks @zchee

@souleb souleb merged commit 6e50bf5 into fluxcd:main Jan 23, 2024
6 checks passed
@zchee zchee deleted the fix-for-loop-defer branch January 23, 2024 21:42
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