Categorygithub.com/balanza/go-multitouch
modulepackage
0.0.0-20250220114350-94871d914043
Repository: https://github.com/balanza/go-multitouch.git
Documentation: pkg.go.dev

# README

go-multitouch

go-multitouch is a Go package that allows you to scaffold a file structure from a descriptor. It is similar to executing mkdir and touch commands recursively. This package is primarily designed for testing file access packages.

Installation

go get -u github.com/balanza/go-multitouch@latest

Usage

import (
    "github.com/balanza/go-multitouch"
)

func main() {
	tree := []FileTree{
		{
			Name: "file.txt",
			Content: "Lorem ipsum"
		},
		{
			Name: "sub_dir",
			Children: []mtouch.FileTree{
				{
					Name: "other_file.txt",
				},
			},
		},
		{
			Name:     "empty_dir",
			Children: []FileTree{},
		},
	}

	// creates the file tree in a memory file system
	fs, err := Touch(tree)

	// created the file tree in the provided directory of the memory file system
	fs, err := Touch(tree, WithBasePath("/my/path"))

	// created the file tree in the provided directory of the current file system
	fs, err := Touch(tree,
			WithFileSystem(afero.NewOsFs()),
			WithBasePath("/my/path")
		)
}

# Functions

Touch creates a directory structure based on the given tree inside a temporary directory.
WithBasePath sets the base path for the filesystem.
WithFileSystem sets a custom filesystem to use.

# Structs

FileTree represents a file or directory.

# Type aliases

No description provided by the author