mirror of
https://github.com/coder/coder.git
synced 2025-07-03 16:13:58 +00:00
chore: refactor time.Duration -> int64 milliseconds for FE consumption (#1944)
* Changes all public-facing codersdk types to use a plain int64 (milliseconds) instead of time.Duration. * Makes autostart_schedule a *string as it may not be present. * Adds a utils/ptr package with some useful methods.
This commit is contained in:
23
coderd/util/ptr/ptr.go
Normal file
23
coderd/util/ptr/ptr.go
Normal file
@ -0,0 +1,23 @@
|
||||
// Package ptr contains some utility methods related to pointers.
|
||||
package ptr
|
||||
|
||||
import "golang.org/x/exp/constraints"
|
||||
|
||||
type number interface {
|
||||
constraints.Integer | constraints.Float
|
||||
}
|
||||
|
||||
// Ref returns a reference to v.
|
||||
func Ref[T any](v T) *T {
|
||||
return &v
|
||||
}
|
||||
|
||||
// NilOrEmpty returns true if s is nil or the empty string.
|
||||
func NilOrEmpty(s *string) bool {
|
||||
return s == nil || *s == ""
|
||||
}
|
||||
|
||||
// NilOrZero returns true if v is nil or 0.
|
||||
func NilOrZero[T number](v *T) bool {
|
||||
return v == nil || *v == 0
|
||||
}
|
Reference in New Issue
Block a user