Re:Mux – A lightweight, fast HTTP request router for Go
by bradleyankrom on Monday December 05, 2016 @11:30AM
(#13106556)
I typically read the HN comments before clicking on a link, and I actually thought this _was_ a post about gorilla/mux until I got to your comment.
Re:Mux – A lightweight, fast HTTP request router for Go
by vegancap on Monday December 05, 2016 @11:36AM
(#13106621)
Same here!
Re:Mux – A lightweight, fast HTTP request router for Go
by hqian on Monday December 05, 2016 @02:43PM
(#13108630)
Same here. I was working with gorilla/mux 2 min ago with some "legacy" code and saw this. Thought to myself "huh it might be some good new changes with gorilla/mux"
Re:Mux – A lightweight, fast HTTP request router for Go
by shanemhansen on Monday December 05, 2016 @11:35AM
(#13106605)
I think they are both copying the stdlib terminology https://golang.org/pkg/net/http/#ServeMux
Historically gophers haven't minded the occasional namespace collision: https://github.com/golang/go/issues/9
Re:Mux – A lightweight, fast HTTP request router for Go
by insertnickname on Monday December 05, 2016 @11:25AM
(#13106511)
That's why we have namespaces. There's gorilla/mux and now there's donutloop/mux.
Re:Mux – A lightweight, fast HTTP request router for Go
by oelmekki on Monday December 05, 2016 @02:23PM
(#13108403)
Fair point, but this post title should read "donutloop/mux – A lightweight, fast HTTP request router for Go", then :)
Re:Mux – A lightweight, fast HTTP request router for Go
by Lewisham on Monday December 05, 2016 @11:32AM
(#13106574)
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.
Re:Mux – A lightweight, fast HTTP request router for Go
by nkozyra on Monday December 05, 2016 @12:29PM
(#13107188)
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
by 1_2__3 on Monday December 05, 2016 @12:15PM
(#13107018)
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
by Lewisham on Monday December 05, 2016 @12:32PM
(#13107236)
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
by TheDong on Monday December 05, 2016 @11:53PM
(#13112349)
It doesn't matter what it's named though, you can always alias the import.
If it was "github.com/foo/poppycock" I could just write import mux "github.com/foo/poppycock" and use it as mux.
Import name similarity is a terrible argument for picking a name.
Re:Mux – A lightweight, fast HTTP request router for Go
by insertnickname on Tuesday December 06, 2016 @01:04AM
(#13112583)
There are cases where it makes sense, like https://github.com/pkg/errors which is meant to be a drop-in replacement for the stdlib `errors` package containing a superset of its functionality.
Re:Mux – A lightweight, fast HTTP request router for Go
by jerf on Monday December 05, 2016 @12:17PM
(#13107052)
Then refer to the library by a name, and tell people to import $NAME/mux. You can also name the imports if people want.
[0] https://github.com/gorilla/mux