# README
xattr
Extended attribute support for Go (linux + darwin + freebsd + netbsd + solaris).
"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...
SetWithFlags
allows to additionally pass system flags to be forwarded to the underlying calls. FreeBSD and NetBSD do not support this and the parameter will be ignored.
The L
variants of all functions (LGet/LSet/...
) are identical to Get/Set/...
except that they
do not reference a symlink that appears at the end of a path. See
GoDoc for details.
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)
}
// One can also specify the flags parameter to be passed to the OS.
if err := xattr.SetWithFlags(path, prefix+"test", []byte("test-attr-value"), xattr.XATTR_CREATE); err != nil {
log.Fatal(err)
}
# Functions
FGet is like Get but accepts a os.File instead of a file path.
FList is like List but accepts a os.File instead of a file path.
FRemove is like Remove but accepts a os.File instead of a file path.
FSet is like Set but accepts a os.File instead of a file path.
FSetWithFlags is like SetWithFlags but accepts a os.File instead of a file path.
Get retrieves extended attribute data associated with path.
LGet is like Get but does not follow a symlink at the end of the path.
List retrieves a list of names of extended attributes associated with the given path in the file system.
LList is like List but does not follow a symlink at the end of the path.
LRemove is like Remove but does not follow a symlink at the end of the path.
LSet is like Set but does not follow a symlink at the end of the path.
LSetWithFlags is like SetWithFlags but does not follow a symlink at the end of the path.
Remove removes the attribute associated with the given path.
Set associates name and data together as an attribute of path.
SetWithFlags associates name and data together as an attribute of path.
# Constants
ENOATTR is not exported by the syscall package on Linux, because it is an alias for ENODATA.
No description provided by the author
No description provided by the author
XATTR_SUPPORTED will be true if the current platform is supported.