webbrowser

package module
v0.0.0-...-e11139f Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2014 License: MIT Imports: 7 Imported by: 2

README

Webbrowser

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.

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

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 hasn't been tested yet.

Installation

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

Usage

Just import the package (after you got it):

import "github.com/toqueteos/webbrowser"

Then use the Open function.

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

Just in case, you have a very simple example on examples/simple.go.

Extras

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