webbrowser

package
v4.27.18+incompatible Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 4, 2016 License: MIT, MIT Imports: 7 Imported by: 0

README

webbrowser Build Status GoDoc GitHub release

webbrowser provides a simple API for opening web pages on your default browser. It's inspired on Python's webbrowser package but lacks some of its features (open new window).

It just opens a webpage, most browsers will open it on a new tab.

Installation

Copy & Paste fans: go get github.com/toqueteos/webbrowser

Usage

Import the package (once you have installed it):

import "github.com/toqueteos/webbrowser"

Then use the Open function.

webbrowser.Open("http://golang.org")

That's it!

Need a full blown example? Checkout [examples/simple.go].

Already disliking it?

No problem! There's alternative libraries that may be better to your needs:

Crossplatform support

The package is guaranteed to work on windows, linux and darwin. It also has default support for freebsd, openbsd and netbsd but these three have not been tested yet (that I'm aware of).

License

It is licensed under the MIT open source license, please see the [LICENSE.txt] file for more information.

Thanks...

Miki Tebeka wrote a nicer version that wasn't on godoc.org when I did this, check it out!.

Documentation

Overview

Package webbrowser provides a simple API for opening web pages on your default browser.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrCantOpen     = errors.New("webbrowser.Open: can't open webpage")
	ErrNoCandidates = errors.New("webbrowser.Open: no browser candidate found for your OS.")
)
View Source
var Candidates []Browser

List of registered `Browser`s that will be tried with Open.

Functions

func Open

func Open(s string) error

Open opens an URL on the first available candidate found.

Types

type Browser

type Browser interface {
	Open(string) error
}

type GenericBrowser

type GenericBrowser struct {
	Cmd  string
	Args []string
}

GenericBrowser just holds a command name and its arguments; the url will be appended as last arg. If you need to use string replacement for url define your own implementation.

func (GenericBrowser) Open

func (gb GenericBrowser) Open(s string) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL