I have 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 the String()
function does not include the "zeros" to the numbers because they are of type inteiro
.
retornado: "8:0", desejado "08:00"
retornado "10:3", desejado "10:03"
This challenge prevents you from using the date
that is already built right into Go
.