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

科技回声

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

GitHubTwitter

首页

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

资源链接

HackerNews API原版 HackerNewsNext.js

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

Show HN: link shortening API in Go

16 点作者 jnye131超过 11 年前

4 条评论

redbad超过 11 年前
<p><pre><code> import ( &quot;.&#x2F;utils&quot; </code></pre> This is what&#x27;s known as a relative import, and it&#x27;s very bad. You want &quot;github.com&#x2F;johnnye&#x2F;short&#x2F;utils&quot;, or (better yet) put your base62 stuff in package main, since it&#x27;s just one function.
评论 #7231761 未加载
评论 #7232029 未加载
tekacs超过 11 年前
Whilst they are nonetheless interesting and worth seeing, there really does seem to be an abundance of really small (30-200 SLoC) projects being posted and reaching the front page recently. I&#x27;m just curious because I&#x27;d usually consider these sorts of things ~20 minutes&#x27; work (plus potentially a more meaningful amount of time writing the documentation). They stand out to me in this sense amongst all the blog posts and stories which almost invariably will have taken a great deal more time and effort to produce. [1]<p>Any thoughts? Indeed any prior discussion?<p>[1]: Not to say that this isn&#x27;t a nice idea. :)
评论 #7231773 未加载
betamike超过 11 年前
Very cool. If you have a recent enough version of Redis, you may want to move away from doing the lookup using KEYS and move to SCAN (<a href="http://redis.io/commands/scan" rel="nofollow">http:&#x2F;&#x2F;redis.io&#x2F;commands&#x2F;scan</a>). KEYS will work for a while, but with a large enough DB it can become a very slow operation so it&#x27;s not typically recommended for a production system.<p>Also, just curious, I see that the original url is encoded in the key, so the key is &quot;&lt;short&gt;||&lt;original&gt;&quot;. Since the key is already a hash, it seems that you could eliminate having to scan over every key in Redis by making each key be only &quot;&lt;short&gt;&quot; and having an additional field in the hash for &quot;original&quot;. Then a lookup becomes simply an HGETALL (if you need to get the &quot;count&quot; field, otherwise just an HGET for the &quot;original&quot; field). I might be missing something though! &lt;&#x2F;armchair programming&gt;
评论 #7231786 未加载
drsintoma超过 11 年前
&gt; 502 Bad Gateway<p>I believe your go process crashed. Consider using something like runit or supervisord.
评论 #7231832 未加载
评论 #7231169 未加载