snapd icon indicating copy to clipboard operation
snapd copied to clipboard

fix(timeutil): remove unreachable panic() call

Open thp-canonical opened this issue 1 year ago • 0 comments

Stumbled upon this while looking for

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

  • https://github.com/canonical/snapd/pull/4775

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


Related proposed downstream Pebble patch: https://github.com/canonical/pebble/pull/455

thp-canonical avatar Aug 27 '24 04:08 thp-canonical