TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Show HN: link shortening API in Go

16 pointsby jnye131over 11 years ago

4 comments

redbadover 11 years ago
<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 未加载
tekacsover 11 years ago
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 未加载
betamikeover 11 years ago
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 未加载
drsintomaover 11 years ago
&gt; 502 Bad Gateway<p>I believe your go process crashed. Consider using something like runit or supervisord.
评论 #7231832 未加载
评论 #7231169 未加载