TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Show HN: Go library for concise, unambiguous and URL-safe UUIDs

50 点作者 Spiritus超过 9 年前

5 条评论

shawnps超过 9 年前
Ran it through an app I maintain, Go Report Card, and it got an A+ grade: <a href="http:&#x2F;&#x2F;goreportcard.com&#x2F;report&#x2F;renstrom&#x2F;shortuuid" rel="nofollow">http:&#x2F;&#x2F;goreportcard.com&#x2F;report&#x2F;renstrom&#x2F;shortuuid</a><p>I&#x27;m actually pretty surprised, as I do this quite often and it&#x27;s rare that something gets 100% across the board on the first try. Not that it&#x27;s necessarily difficult, but I find people normally don&#x27;t use all 3 of &quot;gofmt -s&quot;, &quot;golint&quot;, and &quot;go vet&quot;. Anyway, nicely done.
评论 #10522709 未加载
thwarted超过 9 年前
The goals of unambiguous and concise are at odds, and this format (well, the defaults) errs on the side of shorter.<p>To lessen ambiguity even more, there&#x27;s Crockford Encoding[0]. Results in longer strings, but there&#x27;s no case distinction, and the similar looking characters decode the same. Looks like you can get mostly Crockford Encoding using this library by changing the character set (which is why said &quot;the defaults&quot; above). The check digit in Crockford Encoding is a huge win for when these are dictated&#x2F;transcribed, but may need to be URL-encoded.<p>[0] <a href="http:&#x2F;&#x2F;www.crockford.com&#x2F;wrmg&#x2F;base32.html" rel="nofollow">http:&#x2F;&#x2F;www.crockford.com&#x2F;wrmg&#x2F;base32.html</a>
评论 #10520988 未加载
swah超过 9 年前
My Go is rusty, but this look a little error prone:<p><pre><code> &#x2F;&#x2F; Note that this will create a new UUID each time its .String() method &#x2F;&#x2F; is invoked. fmt.Printf(&quot;%s&quot;, u) &#x2F;&#x2F; Cekw67uyMpBGZLRP2HFVbe fmt.Printf(&quot;%s&quot;, u) &#x2F;&#x2F; 4pUYNRFHTG3YVgThPZvCgC </code></pre> Just imagine an user using u directly instead of assigning to a var:<p><pre><code> token := &quot;secret&quot; + u othertoken := &quot;app&quot; + u</code></pre>
评论 #10520333 未加载
评论 #10520301 未加载
Spiritus超过 9 年前
As mentioned in the README, it&#x27;s heavily based on the Python version[1].<p>[1] <a href="https:&#x2F;&#x2F;github.com&#x2F;stochastic-technologies&#x2F;shortuuid" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;stochastic-technologies&#x2F;shortuuid</a>
sdegutis超过 9 年前
I thought UUIDs had to be 128 bits, such as &quot;de305d54-75b4-431b-adb2-eb6b9e546014&quot; (32 x 4-bit characters, not counting hypens). How is &quot;ajLWxEodc6CmQLHADuKVwD&quot; a UUID?
评论 #10520780 未加载
评论 #10520766 未加载