Go R1 Day 68
tech development 100DaysOfCode golang microblog
progress
- Did exercism.io for gigasecond puzzle.
package gigasecond
// import path for the time package from the standard library
import (
"time"
)
// gigasecond represents a very very very small portion of a second.
const gigasecond = 1000000000
// AddGigasecond adds a very very very small portion of a second called a gigasecond to a provided time input.
func AddGigasecond(t time.Time) time.Time {
gcDuration := gigasecond * time.Second
n := t.Add(gcDuration)
return n
}
- Learned a bit more about using
Math.Pow(), conversion of floats/ints, and dealing with time.Duration. - Tried using
Math.Pow()to work through the issue, but got mixed up when usingtime.Duration()which expects nanoseconds, and such. Went ahead and just used a constant for the exercise as not likely to use gigaseconds anytime soon. š