From e53d2e57bbae21646fdf119f68533a809575944e Mon Sep 17 00:00:00 2001 From: Yoshiyuki Mineo Date: Mon, 14 Aug 2023 00:56:40 +0900 Subject: [PATCH] Update error messages and comments --- sonyflake.go | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/sonyflake.go b/sonyflake.go index 12df0ab..548b243 100644 --- a/sonyflake.go +++ b/sonyflake.go @@ -53,16 +53,19 @@ type Sonyflake struct { } var ( - ErrStartTimeAhead = errors.New("the start time cannot be in the future") - ErrNoPrivateAddress = errors.New("no private IP address") + ErrStartTimeAhead = errors.New("start time is ahead of now") + ErrNoPrivateAddress = errors.New("no private ip address") ErrOverTimeLimit = errors.New("over the time limit") - ErrInvalidMachineID = errors.New("invalid machine ID") + ErrInvalidMachineID = errors.New("invalid machine id") ) var defaultInterfaceAddrs = net.InterfaceAddrs -// New returns a new Sonyflake configured with the given Settings. If an error occurs, -// the *sonyflake.Sonyflake pointer will be nil and an error instance will be returned. +// New returns a new Sonyflake configured with the given Settings. +// New returns an error in the following cases: +// - Settings.StartTime is ahead of the current time. +// - Settings.MachineID returns an error. +// - Settings.CheckMachineID returns false. func New(st Settings) (*Sonyflake, error) { if st.StartTime.After(time.Now()) { return nil, ErrStartTimeAhead