I have this snippet of C code that I'm trying to translate to Go:
#include <sys/time.h>
#include <sys/types.h>
#include <inttypes.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
int main()
{
struct timeval started;
int64_t ms;
gettimeofday(&started, NULL);
ms = (int64_t) started.tv_sec * 1000 + started.tv_usec / 1000;
printf("Time: %011"PRIx64"\n", ms);
return 0;
}
I've found how to convert unix time to millieseconds by using the below snippet:
package main
import (
"fmt"
"time"
)
func main() {
fmt.Printf("Unix Time in ms: %d \n", time.Now().UnixNano() / 1000000)
}
However I'm having a hard time how to convert that number into hexadecimal (That somewhat resembles the output of the C code that I have.) I did find how to decode the hextime stamp using this questions / answer. Can anyone point me in the right direction?