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

fix(timeutil): remove unreachable panic() call #455

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

thp-canonical
Copy link
Contributor

This has been added in upstream snapd back in the day here:

Move conditionals to the correct case where they belong (e.g. >= -cutoffDays belongs to the "%d days ago", ...), and then just naturally move the non-special case of then.Format("2006-01-02") to the default case.

Looking at compiler explorer, it seems like Go (gc 1.21 on x86_64) can optimize out the old version's panic(), so it's just dead code in the source (as it should be): https://godbolt.org/z/fxqTzYfPv

@benhoyt
Copy link
Contributor

benhoyt commented Jul 18, 2024

Does this actually cause any problems? I'm not opposed to this, though might be better to get it into snapd first? Otherwise it seems to me "if it ain't broke, don't fix it".

@thp-canonical
Copy link
Contributor Author

Proposed fix in snapd: canonical/snapd#14427

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