[ANN] webbrowser: open webpages on your default browser.

1,241 views
Skip to first unread message

Carlos Cobo

unread,
Dec 15, 2012, 9:38:46 PM12/15/12
to golan...@googlegroups.com
Hi there gophers,

I made this a couple of weeks ago because I need something like Python's webbrowser and I forgot to publish it here.

It's very simple and but my tests were successful on two Win7 machines and an Ubuntu box. I haven't tested it on Darwin, but it should work out of the box.

Any suggestions/issues are welcome.


Have a nice day,
Carlos

minux

unread,
Dec 15, 2012, 9:43:38 PM12/15/12
to Carlos Cobo, golan...@googlegroups.com
On Sun, Dec 16, 2012 at 10:38 AM, Carlos Cobo <toqu...@gmail.com> wrote:
I made this a couple of weeks ago because I need something like Python's webbrowser and I forgot to publish it here.

It's very simple and but my tests were successful on two Win7 machines and an Ubuntu box. I haven't tested it on Darwin, but it should work out of the box.
i just checked the code, it should work on Darwin. 

Any suggestions/issues are welcome.

Thank you. This is really useful.
And I think we should add this functionality to go-tour project too so that when the user
starts gotour, it will automatically open the browser window.

minux

unread,
Dec 15, 2012, 9:45:52 PM12/15/12
to Carlos Cobo, golan...@googlegroups.com
On Sun, Dec 16, 2012 at 10:38 AM, Carlos Cobo <toqu...@gmail.com> wrote:
what are the licensing terms?
i can't find out anything about license.

Carlos Cobo

unread,
Dec 15, 2012, 9:50:47 PM12/15/12
to golan...@googlegroups.com
I'm sorry minux I forgot to add the License its too late here.

There's nothing super awesome there so I'll use MIT or public domain. I'm not a licensing guy :/ Any suggestions?

minux

unread,
Dec 15, 2012, 9:56:45 PM12/15/12
to Carlos Cobo, golan...@googlegroups.com
On Sun, Dec 16, 2012 at 10:50 AM, Carlos Cobo <php...@gmail.com> wrote:
There's nothing super awesome there so I'll use MIT or public domain. I'm not a licensing guy :/ Any suggestions?
I think both are OK. In fact, as long as the license is compatible with Go's, I'm happy. :-)

Carlos Cobo

unread,
Dec 15, 2012, 10:00:58 PM12/15/12
to golan...@googlegroups.com
Ok then use it as you wish.

It's 4 AM here so dont expect it to have a proper LICENSE file until.. at least 10 hours or so I'm tired as hell.

I'll update on morning.

Goodnight list.

Dan Kortschak

unread,
Dec 15, 2012, 10:09:39 PM12/15/12
to Carlos Cobo, golan...@googlegroups.com
Since Candidates is public and not protected by any locking, is there a reason for providing Register and RegisterPrep? Alternatively, would it be sensible for Candidates to be made unexported and protected by a RWMutex? (this seems like overkill, but you never know).

Nice simple package.

Dan
--
 
 

Mike Rosset

unread,
Dec 15, 2012, 10:42:37 PM12/15/12
to Dan Kortschak, Carlos Cobo, golan...@googlegroups.com
couple of things. do you really need to call cmd and sh? can you not
just call open, xdg-open, start ?

also would it not be easier just to switch runtime.GOOS, would make
the OS abstraction run time not compile time, and avoid code
separation.

other then that cool stuff.
> --
>
>

Carlos Cobo

unread,
Dec 16, 2012, 7:40:20 AM12/16/12
to golan...@googlegroups.com
Hi there again,

As I promised I've updated the package repo with a MIT license.

Carlos Cobo

unread,
Dec 16, 2012, 8:01:04 AM12/16/12
to golan...@googlegroups.com, Dan Kortschak, Carlos Cobo
Thanks for your feedback.

I tried calling those but failed, it seems I need to do some syscall magic there. I tried to keep the package as simple as possible.
Also I never tinkered around with syscall package so, right now, I don''t know how to do that. Pull requests are welcome.

About the runtime / compile time issue:
Better to do something once than on every Open call isn't it?
Once you go get the package your OS doesn't change.

Carlos Cobo

unread,
Dec 16, 2012, 8:05:14 AM12/16/12
to golan...@googlegroups.com, Carlos Cobo
Thanks for your feedback.

I didn't know how people would use `Candidates` so I went all in and provided a couple of methods for the most common operations but also made it Public so any fancy slice operations can still be used.

Using a RWMutex is a nice addtion (thanks!) and shouldn't be such an overkill because I'm using os/exec here but those fancy slice operations wouldn't be permitted. I don't know what to do. I more people to use and test the package.

Miki Tebeka

unread,
Dec 17, 2012, 12:46:53 PM12/17/12
to golan...@googlegroups.com
Nice. I wrote something similar but it uses the OS provided program to open URI's (like open in OSX)

Carlos Cobo

unread,
Dec 17, 2012, 8:01:33 PM12/17/12
to golan...@googlegroups.com
What a beautiful piece of code.

That's what my package uses but I use cmd or bash to call those. That's probably what Mike Rosset was trying to tell me but I didn't get it.

I didn't found your package on godoc.org so I created this, you should submit it there.

I've updated the webbrowser package to use your approach, I linked to your project on the README.

---

I also googled a bit and it seems {free,open,net}bsd also support xdg-open so I added them too!

Miki Tebeka

unread,
Dec 18, 2012, 12:38:22 AM12/18/12
to golan...@googlegroups.com
Thanks for the link

minux

unread,
Dec 18, 2012, 9:39:24 AM12/18/12
to Miki Tebeka, golan...@googlegroups.com
On Tue, Dec 18, 2012 at 1:46 AM, Miki Tebeka <miki....@gmail.com> wrote:
Nice. I wrote something similar but it uses the OS provided program to open URI's (like open in OSX)
just a note, you can't use start directly on windows.
you have to use "cmd /c start URL".

Carlos Cobo

unread,
Dec 18, 2012, 11:15:31 AM12/18/12
to golan...@googlegroups.com, Miki Tebeka
Fixed! Thanks for the notice. I changed that for BSD too fast without checking.

Miki Tebeka

unread,
Dec 18, 2012, 11:35:04 AM12/18/12
to golan...@googlegroups.com
Thanks! fixed as well.

Carlos Cobo

unread,
Jan 14, 2013, 8:10:26 PM1/14/13
to golan...@googlegroups.com
Today a fellow gopher notified me that the webbrowser package didn't support URLs with ampersands.

I've updated the code to support URL's with ampersands on both Windows and Unices.

If you encounter any URLs with characters to escape please fill an issue on Github or just reply here.

Best regards,
Carlos

Dobrosław Żybort

unread,
Jan 15, 2013, 3:26:11 AM1/15/13
to golan...@googlegroups.com
Thank you for fast fix.
Reply all
Reply to author
Forward
0 new messages