[HN Gopher] Show HN: A HN clone writen in Go
___________________________________________________________________
Show HN: A HN clone writen in Go
I've been trying to write my "go on rails" framework for years. I
never quite got it like I wanted. There is gin and echo and all
sorts of other frameworks and patterns but I finally found
something I really like: /foo/ /foo/bar/ /foo/bar/more/ That's
it. Just three levels and all my controllers get passed in what's
between the / with var names first, second, third. In order to
really make sure this framework could build something real I made a
Hacker News clone. RemoteRenters.com is a HN just for articles
about the remote work revolution since covid. Feel free to vote or
submit to see how it all works! Code is open source at:
https://github.com/andrewarrow/feedback
Author : andrewfromx
Score : 60 points
Date : 2023-03-05 20:02 UTC (2 hours ago)
(HTM) web link (remoterenters.com)
(TXT) w3m dump (remoterenters.com)
| imoverclocked wrote:
| Whenever I see code like the example routing, I have to wonder if
| a hash lookup would be more appropriate. This is especially when
| all the functions called are of exactly the same form, I
| immediately just want an interface for that and then define a map
| from "first" to handler.
|
| The counter point in some languages (eg: Java) is that switch
| statements/expressions handle it this way under the hood at
| compile time depending on if it's more efficient to use a map or
| a bunch of checks.
|
| What is the actual best practice in go these days?
| hombre_fatal wrote:
| When routing is static, it's trivial and any solution will
| work. Like when your routes are all static /foo/bar and they
| merely use ?query params to pass info.
|
| Not sure what you're asking, but handling dynamic segment
| routing ergonomically is where naive solutions tend to fail.
|
| For example, a simple trie/map router needs additional logic to
| backtrack and try downstream routes. You wouldn't want `GET
| /users/42/show` to 404 in the following route table.
| /users/42/admin /users/:id/show
| app4soft wrote:
| Worth to add in the title:
|
| > _An HN clone written in Go with Google 's telemetry_[0]
|
| [0] https://news.ycombinator.com/item?id=34744948
| nvknfhnvd wrote:
| No, a build time option that can be disabled is not relevant to
| the post
|
| Do you pedantically point out that end users have to accept
| Oracle's end user license agreement to install the JRE when
| someone posts something written in Java, or that mp3s are
| patent encumbered when someone posts a music player? For crying
| out loud
|
| Also, the FUD you linked to says the feature MAY be shipped. It
| hasn't even actually happened.
|
| Go away.
| nottorp wrote:
| > Also, the FUD you linked to says the feature MAY be
| shipped.
|
| Doesn't it worry you that they'd even consider this kind of
| stuff?
|
| Also, a proposal by one of their developers is not FUD. Maybe
| suicide.
| mseepgood wrote:
| Also, the current plan is that it would be opt-in. You'd have
| to explicitly enable it.
| saagarjha wrote:
| There is no Google telemetry in the site. Pattern matching on
| "Go" with whatever your recent issue is with it is a bad
| comment.
| kitd wrote:
| Good job.
|
| As an alternative view though, one of the nice things about Go,
| or specifically the http part of the stdlib, is that it composes
| well with libraries and middleware like Chi or Negroni. So rather
| than having to conform to an all-encompassing web framework, you
| can assemble just the tools you need for the problem at hand.
| cactusplant7374 wrote:
| Someone once said, "It's good for simple projects but projects
| rarely stay simple." That's why I like frameworks and the
| batteries that they include.
| sethammons wrote:
| What is an example of something simple vs complex?
|
| I believe my services' APIs count as simple. HTTP verbs, url
| and query parameters, some auth headers and jwts, json
| payloads, and http error codes usually with a json body. As
| such, all my problems are easily solved with the chi package.
| I don't do much form handling as our UI handles that and uses
| our APIs. FWIW, our APIs handle billions of requests per day.
|
| What is complex? I imagine things around templating, forms,
| and maybe (maybe!!) auth. Is that what drives framework
| advocates?
|
| My past experience with a few were that they made simple
| things simple and hard things harder or impossible. I
| abandoned them about a decade ago however, so could be out of
| touch.
| donio wrote:
| Simple composable components are especially important for
| complex projects. The larger the project the less likely that
| the assumptions made by the framework will be a good fit for
| it.
| l_theanine wrote:
| I'd love something like this just for python. Especially sans HN
| style moderation.
| denysvitali wrote:
| So meta:
| https://remoterenters.com/stories/57cf0737-f8ed-6cf3-542d-2c...
| TekMol wrote:
| If there was a Django based HN clone in Python, I would be
| tempted to run an instance for topics I am interested in.
| anaganisk wrote:
| But who is going to visit your site? I dont mean to make a
| snarky comment, but I am curious as to how data is generated?
| dzink wrote:
| Nice work. Here is some feedback:
|
| 1. Go has a major bottleneck and that's the growth of its memory
| size when it's under pressure. Templates bloat the memory quickly
| and make the site less performant at scale (aka if you put it on
| Heroku, you'd need more Dinos to support the traffic, which costs
| more.). Instead of GO templating, you can produce static pages
| and fill them up with JS Ajax or React, or whatever your front
| end flavor is and make that call a Go API you produce with the
| framework instead. This also helps you turn your site into an app
| if needed as well.
|
| 2. Saw somewhere you had database incremented user ids and other
| models? Not safe as it allows any bad actor to peruse your user
| base. Always do UUID as a scramble that can't be iterated on.
|
| Keep hammering. For everyone who says you don't need a framework
| in Go, there are at least a few newbies who learn how to set up
| and run their Go server and stack from your framework.
| sideproject wrote:
| Awesome! Last week, I released "Launch your own HN-Clone" tool
|
| https://www.hn.plus
|
| I've tried to maintain true to most of the HN features and also
| included other features so you can grow your HN-clone community!
| wffurr wrote:
| The real secret sauce to HN would be cloning dang.
| Jabrov wrote:
| LLM-based dang clone? Hmm...
| sshine wrote:
| This exists and was featured on HN.
|
| An LLM that generates text like a specific HN account, based
| on their prior comments.
| zxexz wrote:
| Commenting on HN is a very small part of what dang does!
| quickthrower2 wrote:
| And patio11 &tc
| papa-whisky wrote:
| Mega nitpick and completely off topic; it's just "&c". "Et"
| translates as "and" which can be replaced by the ampersand,
| "cetera" is "the rest".
| bqmjjx0kac wrote:
| My understanding is that "&" is actually a ligature of
| "Et". You can kind of see it if you squint your eyes!
| anaganisk wrote:
| Throw in some cloudflare, google, and AWS customer service
| responses while you are at it to make it realistic.
| chinaman425 wrote:
| [dead]
| bqmjjx0kac wrote:
| Is there an advantage to limiting the route to three components?
| It feels limiting, and I'm not really sure what it buys you.
| krapp wrote:
| I mean, HN only has one and everything else is query params.
___________________________________________________________________
(page generated 2023-03-05 23:00 UTC)