embedbin

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2024 License: AGPL-3.0 Imports: 4 Imported by: 0

Documentation

Overview

Package embedbin provides a portable way to install embedded binaries.

The Install function creates a temporary file and writes the contents to it.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Installed

type Installed interface {
	Path() string
	IsRegular() bool
	Uninstall() error
}

Installed is a handle to an installed binary. Users must call Uninstall to clean it up.

type MemfdInstall

type MemfdInstall struct {
	// contains filtered or unexported fields
}

MemfdInstall uses memfd to temporarily get and fd / path for the embedded binary.

func (*MemfdInstall) IsRegular

func (m *MemfdInstall) IsRegular() bool

IsRegular returns false for memfdInstall. The file is a memfd, not a regular file.

func (*MemfdInstall) Path

func (m *MemfdInstall) Path() string

Path returns the path to the memfd.

func (*MemfdInstall) Uninstall

func (m *MemfdInstall) Uninstall() error

Uninstall closes the memfd. The file is automatically removed when the last process closes it.

type MemfdInstaller

type MemfdInstaller struct {
	// contains filtered or unexported fields
}

MemfdInstaller installs embedded binaries.

func New

func New() *MemfdInstaller

New returns a new installer.

func (*MemfdInstaller) Install

func (i *MemfdInstaller) Install(_ string, contents []byte) (Installed, error)

Install creates a memfd and writes the contents to it. the first argument is ignored on Linux (would be the prefix on other implementations).

type RegularInstall

type RegularInstall struct {
	// contains filtered or unexported fields
}

RegularInstall uses a regular file to install an embedded binary.

func (*RegularInstall) IsRegular

func (r *RegularInstall) IsRegular() bool

IsRegular returns true for regularInstall. It is always backed by a regular file.

func (*RegularInstall) Path

func (r *RegularInstall) Path() string

Path returns the path to the regular file.

func (*RegularInstall) Uninstall

func (r *RegularInstall) Uninstall() error

Uninstall removes the regular file.

type RegularInstaller

type RegularInstaller struct {
	// contains filtered or unexported fields
}

RegularInstaller uses a regular file to install an embedded binary.

func (*RegularInstaller) Install

func (r *RegularInstaller) Install(prefix string, contents []byte) (Installed, error)

Install creates a regular file and writes the contents to it. prefix is an optional prefix for the temporary file. If prefix is empty, a temporary directory will be used.

Jump to

Keyboard shortcuts

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