diff --git a/sonyflake.go b/sonyflake.go index 84fbd28..4d074d9 100644 --- a/sonyflake.go +++ b/sonyflake.go @@ -99,6 +99,15 @@ func New(st Settings) (*Sonyflake, error) { return sf, nil } +// Default creates and returns a new Sonyflake instance using the default configuration. +// +// It is equivalent to calling: +// +// New(Settings{}) +func Default() (*Sonyflake, error) { + return New(Settings{}) +} + // NewSonyflake returns a new Sonyflake configured with the given Settings. // NewSonyflake returns nil in the following cases: // - Settings.StartTime is ahead of the current time. @@ -109,6 +118,15 @@ func NewSonyflake(st Settings) *Sonyflake { return sf } +// DefaultSonyflake creates and returns a new Sonyflake instance using the default Settings. +// +// It is equivalent to calling: +// +// NewSonyflake(Settings{}) +func DefaultSonyflake() *Sonyflake { + return NewSonyflake(Settings{}) +} + // NextID generates a next unique ID. // After the Sonyflake time overflows, NextID returns an error. func (sf *Sonyflake) NextID() (uint64, error) { diff --git a/v2/sonyflake.go b/v2/sonyflake.go index 0ca2be4..b10e9c0 100644 --- a/v2/sonyflake.go +++ b/v2/sonyflake.go @@ -172,6 +172,15 @@ func New(st Settings) (*Sonyflake, error) { return sf, nil } +// Default creates and returns a new Sonyflake instance using the default configuration. +// +// It is equivalent to calling: +// +// New(Settings{}) +func Default() (*Sonyflake, error) { + return New(Settings{}) +} + // NextID generates a next unique ID as int64. // After the Sonyflake time overflows, NextID returns an error. func (sf *Sonyflake) NextID() (int64, error) {