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

科技回声

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

GitHubTwitter

首页

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

资源链接

HackerNews API原版 HackerNewsNext.js

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

On Go’s Web Application Ecosystem

52 点作者 sant0sk1超过 11 年前

13 条评论

pearkes超过 11 年前
What I find interesting about Go[1] and the web application community is that people constantly point to speed as a huge selling point. Speed in the sense of latency and request volume per server.<p>I still feel like for the majority of cases, this type of speed difference is <i>not</i> going to matter. The difference between the Go built in web framework at 190,687[2] (1.3 ms) json responses per second and Flask, a popular Python framework at 18,945[2] (3.1 ms) is trivial when you look at the bigger picture.<p>If you are receiving enough traffic for that to make a fundamental difference, you&#x27;ll likely have enough potential or realized revenue to pay for a few more [Flask, Rails, &quot;slow&quot; framework] servers, or have enough developer time to warrant building it in Go.<p>The upside to using a &quot;slow&quot; framework is massive. Try writing an app like Ticketee[3] in Go, even with Gorilla et al and you&#x27;ll realize the productivity gains you&#x27;re missing out on.<p>For a small API, backend services, command line apps Go makes sense. But the big selling point there isn&#x27;t speed, it&#x27;s likely deployability.<p>I love Go. It&#x27;s good for teams, deploys well, is enjoyable to program in, does things quickly. But if a client comes to me wanting a web application with forms, view logic, payments, 3rd party integrations – I&#x27;ll take my Rails, thanks.<p>&gt; Given all this, frameworks (and ecosystems) like Flask, Sinatra, Django and Rails still have an advantage for when you want to get something done today: they’re very useful toolboxes, handle a lot of the boilerplate and have a lot of examples and packages to leverage.<p>The author clearly recognizes this opinion – but there seems to be an idea that you can just &quot;use Go&quot; in place of existing web frameworks. That&#x27;s not the case (yet!). I think this is largely driven by the myth of performance requirement.<p>[1]: Things like Node.js probably fit into this argument too<p>[2]: <a href="http://www.techempower.com/benchmarks/" rel="nofollow">http:&#x2F;&#x2F;www.techempower.com&#x2F;benchmarks&#x2F;</a><p>[3]: <a href="https://github.com/steveklabnik/ticketee" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;steveklabnik&#x2F;ticketee</a>
评论 #6768919 未加载
评论 #6771628 未加载
评论 #6769921 未加载
taude超过 11 年前
I&#x27;m curious as to why everyone wants a web-framework in Go. Wasn&#x27;t it primarily designed for back end service-type-of-stuff? Seems like there&#x27;s plenty of full-stack and micro-web frameworks out there in what ever language you desire, that are in a more web-dev friendly syntax.<p>I guess I don&#x27;t picture a company saying, we&#x27;re going to use GO through-and-through for our dev platform. I picture it more as a &quot;well, we now have a custom messaging service that needs to scale better&quot; or something, much like when people choose to drop into C or C++. It also seems that there&#x27;s more dev-friendly languages to build the web layer in.... I also don&#x27;t see many web-dev types thinking in GO very well.<p>So, why GO at the web-layer?
评论 #6768647 未加载
评论 #6768721 未加载
评论 #6768657 未加载
评论 #6768704 未加载
评论 #6768593 未加载
buro9超过 11 年前
One thing I&#x27;d like to see in Go is a way to sanitise HTML based on a whitelist.<p>This is to accompany blackfriday (Markdown) and text&#x2F;template (templating).<p>Markdown permits HTML, and this allows some scope for nasty stuff to get in, or for bugs that may exist in blackfriday to be exploited leading to HTML that could be the source of a XSS attack.<p>We&#x27;re currently running our user generated content through this: <a href="https://github.com/microcosm-cc/cleanse" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;microcosm-cc&#x2F;cleanse</a> and more specifically this: <a href="https://github.com/microcosm-cc/cleanse/blob/master/src/main/java/Cleanse.java" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;microcosm-cc&#x2F;cleanse&#x2F;blob&#x2F;master&#x2F;src&#x2F;main...</a><p>Which is a set of rules for OWASPs HTML sanitizer: <a href="https://code.google.com/p/owasp-java-html-sanitizer/" rel="nofollow">https:&#x2F;&#x2F;code.google.com&#x2F;p&#x2F;owasp-java-html-sanitizer&#x2F;</a><p>This works extremely well, except for the fact that it means in our Go code we&#x27;re calling out to a process and asking for a Java process to be kicked up for each request.<p>If no-one beats us to it we&#x27;ll be porting that to Go... but for us it remains a &quot;When we need to&quot; from a scaling or performance perspective.<p>Still... we&#x27;d love to see group work on a whitelist based sanitiser that we can contribute to rather than us go and write our own at some indeterminate point in the future.
评论 #6768501 未加载
codebeaker超过 11 年前
From someone who&#x27;s betting the farm on writing a web application in Go (<a href="https://www.harrow.io/" rel="nofollow">https:&#x2F;&#x2F;www.harrow.io&#x2F;</a>).<p>We&#x27;ve chosen Go for two really significant reasons: a) to reduce attack surface area and b) to enable us to distribute binaries to customers who want an enterprise&#x2F;firewall install inside their own network.<p>Speaking about surface area, we&#x27;ve reduced the amount of framework code in stack (rails, gems, etc are all off the table) to zero, and we&#x27;ve reduced the app paths to a few tens of lines of code, in most cases.<p>Whenever one trades off a framework &quot;to make things more secure&quot; one has to be sceptical, there&#x27;s a massive scope to introduce SQL injection, XSS and other nasties. In Go, in our case this is fairly limited. So take that reason with a pinch of salt if you aren&#x27;t building a VERY well defined app with VERY small and skilled team. I don&#x27;t expect this to scale well.<p>The second part is also a niche value, whilst it will have some benefits for us running our hosted version of Harrow, it&#x27;ll have more profound benefits when we can sell binary installations to customers.<p>Finally, learning how to build applications in an API centric manner, without the crutch that is Rails has been interesting, and has made us all better programmers, we have a more interesting architecture now, and are making better use of our tools (we&#x27;re leaning heavily on PostgreSQL, triggers, stored procs, LISTEN&#x2F;NOTIFY etc) and we have a faster system.<p>On the flip side of things, timing attacks are now really something we have to be mindful of. For instance the login endpoint returns &quot;404 Not Found&quot; regardless of whether it&#x27;s an incorrect password, or the account doesn&#x27;t exist. Except, interestingly we&#x27;re using bcrypt (we&#x27;re switching to pdbfk2 before the public launch) we need to look up the user <i>before</i> we can hash and verify the password. Meaning we respond in &lt; 1ms when the user is not found and 4ms when the user is found, but the password is incorrect. (and 4ms when the password is valid). This also applies to a lesser extent in responding with &quot;404 Not Found&quot; when trying to snoop on someone else&#x27;s project&#x2F;logs&#x2F;build&#x2F;etc. The same way they Github does. But it&#x27;s less critical there as there isn&#x27;t the artificially long password hash comparison step.<p>All told the decision to build in Go has made the <i>development</i> of the project slower, but has in my mind at least lead to a better quality of software, with things that don&#x27;t <i>typically</i> show up in Rails&#x2F;et al projects (foreign key constraints, triggers in the DB).<p>Of course all these tools are sharp weapons if handled incorrectly, and testing triggers&#x2F;functions in the database can be a nightmare from a unit&#x2F;functional testing point of view.<p>We&#x27;ve avoided technology proliferation (the <i>entire stack</i> is Go, and PostgreSQL, with worker nodes which rely on LXC). The entire application uses three packages not taken from the Go standard library. (db driver and bcrypt library)<p>Ohh, and our test suite compiles, and runs (all of it.) in less than three seconds. That hasn&#x27;t hurt much, either.
评论 #6769291 未加载
shadowmint超过 11 年前
Anyone have a link to an open source web app of a non-trivial nature built in go?<p>I&#x27;ve seen lots of system utility stuff, but I don&#x27;t think I&#x27;ve ever actually seen anything other than how-to-use-this-framework web apps?
评论 #6769832 未加载
valevk超过 11 年前
I think Go is still missing its killer-web-app-framework. But maybe it&#x27;s better that way. Keeps out the people who don&#x27;t like think before they code.
评论 #6768284 未加载
评论 #6768413 未加载
playing_colours超过 11 年前
When I read all these posts praising Go, I feel like a stranger accidently appeared at someone&#x27;s birthday party. I really want to start loving Go, it looks perspective and people already benefit from using it, but I just cannot make me enjoy the language.<p>Having Java&#x2F;Scala background I used to have static checking and performance for free and I cannot feel about Go the same as someone who switched from Python, PHP, Ruby stacks. I code mainly in Scala, and even if I like Go&#x27;s simplicity, compilation speed and the absense of Java burden, I really miss features like default immutability, pattern matching, generics, reach collection toolset, powerful typesystem. The language looks just not expressive for me to really enjoy.<p>Maybe I am corrupted with FP, cannot value simplicity or I should focus more on getting things done not on the process of writing code. Just wonder, if anyone else have similar impressions &#x2F; feelings?
voidlogic超过 11 年前
All this talk about HTML templating (html&#x2F;template, etc) &amp; Go web applications, is missing any discussion of what IMHO is a better way to write Go web apps:<p>1. Write a backend webservice in Go&#x27;s net&#x2F;http + Gorilla<p>2. Use something like angular JS to interact with those webservices. (From the server&#x27;s perspective this means static HTML&#x2F;CSS&#x2F;JS assets that can again be served by Go, from memory if desired).<p>My first couple Go web applications did things the html&#x2F;template way and were structured on the way I used to go JSF applications- but since I switched to the above approach my projects have been better performing, faster to develop , better scaling and easier to maintain. As we all know, we seldom get all those things in one technology choice without trade-offs.
评论 #6769360 未加载
codegangsta超过 11 年前
Author of Martini here. I think right now is a very exciting time for web development in Go.<p>One of the goals of Martini is to rally developers to create some more reusable web modules in the form of handlers and middleware. Martini has gotten a great response because it doesn&#x27;t infringe it&#x27;s api on your modules&#x2F;middlewares.<p>I personally think that this is the way to move forward with web development in Go. Less coupling, pull in the dependencies you need, get stuff done.
Aissen超过 11 年前
I&#x27;ve came to like some of the components of ghost: <a href="https://github.com/PuerkitoBio/ghost" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;PuerkitoBio&#x2F;ghost</a>
retzkek超过 11 年前
Also worth mentioning is Hugo, a static site generator: <a href="http://spf13.com/project/hugo" rel="nofollow">http:&#x2F;&#x2F;spf13.com&#x2F;project&#x2F;hugo</a>
ungerik超过 11 年前
Not in the post: the go-start framework <a href="https://github.com/ungerik/go-start" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;ungerik&#x2F;go-start</a>
评论 #6768683 未加载
评论 #6768722 未加载
INTPenis超过 11 年前
What about web.go? I never tried it but it seemed promising.
评论 #6768481 未加载