Live data from Hacker News

Mux – A lightweight, fast HTTP request router for Go

github.com

21–30 of 80 posts

Re: Mux – A lightweight, fast HTTP request router for Go

#22
post #8

Earlier quoted context omitted.

That's why we have namespaces. There's gorilla/mux and now there's donutloop/mux.

This. It's actually more idiomatic to use the same name, then you can often just sub out one library for another without any hassle.

What? No! There's no indication at all these two libraries are compatible - why would you want two completely disparate projects to give some indication they support the same interface?

Re: Mux – A lightweight, fast HTTP request router for Go

#24
post #8

Earlier quoted context omitted.

That's why we have namespaces. There's gorilla/mux and now there's donutloop/mux.

This. It's actually more idiomatic to use the same name, then you can often just sub out one library for another without any hassle.

Then refer to the library by a name, and tell people to import $NAME/mux. You can also name the imports if people want.

Re: Mux – A lightweight, fast HTTP request router for Go

#26
post #8

Earlier quoted context omitted.

That's why we have namespaces. There's gorilla/mux and now there's donutloop/mux.

This. It's actually more idiomatic to use the same name, then you can often just sub out one library for another without any hassle.

Unless they have the same functions, variables, structs, etc., sharing the same name really doesn't provide much in terms of hassle-free substitution.

Re: Mux – A lightweight, fast HTTP request router for Go

#27
post #22
post #8

Earlier quoted context omitted.

This. It's actually more idiomatic to use the same name, then you can often just sub out one library for another without any hassle.

What? No! There's no indication at all these two libraries are compatible - why would you want two completely disparate projects to give some indication they support the same interface?

Because many of the base infrastructure libraries are compatible as long as they used interfaces (grumble grumble os.File). I would be very surprised if this doesn't implement net/http/ServeHTTP

Re: Mux – A lightweight, fast HTTP request router for Go

#28
post #2

Does it use a trie? If not, it probably should. Here's a wonderful talk on using that datastructure (with go) for the gov uk url router: https://gdstechnology.blog.gov.uk/2013/12/05/building-a-new-... The Vulcan proxy from Mailgun does the same thing: http://vulcand.github.io/proxy.html#route It looks like it doesn't, so existing open source golang url routers will perform much better, contrary to this post. The one…

Looks like it uses regexp... There isn't any benchmark code as one would expect when making a claim that it's "fast".

Regexp definitely isn't something you'd want to be using if you're primary goal is speed. When running tight loops in string parsing I've found using string splitting and then cycling through the range of indices in a slice was several times faster than Regexp matching. Obviously performance difference will vary depending on the expression and application but that was enough to convince me to think twice about future usage of Regex - as to whether the problem needed Regex or if I was just using them lazily. The latter being a practice I'd slipped into after years of Perl hacking.

Re: Mux – A lightweight, fast HTTP request router for Go

#29
post #2

Does it use a trie? If not, it probably should. Here's a wonderful talk on using that datastructure (with go) for the gov uk url router: https://gdstechnology.blog.gov.uk/2013/12/05/building-a-new-... The Vulcan proxy from Mailgun does the same thing: http://vulcand.github.io/proxy.html#route It looks like it doesn't, so existing open source golang url routers will perform much better, contrary to this post. The one…

Looks like it uses regexp... There isn't any benchmark code as one would expect when making a claim that it's "fast".

Go regexps are slow (https://goo.gl/r0K2xw ), the problem is not regexps but Go's implementation of regexps. So let's not blame regexps when regexps aren't the problem. Because by that logic, people shouldn't use the sort package as well ...

Re: Mux – A lightweight, fast HTTP request router for Go

#30
post #5

I don't usually say this but - isn't this a poor choice of name? Gorilla framework's Mux [0] has been around awhile and is quite popular for routing in Go. [0] https://github.com/gorilla/mux

mux comes from muxer which comes from multiplexer. Gorilla doesn't own that label, no matter how popular the package is.
Post reply on HN