mirror of
https://github.com/sony/sonyflake.git
synced 2026-09-12 10:36:02 +00:00
Upgrade Sonyflake to v2 (#66)
* Add v2 * Introduce staticcheck * Introduce golangci-lint * Add error checks * Add error checks * Lint v2 code * Improve CI trigger * Use io.ReadAll * Use int64 * Remove NewSonyflake * Fix errors * v2: Change MachineID, sequence, and AmazonEC2MachineID to int; update all usage and tests for type consistency * docs: update Settings struct in README to use int for MachineID and CheckMachineID (v2) * docs(v2): clarify Settings, StartTime, MachineID, and CheckMachineID comments and update README links and explanations * docs(v2/mock): improve comments and docstrings for mock implementations * docs(types): unify and clarify package and type docstrings for types.go in v1 and v2 * test(v2): refactor and modernize tests, improve error assertions, and update mocks for v2 * test(v2): normalize whitespace in pseudoSleep calls for consistency * feat(v2): add configurable TimeUnit and refactor time handling for So… (#67) * feat(v2): add configurable TimeUnit and refactor time handling for Sonyflake v2 * test(v2): add ToTime tests, clarify TimeUnit behavior, and update docs for v2 * gofmt
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
// Package mock offers implementations of interfaces defined in types.go
|
||||
// This allows complete control over input / output for any given method that consumes
|
||||
// a given type
|
||||
// Package mock offers mock implementations of interfaces defined in types.go.
|
||||
// This allows complete control over input / output for any given method that consumes a given type.
|
||||
package mock
|
||||
|
||||
import (
|
||||
@@ -10,7 +9,7 @@ import (
|
||||
"github.com/sony/sonyflake/types"
|
||||
)
|
||||
|
||||
// NewSuccessfulInterfaceAddrs returns a single private IP address
|
||||
// NewSuccessfulInterfaceAddrs returns a single private IP address.
|
||||
func NewSuccessfulInterfaceAddrs() types.InterfaceAddrs {
|
||||
ifat := make([]net.Addr, 0, 1)
|
||||
ifat = append(ifat, &net.IPNet{IP: []byte{192, 168, 0, 1}, Mask: []byte{255, 0, 0, 0}})
|
||||
@@ -20,14 +19,14 @@ func NewSuccessfulInterfaceAddrs() types.InterfaceAddrs {
|
||||
}
|
||||
}
|
||||
|
||||
// NewFailingInterfaceAddrs returns an error
|
||||
// NewFailingInterfaceAddrs returns an error.
|
||||
func NewFailingInterfaceAddrs() types.InterfaceAddrs {
|
||||
return func() ([]net.Addr, error) {
|
||||
return nil, fmt.Errorf("test error")
|
||||
}
|
||||
}
|
||||
|
||||
// NewFailingInterfaceAddrs returns an empty slice of addresses
|
||||
// NewNilInterfaceAddrs returns an empty slice of addresses.
|
||||
func NewNilInterfaceAddrs() types.InterfaceAddrs {
|
||||
return func() ([]net.Addr, error) {
|
||||
return []net.Addr{}, nil
|
||||
|
||||
Reference in New Issue
Block a user