xattr

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2017 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.Setxattr(path, prefix+"test", []byte("test-attr-value")); err != nil {
    log.Fatal(err)
  }

  var data []byte
  data, err = xattr.Getxattr(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 Getxattr

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

Getxattr retrieves extended attribute data associated with path.

func Listxattr

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

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

func Removexattr

func Removexattr(path, name string) error

Removexattr removes the attribute associated with the given path.

func Setxattr

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

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

Types

type XAttrError

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

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

func (*XAttrError) Error

func (e *XAttrError) Error() string

Jump to

Keyboard shortcuts

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