opener

package module
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: May 4, 2026 License: BSD-3-Clause Imports: 7 Imported by: 0

README

Opener

A Golang library to open objects (URL, Directoris, Files, Images, Videos) using OS's pefered application for that object type.

Example

The below code opens the URL for the repostory of this library.

err := opener.Open("https://codeberg.org/udan-jayanith/Opener")
if err != nil {
	fmt.Println(err.Error())
} else {
	fmt.Println("URL opened")
}

More detailed example is available in the example directory.


https://pkg.go.dev/codeberg.org/udan-jayanith/Opener

Documentation

Overview

A Golang library to open objects (URL, Directoris, Files, Images, Videos) using OS's pefered application for that object type. The whole library is adapted from https://github.com/openfl/lime/blob/develop/src/lime/system/System.hx#L423

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Open

func Open(object Object) error

Open opens the object using OS's pefered application for that object type. If the object type is somthing other then a URL it should be absolute path to the object.

func OpenStream

func OpenStream(r io.Reader, extension string) (string, error)

OpenStream writes content of r into a file created in OS's tempory directory. If extension is not empty, extension is added to the end of the tempory file, file with no extension is up to OS to handle and file get opened by OS's pefered way. Then OpenStream returns the filepath of the tempory file created and an error. If there were any error returned filepath may be empty.

Types

type Object

type Object = string

Object only could be a URL, Filepath or a Directory

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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