2 Commits

Author SHA1 Message Date
Yoshiyuki Mineo
59c47aeab1 Fix lint errors (#70) 2025-05-05 19:51:28 +09:00
Yoshiyuki Mineo
d764be18d5 Update README.md (#69)
* Update README.md

* Update README.md

* Update test-v2.yml

* Update test-v1.yml
2025-05-05 14:46:40 +09:00
11 changed files with 44 additions and 31 deletions

View File

@@ -3,12 +3,16 @@ name: CI for v1 Module
on:
push:
paths-ignore:
- README.md
- .github/workflows/test-v2.yml
- 'v2/**'
- v2/**
pull_request:
paths-ignore:
- README.md
- .github/workflows/test-v2.yml
- 'v2/**'
- v2/**
permissions: read-all
jobs:
test-v1:
@@ -28,7 +32,7 @@ jobs:
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v2
uses: actions/setup-go@v5
with:
go-version: ${{matrix.go-version}}

View File

@@ -3,12 +3,16 @@ name: CI for v2 Module
on:
push:
paths:
- README.md
- .github/workflows/test-v2.yml
- 'v2/**'
- v2/**
pull_request:
paths:
- README.md
- .github/workflows/test-v2.yml
- 'v2/**'
- v2/**
permissions: read-all
jobs:
test-v2:

2
.gitignore vendored
View File

@@ -1,2 +1,4 @@
example/example
example/sonyflake_server
v2/example/example
v2/example/sonyflake_server

View File

@@ -1,7 +1,7 @@
# Sonyflake
[![GoDoc](https://godoc.org/github.com/sony/sonyflake?status.svg)](http://godoc.org/github.com/sony/sonyflake)
[![Go Report Card](https://goreportcard.com/badge/github.com/sony/sonyflake)](https://goreportcard.com/report/github.com/sony/sonyflake)
[![GoDoc](https://pkg.go.dev/badge/github.com/sony/sonyflake/v2?utm_source=godoc)](https://pkg.go.dev/github.com/sony/sonyflake/v2)
[![Go Report Card](https://goreportcard.com/badge/github.com/sony/sonyflake/v2)](https://goreportcard.com/report/github.com/sony/sonyflake/v2)
Sonyflake is a distributed unique ID generator inspired by [Twitter's Snowflake](https://blog.twitter.com/2010/announcing-snowflake).

View File

@@ -1,6 +1,9 @@
FROM ubuntu:14.04
ADD ./sonyflake_server /
ENTRYPOINT ["/sonyflake_server"]
COPY ./sonyflake_server /sonyflake_server
RUN useradd -m sonyflake
USER sonyflake
ENTRYPOINT ["/sonyflake_server"]
EXPOSE 8080

View File

@@ -1,21 +1,19 @@
Example
=======
# Example
This example runs Sonyflake on AWS Elastic Beanstalk.
Setup
-----
## Setup
1. Build the cross compiler for linux/amd64 if using other platforms.
```
cd $GOROOT/src && GOOS=linux GOARCH=amd64 ./make.bash
```
```bash
cd $GOROOT/src && GOOS=linux GOARCH=amd64 ./make.bash
```
2. Build sonyflake_server in the example directory.
```
./linux64_build.sh
```
```bash
./linux64_build.sh
```
3. Upload the example directory to AWS Elastic Beanstalk.

View File

@@ -1,6 +1,9 @@
FROM ubuntu:24.04
ADD ./sonyflake_server /
ENTRYPOINT ["/sonyflake_server"]
COPY ./sonyflake_server /sonyflake_server
RUN useradd -m sonyflake
USER sonyflake
ENTRYPOINT ["/sonyflake_server"]
EXPOSE 8080

View File

@@ -1,21 +1,19 @@
Example
=======
# Example
This example runs Sonyflake on AWS Elastic Beanstalk.
Setup
-----
## Setup
1. Build the cross compiler for linux/amd64 if using other platforms.
```
cd $GOROOT/src && GOOS=linux GOARCH=amd64 ./make.bash
```
```bash
cd $GOROOT/src && GOOS=linux GOARCH=amd64 ./make.bash
```
2. Build sonyflake_server in the example directory.
```
./linux64_build.sh
```
```bash
./linux64_build.sh
```
3. Upload the example directory to AWS Elastic Beanstalk.

View File

@@ -247,6 +247,7 @@ func lower16BitPrivateIP(interfaceAddrs types.InterfaceAddrs) (int, error) {
return int(ip[2])<<8 + int(ip[3]), nil
}
// ToTime returns the time when the given ID was generated.
func (sf *Sonyflake) ToTime(id int64) time.Time {
return time.Unix(0, (sf.startTime+sf.timePart(id))*sf.timeUnit)
}