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: Go-promise – Golang's style to handle promises/error in JavaScript

4 pointsby docuruover 3 years ago

1 comment

docuruover 3 years ago
I feel handling Promises in JavaScript is not nice with `then&#x2F;catch`. It gets messy when there are multiple promises (I often use `async&#x2F;await` and wrap in a huge `try&#x2F;catch` block in this case), or there is a huge chunk of code in the resolve function<p>I notice how Golang handle errors. The error is returned in the same line of code. We handle it, then move on to the next problem. That makes the code easier to read and is more convenient to handle error.<p>So I make this tiny `go-promise` util library to handle promise better in JavaScript. Feedback are welcome!