symlink

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: May 24, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Relative

func Relative(oldname, newname string, opts *Options) error

Relative creates a relative symlink at newname to the location specified by oldname.

Types

type CreateOption

type CreateOption func(oldname, newname string) error

CreateOption represents an option.

var MkdirAll CreateOption = func(_, newname string) error {

	err := os.MkdirAll(filepath.Dir(newname), 0o775)
	if err != nil {
		return err
	}
	return nil
}

MkdirAll creates the parent directory.

var Overwrite CreateOption = func(_, newname string) error {

	err := os.Remove(newname)
	if err != nil && !errors.Is(err, os.ErrNotExist) {
		return fmt.Errorf("overwriting link: %w", err)
	}
	return nil
}

Overwrite overwrites existing files.

type Options

type Options struct {
	Name        string // Name to prefix dry-run messages with
	MkdirParent bool   // Create parent directory of symlink if it does not exist
	Overwrite   bool   // Delete files that already exist in the prefix while linking
	DryRun      bool   // List files which would be linked or overwritten without actually linking or deleting any files
}

Options contains options for creating symlinks.

Jump to

Keyboard shortcuts

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