It’s easier if I explain the impact, but I will use code for it as well.
The other time I am trying to use is a time.Time() object, specifically obtained by initially using a Unix Epoch time (in milliseconds, as a uint64) which is converted into a Time() object using:
timeStampNewFormat := time.Unix(0, int64(timeOriginalUnixMilli)*int64(time.Second))
This is used for another operation first (the simulation and then subsequent calculation of the data I would like to capture for InfluxDB), then is passed into the function shared initially as a time.Time() object and is ultimately uploaded as Var9 (in the initially shared function)
After calculating the data, I check the influxDB database first to make sure that I am not going to write data points that already exist. I do this through using another function which sets an upper and lower bound on time calculated, by querying the database and looking for the first and last timeStampNewFormat (Var9) that is written for each set of data (exporting through a variable named timeScale
as a map[string]TimeStruct
, of which TimeStruct contains two time.Time() objects). That is, the Time objects are compared using:
if timeStampNewFormat.Before(timeDayLimit) &&
(timeStampNewFormat.Before(timeScale[chosenDataSet].Start) || timeStampNewFormat.After(timeScale[chosenDataSet].End)) {
WriteToInflux(dataState, clientDB, timeStampNewFormat)
However, if there is no data in the bucket- as in, no data has been written to it - the map is empty, and thus a search for times using this if statement causes a segmentation fault.
Therefore, if instead of time.Now() in the first function, I use
SetTime(timeStampNewFormat)
The resulting effect is
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1...
As the bucket is empty, with no data having been written to it.
However, a few seconds after the segfault, some data does arrive in the bucket, with the time accurate to was supposed to be written. However, it’s only a little bit of data. Repeating the program allows it to run without segfaults, but not all of the data arrives at the server.