Giter VIP home page Giter VIP logo

go-snowflake's Introduction

Hello there 👋 godruoyi

Hi there, I work remotely and enjoy using open-source and efficient tools.

  • 🔭 Interested in full stack. Focus on backend.
  • 🌱 Currently learning Golang and Rust.
  • 💻 With 6 years of development working experience.
  • 👒 About me more.
From: 11 September 2024 - To: 18 September 2024

Go             9 hrs 8 mins    ███████████████▒░░░░░░░░░   61.03 %
Java           5 hrs 3 mins    ████████▒░░░░░░░░░░░░░░░░   33.76 %
Text           12 mins         ▒░░░░░░░░░░░░░░░░░░░░░░░░   01.39 %
YAML           12 mins         ▒░░░░░░░░░░░░░░░░░░░░░░░░   01.36 %
Markdown       10 mins         ▒░░░░░░░░░░░░░░░░░░░░░░░░   01.14 %

go-snowflake's People

Contributors

0xflotus avatar godruoyi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

go-snowflake's Issues

Try to got unique id concurrently

package tests

import (
	"fmt"
	mapset "github.com/deckarep/golang-set/v2"
	"testing"
)

func TestCache(t *testing.T) {
	ids := mapset.NewSet[uint64]()
	for i := 1; i <= 10000; i++ {
		go func() {
			id, _ := snowflake.NextID()
			if ids.Contains(id) {
				fmt.Printf("repeat id %d", id)
			}

			ids.Add(id)
		}()

	}

	fmt.Printf("%v \n", ids.Cardinality())

}

try to concurrently to got unique id by such example. Always got such like

6335

Do you have some suggestions try to make this test case got

10000 

android-armv7a build issue

Building on a 32 bit platform results in the following error

/go/pkg/mod/github.com/godruoyi/[email protected]/snowflake.go:65:20: MaxTimestamp (untyped int constant 2199023255551) overflows int

I believe the problem is related with the definition of MaxTimestamp:
MaxTimestamp = 1<<TimestampLength - 1

On a 32-bit platform, int is 32bit, which would not fit the above expression.
I believe some variables should be redefined with int64 instead than int, so to assure cross-compilation

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.