aidarkhanov / nanoid Goto Github PK
View Code? Open in Web Editor NEWA tiny and fast Go unique string generator
License: MIT License
A tiny and fast Go unique string generator
License: MIT License
../github.com/aidarkhanov/nanoid/nanoid.go:32:11: invalid operation: 2 << (31 - bits.LeadingZeros32(uint32(len(alphabet) - 1 | 1))) (shift count type int, must be unsigned integer)
It's give me this error when I try to get package with go get github.com/aidarkhanov/nanoid
It was working before this commit b8b9271
Hello!
I am trying read your implementation and docs (I want to generate identifiers only from symbols) - I found it and all right.
But in your README (you just copy that string, I know :)) you wrote that nanoid used more characters than UUID. I decide to compare your source code and original and found that you used different strings in default mode:
alphabet = "-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW"
let urlAlphabet = 'ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW'
It is not a problem - I can specify it by myself via Generate
, for example. But I think that all general implementation should work the same as original.
And I think that you should rewrite your code like:
// GenerateString generates a random string based on
// alphabet and size.
func GenerateString(alphabet string, size int) (string, error) {
id, err := FormatString(generateRandomBuffer, alphabet, size)
if err != nil {
return "", err
}
return id, nil
}
// New generates a random string.
func New() (string, error) {
return GenerateString(alphabet, size)
}
Because the original code looks like duplicate logic.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.