edgedb / edgedb-go

The official Go client library for EdgeDB
https://pkg.go.dev/github.com/edgedb/edgedb-go
Apache License 2.0
168 stars 11 forks source link

Add convenience functions to transform between edgedb.Duration and time.Duration #304

Closed lsdch closed 6 months ago

lsdch commented 6 months ago

This is meant to improve usability of Duration values and better integrate with the Go ecosystem. This also makes the unit (micro/nanoseconds) difference between Duration and time.Duration more obvious, hopefully reducing the likelihood of introducing hard to detect bugs such as:


func ConvertDuration(d edgedb.Duration) time.Duration {
  return time.Duration(int64(d)) 
  // change from microseconds to nanoseconds representation is not taken care of, 
  // and the compiler can not help to prevent this
}
fmoor commented 6 months ago

Any last changes before I merge?

lsdch commented 6 months ago

Nothing comes to mind, looks like it is ready :rocket:

fmoor commented 6 months ago

released in v0.17.0