Help us shape the future of Go! Take the 2026 Go Developer Survey

ln

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package ln implements the engine behind lnx, a GNU-compatible implementation of the GNU/UNIX ln command: make hard or symbolic links between files.

Index

Constants

View Source
const Name = "lnx"

Name is the command name, used as the prefix of every diagnostic and prompt.

Variables

This section is empty.

Functions

This section is empty.

Types

type Ln

type Ln struct {
	Options

	// PromptFn, when non-nil, is consulted instead of reading from standard
	// input. It is the injection point tests use to answer replace prompts.
	PromptFn func(question string) bool
	// contains filtered or unexported fields
}

Ln is the link engine. Construct it with New.

func New

func New(opts Options, s core.Streams) *Ln

New builds a link engine writing to s.

func (*Ln) Run

func (l *Ln) Run(args []string) error

Run creates links according to args, which take one of ln's four forms: TARGET LINK_NAME, TARGET (link in the current directory), TARGET... DIRECTORY, or (with -t) TARGET.... Diagnostics are written as they occur; the returned error is core.ErrFailed if any link failed, a *core.UsageError for a malformed command line, otherwise nil.

type Options

type Options struct {
	Symbolic          bool   // -s: make symbolic links instead of hard links
	Force             bool   // -f: remove existing destination files
	Interactive       bool   // -i: prompt before removing a destination
	NoDereference     bool   // -n: treat a LINK_NAME that is a symlink to a directory as a file
	Verbose           bool   // -v: print the name of each linked file
	Relative          bool   // -r: with -s, make the link relative to its own location
	TargetDirectory   string // -t: create the links in this directory
	NoTargetDirectory bool   // -T: always treat LINK_NAME as a normal file
	Logical           bool   // -L: hard link to the referent of a symlink TARGET
	Physical          bool   // -P: hard link to a symlink TARGET itself (the default)
}

Options mirrors the GNU ln flag surface.

Jump to

Keyboard shortcuts

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