diff --git a/README.md b/README.md index e73722f..2fb08b3 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,6 @@ E-SOH datastore PoCs 4. Install the hooks defined in `.pre-commit-config.yaml` with `pre-commit install`. ### Useful Commands -- To update the pre-commit hooks in `.pre-commit-config.yaml` run: `pre-commit autoupdate`. -- To run the pre-commit for every file in the repository run `pre-commit run --config './.pre-commit-config.yaml' --all-files`. +- To update the pre-commit hooks in `.pre-commit-config.yaml` run: `pre-commit autoupdate` +- To run the pre-commit for every file in the repository run `pre-commit run --config './.pre-commit-config.yaml' --all-files` - To commit without the pre-commit hook `git commit -m "Some message" --no-verify` diff --git a/datastore/common/common.go b/datastore/common/common.go index 6439bff..ab2266f 100644 --- a/datastore/common/common.go +++ b/datastore/common/common.go @@ -12,7 +12,7 @@ import ( ) var ( - dynamicTime bool // whether the valid time range is considered dynamic or static + dynamicTime bool // whether the valid time range is considered dynamic or static loTimeSecs, hiTimeSecs int64 ) @@ -21,13 +21,13 @@ var ( // // The valid time range is defined like this if dynamicTime is true: // -// [now - loTimeSecs, now - hiTimeSecs] +// [now - loTimeSecs, now - hiTimeSecs] // // where {lo|hi}TimeSecs is converted directly as integer seconds from {LO|HI}TIME. // // If dynamicTime is false, the valid time range is defined like this: // -// [loTimeSecs, hiTimeSecs] +// [loTimeSecs, hiTimeSecs] // // where {lo|hi}TimeSecs is either converted directly as integer seconds from {LO|HI}TIME, or // converted indirectly from {LO|HI}TIME represented as an ISO-8601 datetime of the exact form @@ -53,7 +53,7 @@ func initValidTimeRange() { if t, err = iso8601ToTime(val0); err != nil { log.Printf( "WARNING: failed to parse %s as an ISO-8601 datetime of the form "+ - "2023-10-10T00:00:00Z: %s; falling back to default secs: %d", + "2023-10-10T00:00:00Z: %s; falling back to default secs: %d", name, val0, defaultVal) val = defaultVal } else { @@ -105,11 +105,11 @@ var iso8601layout = "2006-01-02T15:04:05Z" // note upper case! // iso8601ToTime converts time string ts of the form YYYY-MM-DDThh:mm:ssZ to time.Time. // Returns (val, nil) upon success, otherwise (time.Time{}, error). func iso8601ToTime(ts string) (time.Time, error) { - tm, err := time.Parse(iso8601layout, strings.ToUpper(ts)) - if err != nil { - return time.Time{}, fmt.Errorf("time.Parse() failed for %s: %v", ts, err) - } - return tm, nil + tm, err := time.Parse(iso8601layout, strings.ToUpper(ts)) + if err != nil { + return time.Time{}, fmt.Errorf("time.Parse() failed for %s: %v", ts, err) + } + return tm, nil } // Getenv returns the value of an environment variable or a default value if @@ -132,7 +132,7 @@ func Tstamp2float64Secs(tstamp *timestamppb.Timestamp) float64 { func GetValidTimeRange() (time.Time, time.Time) { if dynamicTime { // Case 1: dynamic time, i.e. relative to current time now := time.Now().Unix() - return time.Unix(now - loTimeSecs, 0), time.Unix(now - hiTimeSecs, 0) + return time.Unix(now-loTimeSecs, 0), time.Unix(now-hiTimeSecs, 0) } // Case 2: static time, i.e. based on fixed time (useful e.g. for certain testing!) diff --git a/datastore/storagebackend/postgresql/postgresql.go b/datastore/storagebackend/postgresql/postgresql.go index 8e439b4..3dbb4d3 100644 --- a/datastore/storagebackend/postgresql/postgresql.go +++ b/datastore/storagebackend/postgresql/postgresql.go @@ -196,4 +196,4 @@ func considerCleanup(db *sql.DB) error { } return nil -} \ No newline at end of file +}