[tor-bugs] #33038 [Circumvention/Snowflake]: Represent timeouts using time.Duration

Tor Bug Tracker & Wiki blackhole at torproject.org
Thu Jan 23 18:06:10 UTC 2020


#33038: Represent timeouts using time.Duration
-----------------------------------------+----------------------
     Reporter:  dcf                      |      Owner:  dcf
         Type:  enhancement              |     Status:  assigned
     Priority:  Medium                   |  Milestone:
    Component:  Circumvention/Snowflake  |    Version:
     Severity:  Minor                    |   Keywords:
Actual Points:                           |  Parent ID:
       Points:                           |   Reviewer:
      Sponsor:                           |
-----------------------------------------+----------------------
 Representing these constants in `time.Duration` form is more semantic, and
 allows rewriting
 {{{
 if time.Since(start).Seconds() > myTimeout {
 }}}
 as
 {{{
 if time.Since(start) > myTimeout {
 }}}

 One side effect is that `Printf` formatting
 [https://golang.org/pkg/time/#Duration.String renders] a `time.Duration`
 as a string like `10s` or `100ms`, which changes some log messages
 slightly. If we need compatibility of log message formats, we could use
 `.Seconds()` in those places.

--
Ticket URL: <https://trac.torproject.org/projects/tor/ticket/33038>
Tor Bug Tracker & Wiki <https://trac.torproject.org/>
The Tor Project: anonymity online


More information about the tor-bugs mailing list