Md5 on timestamp

(Sara D) #1

I am trying to hash the timestamp in my program:

h := md5.New()
t := time.Now()
io.WriteString(h, t)

Here’s what I get:

cannot use t (type time.Time) as type string in argument to io.WriteString

…and I cannot convert it to type String, or at least with what I have tried so far. Any ideas?

(Johan Dahl) #2

Hi is the function you want to use. There is also predefined formats for some common formats:

(Anyaddres) #3

How about this? You can call the String() method directly on the time instance. That will use the default format for the time string. Alternatively you could specify a format that you choose but you would need to be consistent.