webbrowser

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

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

Go to latest
Published: Nov 16, 2016 License: MIT Imports: 5 Imported by: 5

README

webbrowser

Go library for opening URLs using a web browser. Currently supports Linux, OSX, and Windows.

Documentation

The API documentation can be found at http://godoc.org/github.com/bryanl/webbrowser.

Example

package main

import (
    "log"

    "github.com/bryanl/webbrowser"
)

func main() {
    err := webbrowser.Open("http://blil.es", webbrowser.NewTab, true)
    if err != nil {
        log.Println("open failed:", err)
    }
}

~

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Open

func Open(u string, windowState WindowType, autoRaise bool) error

Open opens a URL in a web browser window.

Example
package main

import (
	"log"

	"github.com/bryanl/webbrowser"
)

func main() {
	err := webbrowser.Open("http://digitalocean.com", webbrowser.NewTab, true)
	if err != nil {
		log.Println("open failed:", err)
	}
}
Output:

Types

type LinuxOpener

type LinuxOpener struct {
	Env []string
}

LinuxOpener is an implementation of Opener for Linux.

func (*LinuxOpener) Open

func (o *LinuxOpener) Open(u string, windowType WindowType, autoRaise bool) error

Open opens a URL using xdg-open. Returns an error if X is not available.

type OSXOpener

type OSXOpener struct {
	Env []string
}

OSXOpener is an Opener for Mac OSX.

func (*OSXOpener) Open

func (o *OSXOpener) Open(u string, windowType WindowType, autoRaise bool) error

Open opens a URL using osascript..

type Opener

type Opener interface {
	Open(url string, windowState WindowType, autoRaise bool) error
}

Opener is the interface that wraps the Open method. It opens a URL with specifications for the type of window and if it should be autoraised or not.

type RequireXError

type RequireXError struct{}

RequireXError signifies X windows is running.

func (*RequireXError) Error

func (e *RequireXError) Error() string

type UnsupportedOSError

type UnsupportedOSError struct {
	OS string
}

UnsupportedOSError signifies an unsupported OS.

func (*UnsupportedOSError) Error

func (e *UnsupportedOSError) Error() string

type WindowType

type WindowType string

WindowType is a type of window to open. Currently this is not supported but exists to keep the API stable for a future change.

const (
	// SameWindow is for opening the URL in the same window.
	SameWindow WindowType = "same_window"
	// NewWindow is for opening the URL in a new window.
	NewWindow WindowType = "new_window"
	// NewTab is for opening the URL in a new tab.
	NewTab WindowType = "new_tab"
)

type WindowsOpener

type WindowsOpener struct {
	Env []string
}

WindowsOpener is an Opener for Windows.

func (*WindowsOpener) Open

func (o *WindowsOpener) Open(u string, windowType WindowType, autoRaise bool) error

Open opens a URL using cmd.exe.

Jump to

Keyboard shortcuts

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