xattr

package module
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2018 License: BSD-2-Clause Imports: 1 Imported by: 174

README

GoDoc Go Report Card Build Status

xattr

Extended attribute support for Go (linux + darwin + freebsd).

"Extended attributes are name:value pairs associated permanently with files and directories, similar to the environment strings associated with a process. An attribute may be defined or undefined. If it is defined, its value may be empty or non-empty." See more...

Example
  const path = "/tmp/myfile"
  const prefix = "user."

  if err := xattr.Set(path, prefix+"test", []byte("test-attr-value")); err != nil {
  	log.Fatal(err)
  }
 
  var list []string
  if list, err = xattr.List(path); err != nil {
  	log.Fatal(err)
  }
  
  var data []byte
  if data, err = xattr.Get(path, prefix+"test"); err != nil {
  	log.Fatal(err)
  }

  if err = xattr.Remove(path, prefix+"test"); err != nil {
  	log.Fatal(err)
  }

Documentation

Overview

Package xattr provides support for extended attributes on linux, darwin and freebsd. Extended attributes are name:value pairs associated permanently with files and directories, similar to the environment strings associated with a process. An attribute may be defined or undefined. If it is defined, its value may be empty or non-empty. More details you can find here: https://en.wikipedia.org/wiki/Extended_file_attributes

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Get added in v0.2.0

func Get(path, name string) ([]byte, error)

Get retrieves extended attribute data associated with path.

func List added in v0.2.0

func List(path string) ([]string, error)

List retrieves a list of names of extended attributes associated with the given path in the file system.

func Remove added in v0.2.0

func Remove(path, name string) error

Remove removes the attribute associated with the given path.

func Set added in v0.2.0

func Set(path, name string, data []byte) error

Set associates name and data together as an attribute of path.

func Supported added in v0.2.2

func Supported(path string) bool

Supported checks if filesystem supports extended attributes

Types

type Error added in v0.2.0

type Error struct {
	Op   string
	Path string
	Name string
	Err  error
}

Error records an error and the operation, file path and attribute that caused it.

func (*Error) Error added in v0.2.0

func (e *Error) Error() string

Jump to

Keyboard shortcuts

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