| 1 | # webbrowser [](https://github.com/toqueteos/webbrowser/actions) [](https://pkg.go.dev/github.com/toqueteos/webbrowser) |
| 2 | |
| 3 | webbrowser provides a simple API for opening web pages on your default browser. |
| 4 | |
| 5 | It's inspired on [Python's webbrowser](http://docs.python.org/3/library/webbrowser.html) package but lacks some of its features (open new window). |
| 6 | |
| 7 | It just opens a webpage, most browsers will open it on a new tab. |
| 8 | |
| 9 | ## Installation |
| 10 | |
| 11 | As simple as: |
| 12 | |
| 13 | ```bash |
| 14 | go get -u github.com/toqueteos/webbrowser |
| 15 | ``` |
| 16 | |
| 17 | It is Go modules compatible! |
| 18 | |
| 19 | _(`go.mod` was explicitly added in version `v1.2.0`)_ |
| 20 | |
| 21 | ## Usage |
| 22 | |
| 23 | ```go |
| 24 | package main |
| 25 | |
| 26 | import "github.com/toqueteos/webbrowser" |
| 27 | |
| 28 | func main() { |
| 29 | webbrowser.Open("http://golang.org") |
| 30 | } |
| 31 | ``` |
| 32 | |
| 33 | That's it! |
| 34 | |
| 35 | ## Crossplatform support |
| 36 | |
| 37 | The package works on: |
| 38 | |
| 39 | - [x] `android` (verified by 3rd party) |
| 40 | - [x] `darwin` |
| 41 | - [x] `freebsd` (verified by 3rd party) |
| 42 | - [x] `linux` |
| 43 | - [x] `netbsd` (verified by 3rd party) |
| 44 | - [x] `openbsd` (verified by 3rd party) |
| 45 | - [x] `windows` |
| 46 | |
| 47 | ## License |
| 48 | |
| 49 | It is licensed under the MIT open source license, please see the [LICENSE.md](https://github.com/toqueteos/webbrowser/blob/master/LICENSE.md) file for more information. |
| 50 | |
| 51 | ## Thanks... |
| 52 | |
| 53 | Miki Tebeka wrote a nicer version that wasn't on godoc.org when I did this, [check it out!](https://bitbucket.org/tebeka/go-wise/src/d8db9bf5c4d1/desktop.go?at=default). |
| 54 | |
| 55 | ## Already disliking it? |
| 56 | |
| 57 | No problem! There's alternative libraries that may be better to your needs: |
| 58 | |
| 59 | - https://github.com/pkg/browser, it does what webbrowser does and more! |
| 60 | - https://github.com/skratchdot/open-golang, it even provides a `xdg-open` implementation in case you don't have it! |