1
I own a struct
with 2 ints
and I need to return these values in string
but in time format.
type Clock struct {
hour int
minute int
}
func New(hour, minute int) Clock {
return Clock{hour, minute}
}
func (c Clock) String() string {
return strconv.Itoa(c.hour) + ":" + strconv.Itoa(c.minute)
}
The return of function String()
does not include the "zeros" due to the numbers as they are of the type inteiro
.
retornado: "8:0", desejado "08:00"
retornado "10:3", desejado "10:03"
This challenge is to not use the date
which already comes embedded just to the Go
.
thanks, but the challenge says I can’t use the package
time
, I’m breaking my head to create the functionAdd()
for seconds!– RFL