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 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.
Click to show internal directories.
Click to hide internal directories.