mirror of
https://github.com/sony/sonyflake.git
synced 2026-11-22 08:06:28 +00:00
v2: Change MachineID, sequence, and AmazonEC2MachineID to int; update all usage and tests for type consistency
This commit is contained in:
1 parent
585f877536
commit
fd450d1c8e
5 files changed
+42
-43
No files matched your search
@@ -34,13 +34,13 @@ func amazonEC2PrivateIPv4() (net.IP, error) {
|
||||
// AmazonEC2MachineID retrieves the private IP address of the Amazon EC2 instance
|
||||
// and returns its lower 16 bits.
|
||||
// It works correctly on Docker as well.
|
||||
func AmazonEC2MachineID() (int64, error) {
|
||||
func AmazonEC2MachineID() (int, error) {
|
||||
ip, err := amazonEC2PrivateIPv4()
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
return int64(uint16(ip[2])<<8 + uint16(ip[3])), nil
|
||||
return int(ip[2])<<8 + int(ip[3]), nil
|
||||
}
|
||||
|
||||
// TimeDifference returns the time difference between the localhost and the given NTP server.
|
||||
|
||||
Reference in new issue
Block a user