package module
v0.0.0-...-7320435 Latest Latest

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

Go to latest
Published: Nov 20, 2022 License: MIT Imports: 19 Imported by: 20



build status codecov Go Report Card GoDoc MIT licensed

dash "configures" a folder, which means it looks at its contents and determines interesting launch targets such as:

  • Native Windows, Linux & macOS executables
  • HTML index files
  • .jar files, .love files, etc.


Licensed under MIT License, see LICENSE for details.




View Source
const (
	PenaltyExclude = iota


This section is empty.


func FixPermissions

func FixPermissions(v *Verdict, params FixPermissionsParams) ([]string, error)

FixPermissions makes sure all ELF executables, COFF executables, and scripts have the executable bit set


type Arch

type Arch string

The architecture of an executable

const (
	// 32-bit
	Arch386 Arch = "386"
	// 64-bit
	ArchAmd64 Arch = "amd64"

type BlacklistEntry

type BlacklistEntry struct {
	// contains filtered or unexported fields

type Candidate

type Candidate struct {
	// Path is relative to the configured folder
	Path string `json:"path"`
	// Mode describes file permissions
	Mode uint32 `json:"mode,omitempty"`
	// Depth is the number of path elements leading up to this candidate
	Depth int `json:"depth"`
	// Flavor is the type of a candidate - native, html, jar etc.
	Flavor Flavor `json:"flavor"`
	// Arch describes the architecture of a candidate (where relevant)
	Arch Arch `json:"arch,omitempty"`
	// Size is the size of the candidate's file, in bytes
	Size int64 `json:"size"`
	// Spell contains raw output from <https://github.com/itchio/wizardry>
	// @optional
	Spell []string `json:"spell,omitempty"`
	// WindowsInfo contains information specific to native Windows candidates
	// @optional
	WindowsInfo *WindowsInfo `json:"windowsInfo,omitempty"`
	// LinuxInfo contains information specific to native Linux candidates
	// @optional
	LinuxInfo *LinuxInfo `json:"linuxInfo,omitempty"`
	// MacosInfo contains information specific to native macOS candidates
	// @optional
	MacosInfo *MacosInfo `json:"macosInfo,omitempty"`
	// LoveInfo contains information specific to Love2D bundles (`.love` files)
	// @optional
	LoveInfo *LoveInfo `json:"loveInfo,omitempty"`
	// ScriptInfo contains information specific to shell scripts (`.sh`, `.bat` etc.)
	// @optional
	ScriptInfo *ScriptInfo `json:"scriptInfo,omitempty"`
	// JarInfo contains information specific to Java archives (`.jar` files)
	// @optional
	JarInfo *JarInfo `json:"jarInfo,omitempty"`
	// Any other info.
	Metadata interface{}

A Candidate is a potentially interesting launch target, be it a native executable, a Java or Love2D bundle, an HTML index, etc.

func Sniff

func Sniff(r io.ReadSeeker, name string, size int64) (*Candidate, error)

func (*Candidate) String

func (c *Candidate) String() string

type CandidateDetector

type CandidateDetector interface {
	// Error returned here is treated as critical and will
	// cancel Configuration.
	DetectCandidate(pool lake.Pool, fileIndex int64, f *tlc.File) (DetectResult, error)

type ConfigureParams

type ConfigureParams struct {
	Consumer *state.Consumer
	// filter to use when walking the install folder a nil value will fallback
	// on lake's presets (not git/hg/svn metadata, no windows/mac metadata, no
	// .itch folder)
	Filter tlc.FilterFunc
	Stats  *VerdictStats


ConfigureParams controls the behavior of Configure

type DetectResult

type DetectResult struct {
	// Allowed to be nil.
	Candidate           *Candidate
	SkipDefaultAnalysis bool

type FilterParams

type FilterParams struct {
	OS   string
	Arch string

type FixPermissionsParams

type FixPermissionsParams struct {
	DryRun   bool
	Consumer *state.Consumer

type Flavor

type Flavor string

Flavor describes whether we're dealing with a native executables, a Java archive, a love2d bundle, etc.

const (
	// FlavorNativeLinux denotes native linux executables
	FlavorNativeLinux Flavor = "linux"
	// ExecNativeMacos denotes native macOS executables
	FlavorNativeMacos Flavor = "macos"
	// FlavorPe denotes native windows executables
	FlavorNativeWindows Flavor = "windows"
	// FlavorAppMacos denotes a macOS app bundle
	FlavorAppMacos Flavor = "app-macos"
	// FlavorScript denotes scripts starting with a shebang (#!)
	FlavorScript Flavor = "script"
	// FlavorScriptWindows denotes windows scripts (.bat or .cmd)
	FlavorScriptWindows Flavor = "windows-script"
	// FlavorJar denotes a .jar archive with a Main-Class
	FlavorJar Flavor = "jar"
	// FlavorHTML denotes an index html file
	FlavorHTML Flavor = "html"
	// FlavorLove denotes a love package
	FlavorLove Flavor = "love"
	// Microsoft installer packages
	FlavorMSI Flavor = "msi"

type HighestScoreFirst

type HighestScoreFirst struct {
	// contains filtered or unexported fields

func (*HighestScoreFirst) Len

func (hsf *HighestScoreFirst) Len() int

func (*HighestScoreFirst) Less

func (hsf *HighestScoreFirst) Less(i, j int) bool

func (*HighestScoreFirst) Swap

func (hsf *HighestScoreFirst) Swap(i, j int)

type JarInfo

type JarInfo struct {
	// The main Java class as specified by the manifest included in the .jar (if any)
	// @optional
	MainClass string `json:"mainClass,omitempty"`

Contains information specific to Java archives

type LinuxInfo

type LinuxInfo struct {

Contains information specific to native Linux executables

type LoveInfo

type LoveInfo struct {
	// The version of love2D required to open this bundle. May be empty
	// @optional
	Version string `json:"version,omitempty"`

Contains information specific to Love2D bundles

type MacosInfo

type MacosInfo struct {

Contains information specific to native macOS executables or app bundles.

type Penalty

type Penalty struct {
	// contains filtered or unexported fields

type PenaltyKind

type PenaltyKind int

type ScoredCandidate

type ScoredCandidate struct {
	// contains filtered or unexported fields

type ScriptInfo

type ScriptInfo struct {
	// Something like `/bin/bash`
	// @optional
	Interpreter string `json:"interpreter,omitempty"`

Contains information specific to shell scripts

type Verdict

type Verdict struct {
	// BasePath is the absolute path of the folder that was configured
	BasePath string `json:"basePath"`
	// TotalSize is the size in bytes of the folder and all its children, recursively
	TotalSize int64 `json:"totalSize"`
	// Candidates is a list of potentially interesting files, with a lot of additional info
	Candidates []*Candidate `json:"candidates"`

A Verdict contains a wealth of information on how to "launch" or "open" a specific folder.

func Configure

func Configure(root string, params ConfigureParams) (*Verdict, error)

Configure walks a directory and finds potential launch candidates, grouped together into a verdict.

func (Verdict) Filter

func (v Verdict) Filter(consumer *state.Consumer, params FilterParams) Verdict

Filter candidates by OS and/or Arch OS and Arch may be empty strings.

Returns a copy of this Verdict.

func (*Verdict) String

func (v *Verdict) String() string

type VerdictStats

type VerdictStats struct {
	NumSniffs   int
	SniffsByExt map[string]int

type WindowsInfo

type WindowsInfo struct {
	// Particular type of installer (msi, inno, etc.)
	// @optional
	InstallerType WindowsInstallerType `json:"installerType,omitempty"`
	// True if we suspect this might be an uninstaller rather than an installer
	// @optional
	Uninstaller bool `json:"uninstaller,omitempty"`
	// Is this executable marked as GUI? This can be false and still pop a GUI, it's just a hint.
	// @optional
	Gui bool `json:"gui,omitempty"`
	// Is this a .NET assembly?
	// @optional
	DotNet bool `json:"dotNet,omitempty"`

Contains information specific to native windows executables or installer packages.

type WindowsInstallerType

type WindowsInstallerType string

Which particular type of windows-specific installer

const (
	// Microsoft install packages (`.msi` files)
	WindowsInstallerTypeMsi WindowsInstallerType = "msi"
	// InnoSetup installers
	WindowsInstallerTypeInno WindowsInstallerType = "inno"
	// NSIS installers
	WindowsInstallerTypeNullsoft WindowsInstallerType = "nsis"
	// Self-extracting installers that 7-zip knows how to extract
	WindowsInstallerTypeArchive WindowsInstallerType = "archive"

Jump to

Keyboard shortcuts

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