package browser
import "github.com/pkg/browser"
Package browser provides helpers to open files, readers, and urls in a browser window.
The choice of which browser is started is entirely client dependant.
Index ¶
- Variables
- func OpenFile(path string) error
- func OpenReader(r io.Reader) error
- func OpenURL(url string) error
Examples ¶
Variables ¶
Stderr is the io.Writer to which executed commands write standard error.
Stdout is the io.Writer to which executed commands write standard output.
Functions ¶
func OpenFile ¶
OpenFile opens new browser window for the file path.
Code:
Example¶
{
OpenFile("index.html")
}
func OpenReader ¶
OpenReader consumes the contents of r and presents the
results in a new browser window.
Code:
Example¶
{
// https://github.com/rust-lang/rust/issues/13871
const quote = `There was a night when winds from unknown spaces
whirled us irresistibly into limitless vacum beyond all thought and entity.
Perceptions of the most maddeningly untransmissible sort thronged upon us;
perceptions of infinity which at the time convulsed us with joy, yet which
are now partly lost to my memory and partly incapable of presentation to others.`
r := strings.NewReader(quote)
OpenReader(r)
}
func OpenURL ¶
OpenURL opens a new browser window pointing to url.
Code:
Example¶
{
const url = "http://golang.org/"
OpenURL(url)
}
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
examples | |
examples/Open | Open is a simple example of the github.com/pkg/browser package. |
- Version
- v0.0.0-20240102092130-5ac0b6a4141c (latest)
- Published
- Jan 2, 2024
- Platform
- windows/amd64
- Imports
- 7 packages
- Last checked
- now –
Tools for package owners.