You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

2148 lines
71 KiB

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="theme-color" content="#375EAB">
<title>os - The Go Programming Language</title>
<link type="text/css" rel="stylesheet" href="../../lib/godoc/style.css">
<link rel="stylesheet" href="../../lib/godoc/jquery.treeview.css">
<script type="text/javascript">window.initFuncs = [];</script>
</head>
<body>
<div id='lowframe' style="position: fixed; bottom: 0; left: 0; height: 0; width: 100%; border-top: thin solid grey; background-color: white; overflow: auto;">
...
</div><!-- #lowframe -->
<div id="topbar" class="wide"><div class="container">
<div class="top-heading" id="heading-wide"><a href="http://localhost:6060/">The Go Programming Language</a></div>
<div class="top-heading" id="heading-narrow"><a href="http://localhost:6060/">Go</a></div>
<a href="index.html#" id="menu-button"><span id="menu-button-arrow">&#9661;</span></a>
<form method="GET" action="http://localhost:6060/search">
<div id="menu">
<a href="http://localhost:6060/doc/">Documents</a>
<a href="http://localhost:6060/pkg/">Packages</a>
<a href="http://localhost:6060/project/">The Project</a>
<a href="http://localhost:6060/help/">Help</a>
<a href="http://localhost:6060/blog/">Blog</a>
<input type="text" id="search" name="q" class="inactive" value="Search" placeholder="Search">
</div>
</form>
</div></div>
<div id="page" class="wide">
<div class="container">
<h1>Package os</h1>
<div id="nav"></div>
<!--
Copyright 2009 The Go Authors. All rights reserved.
Use of this source code is governed by a BSD-style
license that can be found in the LICENSE file.
-->
<!--
Note: Static (i.e., not template-generated) href and id
attributes start with "pkg-" to make it impossible for
them to conflict with generated attributes (some of which
correspond to Go identifiers).
-->
<script type='text/javascript'>
document.ANALYSIS_DATA = null;
document.CALLGRAPH = null;
</script>
<div id="short-nav">
<dl>
<dd><code>import "os"</code></dd>
</dl>
<dl>
<dd><a href="index.html#pkg-overview" class="overviewLink">Overview</a></dd>
<dd><a href="index.html#pkg-index" class="indexLink">Index</a></dd>
<dd><a href="index.html#pkg-subdirectories">Subdirectories</a></dd>
</dl>
</div>
<!-- The package's Name is printed as title by the top-level template -->
<div id="pkg-overview" class="toggleVisible">
<div class="collapsed">
<h2 class="toggleButton" title="Click to show Overview section">Overview ▹</h2>
</div>
<div class="expanded">
<h2 class="toggleButton" title="Click to hide Overview section">Overview ▾</h2>
<p>
Package os provides a platform-independent interface to operating system
functionality. The design is Unix-like, although the error handling is
Go-like; failing calls return values of type error rather than error numbers.
Often, more information is available within the error. For example,
if a call that takes a file name fails, such as Open or Stat, the error
will include the failing file name when printed and will be of type
*PathError, which may be unpacked for more information.
</p>
<p>
The os interface is intended to be uniform across all operating systems.
Features not generally available appear in the system-specific package syscall.
</p>
<p>
Here is a simple example, opening a file and reading some of it.
</p>
<pre>file, err := os.Open(&#34;file.go&#34;) // For read access.
if err != nil {
log.Fatal(err)
}
</pre>
<p>
If the open fails, the error string will be self-explanatory, like
</p>
<pre>open file.go: no such file or directory
</pre>
<p>
The file&#39;s data can then be read into a slice of bytes. Read and
Write take their byte counts from the length of the argument slice.
</p>
<pre>data := make([]byte, 100)
count, err := file.Read(data)
if err != nil {
log.Fatal(err)
}
fmt.Printf(&#34;read %d bytes: %q\n&#34;, count, data[:count])
</pre>
</div>
</div>
<div id="pkg-index" class="toggleVisible">
<div class="collapsed">
<h2 class="toggleButton" title="Click to show Index section">Index ▹</h2>
</div>
<div class="expanded">
<h2 class="toggleButton" title="Click to hide Index section">Index ▾</h2>
<!-- Table of contents for API; must be named manual-nav to turn off auto nav. -->
<div id="manual-nav">
<dl>
<dd><a href="index.html#pkg-constants">Constants</a></dd>
<dd><a href="index.html#pkg-variables">Variables</a></dd>
<dd><a href="index.html#Chdir">func Chdir(dir string) error</a></dd>
<dd><a href="index.html#Chmod">func Chmod(name string, mode FileMode) error</a></dd>
<dd><a href="index.html#Chown">func Chown(name string, uid, gid int) error</a></dd>
<dd><a href="index.html#Chtimes">func Chtimes(name string, atime time.Time, mtime time.Time) error</a></dd>
<dd><a href="index.html#Clearenv">func Clearenv()</a></dd>
<dd><a href="index.html#Environ">func Environ() []string</a></dd>
<dd><a href="index.html#Exit">func Exit(code int)</a></dd>
<dd><a href="index.html#Expand">func Expand(s string, mapping func(string) string) string</a></dd>
<dd><a href="index.html#ExpandEnv">func ExpandEnv(s string) string</a></dd>
<dd><a href="index.html#Getegid">func Getegid() int</a></dd>
<dd><a href="index.html#Getenv">func Getenv(key string) string</a></dd>
<dd><a href="index.html#Geteuid">func Geteuid() int</a></dd>
<dd><a href="index.html#Getgid">func Getgid() int</a></dd>
<dd><a href="index.html#Getgroups">func Getgroups() ([]int, error)</a></dd>
<dd><a href="index.html#Getpagesize">func Getpagesize() int</a></dd>
<dd><a href="index.html#Getpid">func Getpid() int</a></dd>
<dd><a href="index.html#Getppid">func Getppid() int</a></dd>
<dd><a href="index.html#Getuid">func Getuid() int</a></dd>
<dd><a href="index.html#Getwd">func Getwd() (dir string, err error)</a></dd>
<dd><a href="index.html#Hostname">func Hostname() (name string, err error)</a></dd>
<dd><a href="index.html#IsExist">func IsExist(err error) bool</a></dd>
<dd><a href="index.html#IsNotExist">func IsNotExist(err error) bool</a></dd>
<dd><a href="index.html#IsPathSeparator">func IsPathSeparator(c uint8) bool</a></dd>
<dd><a href="index.html#IsPermission">func IsPermission(err error) bool</a></dd>
<dd><a href="index.html#Lchown">func Lchown(name string, uid, gid int) error</a></dd>
<dd><a href="index.html#Link">func Link(oldname, newname string) error</a></dd>
<dd><a href="index.html#LookupEnv">func LookupEnv(key string) (string, bool)</a></dd>
<dd><a href="index.html#Mkdir">func Mkdir(name string, perm FileMode) error</a></dd>
<dd><a href="index.html#MkdirAll">func MkdirAll(path string, perm FileMode) error</a></dd>
<dd><a href="index.html#NewSyscallError">func NewSyscallError(syscall string, err error) error</a></dd>
<dd><a href="index.html#Readlink">func Readlink(name string) (string, error)</a></dd>
<dd><a href="index.html#Remove">func Remove(name string) error</a></dd>
<dd><a href="index.html#RemoveAll">func RemoveAll(path string) error</a></dd>
<dd><a href="index.html#Rename">func Rename(oldpath, newpath string) error</a></dd>
<dd><a href="index.html#SameFile">func SameFile(fi1, fi2 FileInfo) bool</a></dd>
<dd><a href="index.html#Setenv">func Setenv(key, value string) error</a></dd>
<dd><a href="index.html#Symlink">func Symlink(oldname, newname string) error</a></dd>
<dd><a href="index.html#TempDir">func TempDir() string</a></dd>
<dd><a href="index.html#Truncate">func Truncate(name string, size int64) error</a></dd>
<dd><a href="index.html#Unsetenv">func Unsetenv(key string) error</a></dd>
<dd><a href="index.html#File">type File</a></dd>
<dd>&nbsp; &nbsp; <a href="index.html#Create">func Create(name string) (*File, error)</a></dd>
<dd>&nbsp; &nbsp; <a href="index.html#NewFile">func NewFile(fd uintptr, name string) *File</a></dd>
<dd>&nbsp; &nbsp; <a href="index.html#Open">func Open(name string) (*File, error)</a></dd>
<dd>&nbsp; &nbsp; <a href="index.html#OpenFile">func OpenFile(name string, flag int, perm FileMode) (*File, error)</a></dd>
<dd>&nbsp; &nbsp; <a href="index.html#Pipe">func Pipe() (r *File, w *File, err error)</a></dd>
<dd>&nbsp; &nbsp; <a href="index.html#File.Chdir">func (f *File) Chdir() error</a></dd>
<dd>&nbsp; &nbsp; <a href="index.html#File.Chmod">func (f *File) Chmod(mode FileMode) error</a></dd>
<dd>&nbsp; &nbsp; <a href="index.html#File.Chown">func (f *File) Chown(uid, gid int) error</a></dd>
<dd>&nbsp; &nbsp; <a href="index.html#File.Close">func (f *File) Close() error</a></dd>
<dd>&nbsp; &nbsp; <a href="index.html#File.Fd">func (f *File) Fd() uintptr</a></dd>
<dd>&nbsp; &nbsp; <a href="index.html#File.Name">func (f *File) Name() string</a></dd>
<dd>&nbsp; &nbsp; <a href="index.html#File.Read">func (f *File) Read(b []byte) (n int, err error)</a></dd>
<dd>&nbsp; &nbsp; <a href="index.html#File.ReadAt">func (f *File) ReadAt(b []byte, off int64) (n int, err error)</a></dd>
<dd>&nbsp; &nbsp; <a href="index.html#File.Readdir">func (f *File) Readdir(n int) (fi []FileInfo, err error)</a></dd>
<dd>&nbsp; &nbsp; <a href="index.html#File.Readdirnames">func (f *File) Readdirnames(n int) (names []string, err error)</a></dd>
<dd>&nbsp; &nbsp; <a href="index.html#File.Seek">func (f *File) Seek(offset int64, whence int) (ret int64, err error)</a></dd>
<dd>&nbsp; &nbsp; <a href="index.html#File.Stat">func (f *File) Stat() (FileInfo, error)</a></dd>
<dd>&nbsp; &nbsp; <a href="index.html#File.Sync">func (f *File) Sync() error</a></dd>
<dd>&nbsp; &nbsp; <a href="index.html#File.Truncate">func (f *File) Truncate(size int64) error</a></dd>
<dd>&nbsp; &nbsp; <a href="index.html#File.Write">func (f *File) Write(b []byte) (n int, err error)</a></dd>
<dd>&nbsp; &nbsp; <a href="index.html#File.WriteAt">func (f *File) WriteAt(b []byte, off int64) (n int, err error)</a></dd>
<dd>&nbsp; &nbsp; <a href="index.html#File.WriteString">func (f *File) WriteString(s string) (n int, err error)</a></dd>
<dd><a href="index.html#FileInfo">type FileInfo</a></dd>
<dd>&nbsp; &nbsp; <a href="index.html#Lstat">func Lstat(name string) (FileInfo, error)</a></dd>
<dd>&nbsp; &nbsp; <a href="index.html#Stat">func Stat(name string) (FileInfo, error)</a></dd>
<dd><a href="index.html#FileMode">type FileMode</a></dd>
<dd>&nbsp; &nbsp; <a href="index.html#FileMode.IsDir">func (m FileMode) IsDir() bool</a></dd>
<dd>&nbsp; &nbsp; <a href="index.html#FileMode.IsRegular">func (m FileMode) IsRegular() bool</a></dd>
<dd>&nbsp; &nbsp; <a href="index.html#FileMode.Perm">func (m FileMode) Perm() FileMode</a></dd>
<dd>&nbsp; &nbsp; <a href="index.html#FileMode.String">func (m FileMode) String() string</a></dd>
<dd><a href="index.html#LinkError">type LinkError</a></dd>
<dd>&nbsp; &nbsp; <a href="index.html#LinkError.Error">func (e *LinkError) Error() string</a></dd>
<dd><a href="index.html#PathError">type PathError</a></dd>
<dd>&nbsp; &nbsp; <a href="index.html#PathError.Error">func (e *PathError) Error() string</a></dd>
<dd><a href="index.html#ProcAttr">type ProcAttr</a></dd>
<dd><a href="index.html#Process">type Process</a></dd>
<dd>&nbsp; &nbsp; <a href="index.html#FindProcess">func FindProcess(pid int) (*Process, error)</a></dd>
<dd>&nbsp; &nbsp; <a href="index.html#StartProcess">func StartProcess(name string, argv []string, attr *ProcAttr) (*Process, error)</a></dd>
<dd>&nbsp; &nbsp; <a href="index.html#Process.Kill">func (p *Process) Kill() error</a></dd>
<dd>&nbsp; &nbsp; <a href="index.html#Process.Release">func (p *Process) Release() error</a></dd>
<dd>&nbsp; &nbsp; <a href="index.html#Process.Signal">func (p *Process) Signal(sig Signal) error</a></dd>
<dd>&nbsp; &nbsp; <a href="index.html#Process.Wait">func (p *Process) Wait() (*ProcessState, error)</a></dd>
<dd><a href="index.html#ProcessState">type ProcessState</a></dd>
<dd>&nbsp; &nbsp; <a href="index.html#ProcessState.Exited">func (p *ProcessState) Exited() bool</a></dd>
<dd>&nbsp; &nbsp; <a href="index.html#ProcessState.Pid">func (p *ProcessState) Pid() int</a></dd>
<dd>&nbsp; &nbsp; <a href="index.html#ProcessState.String">func (p *ProcessState) String() string</a></dd>
<dd>&nbsp; &nbsp; <a href="index.html#ProcessState.Success">func (p *ProcessState) Success() bool</a></dd>
<dd>&nbsp; &nbsp; <a href="index.html#ProcessState.Sys">func (p *ProcessState) Sys() interface{}</a></dd>
<dd>&nbsp; &nbsp; <a href="index.html#ProcessState.SysUsage">func (p *ProcessState) SysUsage() interface{}</a></dd>
<dd>&nbsp; &nbsp; <a href="index.html#ProcessState.SystemTime">func (p *ProcessState) SystemTime() time.Duration</a></dd>
<dd>&nbsp; &nbsp; <a href="index.html#ProcessState.UserTime">func (p *ProcessState) UserTime() time.Duration</a></dd>
<dd><a href="index.html#Signal">type Signal</a></dd>
<dd><a href="index.html#SyscallError">type SyscallError</a></dd>
<dd>&nbsp; &nbsp; <a href="index.html#SyscallError.Error">func (e *SyscallError) Error() string</a></dd>
</dl>
</div><!-- #manual-nav -->
<h4>Package files</h4>
<p>
<span style="font-size:90%">
<a href="http://localhost:6060/src/os/dir_unix.go">dir_unix.go</a>
<a href="http://localhost:6060/src/os/doc.go">doc.go</a>
<a href="http://localhost:6060/src/os/env.go">env.go</a>
<a href="http://localhost:6060/src/os/error.go">error.go</a>
<a href="http://localhost:6060/src/os/error_unix.go">error_unix.go</a>
<a href="http://localhost:6060/src/os/exec.go">exec.go</a>
<a href="http://localhost:6060/src/os/exec_posix.go">exec_posix.go</a>
<a href="http://localhost:6060/src/os/exec_unix.go">exec_unix.go</a>
<a href="http://localhost:6060/src/os/file.go">file.go</a>
<a href="http://localhost:6060/src/os/file_posix.go">file_posix.go</a>
<a href="http://localhost:6060/src/os/file_unix.go">file_unix.go</a>
<a href="http://localhost:6060/src/os/getwd.go">getwd.go</a>
<a href="http://localhost:6060/src/os/path.go">path.go</a>
<a href="http://localhost:6060/src/os/path_unix.go">path_unix.go</a>
<a href="http://localhost:6060/src/os/pipe_linux.go">pipe_linux.go</a>
<a href="http://localhost:6060/src/os/proc.go">proc.go</a>
<a href="http://localhost:6060/src/os/stat_linux.go">stat_linux.go</a>
<a href="http://localhost:6060/src/os/sticky_notbsd.go">sticky_notbsd.go</a>
<a href="http://localhost:6060/src/os/str.go">str.go</a>
<a href="http://localhost:6060/src/os/sys_linux.go">sys_linux.go</a>
<a href="http://localhost:6060/src/os/sys_unix.go">sys_unix.go</a>
<a href="http://localhost:6060/src/os/types.go">types.go</a>
<a href="http://localhost:6060/src/os/types_unix.go">types_unix.go</a>
</span>
</p>
</div><!-- .expanded -->
</div><!-- #pkg-index -->
<div id="pkg-callgraph" class="toggle" style="display: none">
<div class="collapsed">
<h2 class="toggleButton" title="Click to show Internal Call Graph section">Internal call graph ▹</h2>
</div> <!-- .expanded -->
<div class="expanded">
<h2 class="toggleButton" title="Click to hide Internal Call Graph section">Internal call graph ▾</h2>
<p>
In the call graph viewer below, each node
is a function belonging to this package
and its children are the functions it
calls&mdash;perhaps dynamically.
</p>
<p>
The root nodes are the entry points of the
package: functions that may be called from
outside the package.
There may be non-exported or anonymous
functions among them if they are called
dynamically from another package.
</p>
<p>
Click a node to visit that function's source code.
From there you can visit its callers by
clicking its declaring <code>func</code>
token.
</p>
<p>
Functions may be omitted if they were
determined to be unreachable in the
particular programs or tests that were
analyzed.
</p>
<!-- Zero means show all package entry points. -->
<ul style="margin-left: 0.5in" id="callgraph-0" class="treeview"></ul>
</div>
</div> <!-- #pkg-callgraph -->
<h2 id="pkg-constants">Constants</h2>
<pre>const (
<span id="O_RDONLY">O_RDONLY</span> <a href="../builtin/index.html#int">int</a> = <a href="../syscall/index.html">syscall</a>.<a href="../syscall/index.html#O_RDONLY">O_RDONLY</a> <span class="comment">// open the file read-only.</span>
<span id="O_WRONLY">O_WRONLY</span> <a href="../builtin/index.html#int">int</a> = <a href="../syscall/index.html">syscall</a>.<a href="../syscall/index.html#O_WRONLY">O_WRONLY</a> <span class="comment">// open the file write-only.</span>
<span id="O_RDWR">O_RDWR</span> <a href="../builtin/index.html#int">int</a> = <a href="../syscall/index.html">syscall</a>.<a href="../syscall/index.html#O_RDWR">O_RDWR</a> <span class="comment">// open the file read-write.</span>
<span id="O_APPEND">O_APPEND</span> <a href="../builtin/index.html#int">int</a> = <a href="../syscall/index.html">syscall</a>.<a href="../syscall/index.html#O_APPEND">O_APPEND</a> <span class="comment">// append data to the file when writing.</span>
<span id="O_CREATE">O_CREATE</span> <a href="../builtin/index.html#int">int</a> = <a href="../syscall/index.html">syscall</a>.<a href="../syscall/index.html#O_CREAT">O_CREAT</a> <span class="comment">// create a new file if none exists.</span>
<span id="O_EXCL">O_EXCL</span> <a href="../builtin/index.html#int">int</a> = <a href="../syscall/index.html">syscall</a>.<a href="../syscall/index.html#O_EXCL">O_EXCL</a> <span class="comment">// used with O_CREATE, file must not exist</span>
<span id="O_SYNC">O_SYNC</span> <a href="../builtin/index.html#int">int</a> = <a href="../syscall/index.html">syscall</a>.<a href="../syscall/index.html#O_SYNC">O_SYNC</a> <span class="comment">// open for synchronous I/O.</span>
<span id="O_TRUNC">O_TRUNC</span> <a href="../builtin/index.html#int">int</a> = <a href="../syscall/index.html">syscall</a>.<a href="../syscall/index.html#O_TRUNC">O_TRUNC</a> <span class="comment">// if possible, truncate file when opened.</span>
)</pre>
<p>
Flags to OpenFile wrapping those of the underlying system. Not all
flags may be implemented on a given system.
</p>
<pre>const (
<span id="SEEK_SET">SEEK_SET</span> <a href="../builtin/index.html#int">int</a> = 0 <span class="comment">// seek relative to the origin of the file</span>
<span id="SEEK_CUR">SEEK_CUR</span> <a href="../builtin/index.html#int">int</a> = 1 <span class="comment">// seek relative to the current offset</span>
<span id="SEEK_END">SEEK_END</span> <a href="../builtin/index.html#int">int</a> = 2 <span class="comment">// seek relative to the end</span>
)</pre>
<p>
Seek whence values.
</p>
<pre>const (
<span id="PathSeparator">PathSeparator</span> = &#39;/&#39; <span class="comment">// OS-specific path separator</span>
<span id="PathListSeparator">PathListSeparator</span> = &#39;:&#39; <span class="comment">// OS-specific path list separator</span>
)</pre>
<pre>const <span id="DevNull">DevNull</span> = &#34;/dev/null&#34;</pre>
<p>
DevNull is the name of the operating system&#39;s &ldquo;null device.&rdquo;
On Unix-like systems, it is &#34;/dev/null&#34;; on Windows, &#34;NUL&#34;.
</p>
<h2 id="pkg-variables">Variables</h2>
<pre>var (
<span id="ErrInvalid">ErrInvalid</span> = <a href="../errors/index.html">errors</a>.<a href="../errors/index.html#New">New</a>(&#34;invalid argument&#34;) <span class="comment">// methods on File will return this error when the receiver is nil</span>
<span id="ErrPermission">ErrPermission</span> = <a href="../errors/index.html">errors</a>.<a href="../errors/index.html#New">New</a>(&#34;permission denied&#34;)
<span id="ErrExist">ErrExist</span> = <a href="../errors/index.html">errors</a>.<a href="../errors/index.html#New">New</a>(&#34;file already exists&#34;)
<span id="ErrNotExist">ErrNotExist</span> = <a href="../errors/index.html">errors</a>.<a href="../errors/index.html#New">New</a>(&#34;file does not exist&#34;)
)</pre>
<p>
Portable analogs of some common system call errors.
</p>
<pre>var (
<span id="Stdin">Stdin</span> = <a href="index.html#NewFile">NewFile</a>(<a href="../builtin/index.html#uintptr">uintptr</a>(<a href="../syscall/index.html">syscall</a>.<a href="../syscall/index.html#Stdin">Stdin</a>), &#34;/dev/stdin&#34;)
<span id="Stdout">Stdout</span> = <a href="index.html#NewFile">NewFile</a>(<a href="../builtin/index.html#uintptr">uintptr</a>(<a href="../syscall/index.html">syscall</a>.<a href="../syscall/index.html#Stdout">Stdout</a>), &#34;/dev/stdout&#34;)
<span id="Stderr">Stderr</span> = <a href="index.html#NewFile">NewFile</a>(<a href="../builtin/index.html#uintptr">uintptr</a>(<a href="../syscall/index.html">syscall</a>.<a href="../syscall/index.html#Stderr">Stderr</a>), &#34;/dev/stderr&#34;)
)</pre>
<p>
Stdin, Stdout, and Stderr are open Files pointing to the standard input,
standard output, and standard error file descriptors.
</p>
<pre>var <span id="Args">Args</span> []<a href="../builtin/index.html#string">string</a></pre>
<p>
Args hold the command-line arguments, starting with the program name.
</p>
<h2 id="Chdir">func <a href="http://localhost:6060/src/os/file.go?s=6359:6387#L209">Chdir</a></h2>
<pre>func Chdir(dir <a href="../builtin/index.html#string">string</a>) <a href="../builtin/index.html#error">error</a></pre>
<p>
Chdir changes the current working directory to the named directory.
If there is an error, it will be of type *PathError.
</p>
<h2 id="Chmod">func <a href="http://localhost:6060/src/os/file_posix.go?s=1266:1310#L40">Chmod</a></h2>
<pre>func Chmod(name <a href="../builtin/index.html#string">string</a>, mode <a href="index.html#FileMode">FileMode</a>) <a href="../builtin/index.html#error">error</a></pre>
<p>
Chmod changes the mode of the named file to mode.
If the file is a symbolic link, it changes the mode of the link&#39;s target.
If there is an error, it will be of type *PathError.
</p>
<h2 id="Chown">func <a href="http://localhost:6060/src/os/file_posix.go?s=1933:1976#L62">Chown</a></h2>
<pre>func Chown(name <a href="../builtin/index.html#string">string</a>, uid, gid <a href="../builtin/index.html#int">int</a>) <a href="../builtin/index.html#error">error</a></pre>
<p>
Chown changes the numeric uid and gid of the named file.
If the file is a symbolic link, it changes the uid and gid of the link&#39;s target.
If there is an error, it will be of type *PathError.
</p>
<h2 id="Chtimes">func <a href="http://localhost:6060/src/os/file_posix.go?s=3693:3758#L123">Chtimes</a></h2>
<pre>func Chtimes(name <a href="../builtin/index.html#string">string</a>, atime <a href="../time/index.html">time</a>.<a href="../time/index.html#Time">Time</a>, mtime <a href="../time/index.html">time</a>.<a href="../time/index.html#Time">Time</a>) <a href="../builtin/index.html#error">error</a></pre>
<p>
Chtimes changes the access and modification times of the named
file, similar to the Unix utime() or utimes() functions.
</p>
<p>
The underlying filesystem may truncate or round the values to a
less precise time unit.
If there is an error, it will be of type *PathError.
</p>
<h2 id="Clearenv">func <a href="http://localhost:6060/src/os/env.go?s=3213:3228#L99">Clearenv</a></h2>
<pre>func Clearenv()</pre>
<p>
Clearenv deletes all environment variables.
</p>
<h2 id="Environ">func <a href="http://localhost:6060/src/os/env.go?s=3349:3372#L105">Environ</a></h2>
<pre>func Environ() []<a href="../builtin/index.html#string">string</a></pre>
<p>
Environ returns a copy of strings representing the environment,
in the form &#34;key=value&#34;.
</p>
<h2 id="Exit">func <a href="http://localhost:6060/src/os/proc.go?s=1325:1344#L38">Exit</a></h2>
<pre>func Exit(code <a href="../builtin/index.html#int">int</a>)</pre>
<p>
Exit causes the current program to exit with the given status code.
Conventionally, code zero indicates success, non-zero an error.
The program terminates immediately; deferred functions are not run.
</p>
<h2 id="Expand">func <a href="http://localhost:6060/src/os/env.go?s=379:436#L3">Expand</a></h2>
<pre>func Expand(s <a href="../builtin/index.html#string">string</a>, mapping func(<a href="../builtin/index.html#string">string</a>) <a href="../builtin/index.html#string">string</a>) <a href="../builtin/index.html#string">string</a></pre>
<p>
Expand replaces ${var} or $var in the string based on the mapping function.
For example, os.ExpandEnv(s) is equivalent to os.Expand(s, os.Getenv).
</p>
<h2 id="ExpandEnv">func <a href="http://localhost:6060/src/os/env.go?s=963:994#L22">ExpandEnv</a></h2>
<pre>func ExpandEnv(s <a href="../builtin/index.html#string">string</a>) <a href="../builtin/index.html#string">string</a></pre>
<p>
ExpandEnv replaces ${var} or $var in the string according to the values
of the current environment variables. References to undefined
variables are replaced by the empty string.
</p>
<h2 id="Getegid">func <a href="http://localhost:6060/src/os/proc.go?s=867:885#L27">Getegid</a></h2>
<pre>func Getegid() <a href="../builtin/index.html#int">int</a></pre>
<p>
Getegid returns the numeric effective group id of the caller.
</p>
<h2 id="Getenv">func <a href="http://localhost:6060/src/os/env.go?s=2368:2398#L69">Getenv</a></h2>
<pre>func Getenv(key <a href="../builtin/index.html#string">string</a>) <a href="../builtin/index.html#string">string</a></pre>
<p>
Getenv retrieves the value of the environment variable named by the key.
It returns the value, which will be empty if the variable is not present.
</p>
<h2 id="Geteuid">func <a href="http://localhost:6060/src/os/proc.go?s=652:670#L21">Geteuid</a></h2>
<pre>func Geteuid() <a href="../builtin/index.html#int">int</a></pre>
<p>
Geteuid returns the numeric effective user id of the caller.
</p>
<h2 id="Getgid">func <a href="http://localhost:6060/src/os/proc.go?s=755:772#L24">Getgid</a></h2>
<pre>func Getgid() <a href="../builtin/index.html#int">int</a></pre>
<p>
Getgid returns the numeric group id of the caller.
</p>
<h2 id="Getgroups">func <a href="http://localhost:6060/src/os/proc.go?s=1001:1032#L30">Getgroups</a></h2>
<pre>func Getgroups() ([]<a href="../builtin/index.html#int">int</a>, <a href="../builtin/index.html#error">error</a>)</pre>
<p>
Getgroups returns a list of the numeric ids of groups that the caller belongs to.
</p>
<h2 id="Getpagesize">func <a href="http://localhost:6060/src/os/types.go?s=268:290#L3">Getpagesize</a></h2>
<pre>func Getpagesize() <a href="../builtin/index.html#int">int</a></pre>
<p>
Getpagesize returns the underlying system&#39;s memory page size.
</p>
<h2 id="Getpid">func <a href="http://localhost:6060/src/os/exec.go?s=2054:2071#L57">Getpid</a></h2>
<pre>func Getpid() <a href="../builtin/index.html#int">int</a></pre>
<p>
Getpid returns the process id of the caller.
</p>
<h2 id="Getppid">func <a href="http://localhost:6060/src/os/exec.go?s=2159:2177#L60">Getppid</a></h2>
<pre>func Getppid() <a href="../builtin/index.html#int">int</a></pre>
<p>
Getppid returns the process id of the caller&#39;s parent.
</p>
<h2 id="Getuid">func <a href="http://localhost:6060/src/os/proc.go?s=541:558#L18">Getuid</a></h2>
<pre>func Getuid() <a href="../builtin/index.html#int">int</a></pre>
<p>
Getuid returns the numeric user id of the caller.
</p>
<h2 id="Getwd">func <a href="http://localhost:6060/src/os/getwd.go?s=621:657#L16">Getwd</a></h2>
<pre>func Getwd() (dir <a href="../builtin/index.html#string">string</a>, err <a href="../builtin/index.html#error">error</a>)</pre>
<p>
Getwd returns a rooted path name corresponding to the
current directory. If the current directory can be
reached via multiple paths (due to symbolic links),
Getwd may return any one of them.
</p>
<h2 id="Hostname">func <a href="http://localhost:6060/src/os/doc.go?s=3068:3108#L86">Hostname</a></h2>
<pre>func Hostname() (name <a href="../builtin/index.html#string">string</a>, err <a href="../builtin/index.html#error">error</a>)</pre>
<p>
Hostname returns the host name reported by the kernel.
</p>
<h2 id="IsExist">func <a href="http://localhost:6060/src/os/error.go?s=1454:1482#L39">IsExist</a></h2>
<pre>func IsExist(err <a href="../builtin/index.html#error">error</a>) <a href="../builtin/index.html#bool">bool</a></pre>
<p>
IsExist returns a boolean indicating whether the error is known to report
that a file or directory already exists. It is satisfied by ErrExist as
well as some syscall errors.
</p>
<h2 id="IsNotExist">func <a href="http://localhost:6060/src/os/error.go?s=1699:1730#L46">IsNotExist</a></h2>
<pre>func IsNotExist(err <a href="../builtin/index.html#error">error</a>) <a href="../builtin/index.html#bool">bool</a></pre>
<p>
IsNotExist returns a boolean indicating whether the error is known to
report that a file or directory does not exist. It is satisfied by
ErrNotExist as well as some syscall errors.
</p>
<h2 id="IsPathSeparator">func <a href="http://localhost:6060/src/os/path_unix.go?s=441:475#L5">IsPathSeparator</a></h2>
<pre>func IsPathSeparator(c <a href="../builtin/index.html#uint8">uint8</a>) <a href="../builtin/index.html#bool">bool</a></pre>
<p>
IsPathSeparator reports whether c is a directory separator character.
</p>
<h2 id="IsPermission">func <a href="http://localhost:6060/src/os/error.go?s=1940:1973#L53">IsPermission</a></h2>
<pre>func IsPermission(err <a href="../builtin/index.html#error">error</a>) <a href="../builtin/index.html#bool">bool</a></pre>
<p>
IsPermission returns a boolean indicating whether the error is known to
report that permission is denied. It is satisfied by ErrPermission as well
as some syscall errors.
</p>
<h2 id="Lchown">func <a href="http://localhost:6060/src/os/file_posix.go?s=2285:2329#L72">Lchown</a></h2>
<pre>func Lchown(name <a href="../builtin/index.html#string">string</a>, uid, gid <a href="../builtin/index.html#int">int</a>) <a href="../builtin/index.html#error">error</a></pre>
<p>
Lchown changes the numeric uid and gid of the named file.
If the file is a symbolic link, it changes the uid and gid of the link itself.
If there is an error, it will be of type *PathError.
</p>
<h2 id="Link">func <a href="http://localhost:6060/src/os/file_unix.go?s=9855:9895#L350">Link</a></h2>
<pre>func Link(oldname, newname <a href="../builtin/index.html#string">string</a>) <a href="../builtin/index.html#error">error</a></pre>
<p>
Link creates newname as a hard link to the oldname file.
If there is an error, it will be of type *LinkError.
</p>
<h2 id="LookupEnv">func <a href="http://localhost:6060/src/os/env.go?s=2722:2763#L79">LookupEnv</a></h2>
<pre>func LookupEnv(key <a href="../builtin/index.html#string">string</a>) (<a href="../builtin/index.html#string">string</a>, <a href="../builtin/index.html#bool">bool</a>)</pre>
<p>
LookupEnv retrieves the value of the environment variable named
by the key. If the variable is present in the environment the
value (which may be empty) is returned and the boolean is true.
Otherwise the returned value will be empty and the boolean will
be false.
</p>
<h2 id="Mkdir">func <a href="http://localhost:6060/src/os/file.go?s=5916:5960#L192">Mkdir</a></h2>
<pre>func Mkdir(name <a href="../builtin/index.html#string">string</a>, perm <a href="index.html#FileMode">FileMode</a>) <a href="../builtin/index.html#error">error</a></pre>
<p>
Mkdir creates a new directory with the specified name and permission bits.
If there is an error, it will be of type *PathError.
</p>
<h2 id="MkdirAll">func <a href="http://localhost:6060/src/os/path.go?s=488:535#L9">MkdirAll</a></h2>
<pre>func MkdirAll(path <a href="../builtin/index.html#string">string</a>, perm <a href="index.html#FileMode">FileMode</a>) <a href="../builtin/index.html#error">error</a></pre>
<p>
MkdirAll creates a directory named path,
along with any necessary parents, and returns nil,
or else returns an error.
The permission bits perm are used for all
directories that MkdirAll creates.
If path is already a directory, MkdirAll does nothing
and returns nil.
</p>
<h2 id="NewSyscallError">func <a href="http://localhost:6060/src/os/error.go?s=1142:1195#L29">NewSyscallError</a></h2>
<pre>func NewSyscallError(syscall <a href="../builtin/index.html#string">string</a>, err <a href="../builtin/index.html#error">error</a>) <a href="../builtin/index.html#error">error</a></pre>
<p>
NewSyscallError returns, as an error, a new SyscallError
with the given system call name and error details.
As a convenience, if err is nil, NewSyscallError returns nil.
</p>
<h2 id="Readlink">func <a href="http://localhost:6060/src/os/file_posix.go?s=451:493#L8">Readlink</a></h2>
<pre>func Readlink(name <a href="../builtin/index.html#string">string</a>) (<a href="../builtin/index.html#string">string</a>, <a href="../builtin/index.html#error">error</a>)</pre>
<p>
Readlink returns the destination of the named symbolic link.
If there is an error, it will be of type *PathError.
</p>
<h2 id="Remove">func <a href="http://localhost:6060/src/os/file_unix.go?s=8300:8330#L288">Remove</a></h2>
<pre>func Remove(name <a href="../builtin/index.html#string">string</a>) <a href="../builtin/index.html#error">error</a></pre>
<p>
Remove removes the named file or directory.
If there is an error, it will be of type *PathError.
</p>
<h2 id="RemoveAll">func <a href="http://localhost:6060/src/os/path.go?s=1635:1668#L56">RemoveAll</a></h2>
<pre>func RemoveAll(path <a href="../builtin/index.html#string">string</a>) <a href="../builtin/index.html#error">error</a></pre>
<p>
RemoveAll removes path and any children it contains.
It removes everything it can but returns the first error
it encounters. If the path does not exist, RemoveAll
returns nil (no error).
</p>
<h2 id="Rename">func <a href="http://localhost:6060/src/os/file.go?s=7777:7819#L253">Rename</a></h2>
<pre>func Rename(oldpath, newpath <a href="../builtin/index.html#string">string</a>) <a href="../builtin/index.html#error">error</a></pre>
<p>
Rename renames (moves) oldpath to newpath.
If newpath already exists, Rename replaces it.
OS-specific restrictions may apply when oldpath and newpath are in different directories.
If there is an error, it will be of type *LinkError.
</p>
<h2 id="SameFile">func <a href="http://localhost:6060/src/os/types.go?s=3885:3922#L101">SameFile</a></h2>
<pre>func SameFile(fi1, fi2 <a href="index.html#FileInfo">FileInfo</a>) <a href="../builtin/index.html#bool">bool</a></pre>
<p>
SameFile reports whether fi1 and fi2 describe the same file.
For example, on Unix this means that the device and inode fields
of the two underlying structures are identical; on other systems
the decision may be based on the path names.
SameFile only applies to results returned by this package&#39;s Stat.
It returns false in other cases.
</p>
<h2 id="Setenv">func <a href="http://localhost:6060/src/os/env.go?s=2900:2936#L85">Setenv</a></h2>
<pre>func Setenv(key, value <a href="../builtin/index.html#string">string</a>) <a href="../builtin/index.html#error">error</a></pre>
<p>
Setenv sets the value of the environment variable named by the key.
It returns an error, if any.
</p>
<h2 id="Symlink">func <a href="http://localhost:6060/src/os/file_unix.go?s=10131:10174#L360">Symlink</a></h2>
<pre>func Symlink(oldname, newname <a href="../builtin/index.html#string">string</a>) <a href="../builtin/index.html#error">error</a></pre>
<p>
Symlink creates newname as a symbolic link to oldname.
If there is an error, it will be of type *LinkError.
</p>
<h2 id="TempDir">func <a href="http://localhost:6060/src/os/file_unix.go?s=9565:9586#L336">TempDir</a></h2>
<pre>func TempDir() <a href="../builtin/index.html#string">string</a></pre>
<p>
TempDir returns the default directory to use for temporary files.
</p>
<h2 id="Truncate">func <a href="http://localhost:6060/src/os/file_unix.go?s=8041:8085#L279">Truncate</a></h2>
<pre>func Truncate(name <a href="../builtin/index.html#string">string</a>, size <a href="../builtin/index.html#int64">int64</a>) <a href="../builtin/index.html#error">error</a></pre>
<p>
Truncate changes the size of the named file.
If the file is a symbolic link, it changes the size of the link&#39;s target.
If there is an error, it will be of type *PathError.
</p>
<h2 id="Unsetenv">func <a href="http://localhost:6060/src/os/env.go?s=3099:3130#L94">Unsetenv</a></h2>
<pre>func Unsetenv(key <a href="../builtin/index.html#string">string</a>) <a href="../builtin/index.html#error">error</a></pre>
<p>
Unsetenv unsets a single environment variable.
</p>
<h2 id="File">type <a href="http://localhost:6060/src/os/file_unix.go?s=597:624#L17">File</a></h2>
<pre>type File struct {
<span class="comment">// contains filtered or unexported fields</span>
}</pre>
<p>
File represents an open file descriptor.
</p>
<h3 id="Create">func <a href="http://localhost:6060/src/os/file.go?s=7381:7420#L242">Create</a></h3>
<pre>func Create(name <a href="../builtin/index.html#string">string</a>) (*<a href="index.html#File">File</a>, <a href="../builtin/index.html#error">error</a>)</pre>
<p>
Create creates the named file with mode 0666 (before umask), truncating
it if it already exists. If successful, methods on the returned
File can be used for I/O; the associated file descriptor has mode
O_RDWR.
If there is an error, it will be of type *PathError.
</p>
<h3 id="NewFile">func <a href="http://localhost:6060/src/os/file_unix.go?s=1267:1310#L41">NewFile</a></h3>
<pre>func NewFile(fd <a href="../builtin/index.html#uintptr">uintptr</a>, name <a href="../builtin/index.html#string">string</a>) *<a href="index.html#File">File</a></pre>
<p>
NewFile returns a new File with the given file descriptor and name.
</p>
<h3 id="Open">func <a href="http://localhost:6060/src/os/file.go?s=7024:7061#L233">Open</a></h3>
<pre>func Open(name <a href="../builtin/index.html#string">string</a>) (*<a href="index.html#File">File</a>, <a href="../builtin/index.html#error">error</a>)</pre>
<p>
Open opens the named file for reading. If successful, methods on
the returned file can be used for reading; the associated file
descriptor has mode O_RDONLY.
If there is an error, it will be of type *PathError.
</p>
<h3 id="OpenFile">func <a href="http://localhost:6060/src/os/file_unix.go?s=2432:2498#L76">OpenFile</a></h3>
<pre>func OpenFile(name <a href="../builtin/index.html#string">string</a>, flag <a href="../builtin/index.html#int">int</a>, perm <a href="index.html#FileMode">FileMode</a>) (*<a href="index.html#File">File</a>, <a href="../builtin/index.html#error">error</a>)</pre>
<p>
OpenFile is the generalized open call; most users will use Open
or Create instead. It opens the named file with specified flag
(O_RDONLY etc.) and perm, (0666 etc.) if applicable. If successful,
methods on the returned File can be used for I/O.
If there is an error, it will be of type *PathError.
</p>
<h3 id="Pipe">func <a href="http://localhost:6060/src/os/pipe_linux.go?s=319:360#L1">Pipe</a></h3>
<pre>func Pipe() (r *<a href="index.html#File">File</a>, w *<a href="index.html#File">File</a>, err <a href="../builtin/index.html#error">error</a>)</pre>
<p>
Pipe returns a connected pair of Files; reads from r return bytes written to w.
It returns the files and an error, if any.
</p>
<h3 id="File.Chdir">func (*File) <a href="http://localhost:6060/src/os/file.go?s=6631:6659#L219">Chdir</a></h3>
<pre>func (f *<a href="index.html#File">File</a>) Chdir() <a href="../builtin/index.html#error">error</a></pre>
<p>
Chdir changes the current working directory to the file,
which must be a directory.
If there is an error, it will be of type *PathError.
</p>
<h3 id="File.Chmod">func (*File) <a href="http://localhost:6060/src/os/file_posix.go?s=1532:1573#L49">Chmod</a></h3>
<pre>func (f *<a href="index.html#File">File</a>) Chmod(mode <a href="index.html#FileMode">FileMode</a>) <a href="../builtin/index.html#error">error</a></pre>
<p>
Chmod changes the mode of the file to mode.
If there is an error, it will be of type *PathError.
</p>
<h3 id="File.Chown">func (*File) <a href="http://localhost:6060/src/os/file_posix.go?s=2557:2597#L81">Chown</a></h3>
<pre>func (f *<a href="index.html#File">File</a>) Chown(uid, gid <a href="../builtin/index.html#int">int</a>) <a href="../builtin/index.html#error">error</a></pre>
<p>
Chown changes the numeric uid and gid of the named file.
If there is an error, it will be of type *PathError.
</p>
<h3 id="File.Close">func (*File) <a href="http://localhost:6060/src/os/file_unix.go?s=3525:3553#L118">Close</a></h3>
<pre>func (f *<a href="index.html#File">File</a>) Close() <a href="../builtin/index.html#error">error</a></pre>
<p>
Close closes the File, rendering it unusable for I/O.
It returns an error, if any.
</p>
<h3 id="File.Fd">func (*File) <a href="http://localhost:6060/src/os/file_unix.go?s=1100:1127#L33">Fd</a></h3>
<pre>func (f *<a href="index.html#File">File</a>) Fd() <a href="../builtin/index.html#uintptr">uintptr</a></pre>
<p>
Fd returns the integer Unix file descriptor referencing the open file.
The file descriptor is valid only until f.Close is called or f is garbage collected.
</p>
<h3 id="File.Name">func (*File) <a href="http://localhost:6060/src/os/file.go?s=1531:1559#L35">Name</a></h3>
<pre>func (f *<a href="index.html#File">File</a>) Name() <a href="../builtin/index.html#string">string</a></pre>
<p>
Name returns the name of the file as presented to Open.
</p>
<h3 id="File.Read">func (*File) <a href="http://localhost:6060/src/os/file.go?s=3218:3266#L81">Read</a></h3>
<pre>func (f *<a href="index.html#File">File</a>) Read(b []<a href="../builtin/index.html#byte">byte</a>) (n <a href="../builtin/index.html#int">int</a>, err <a href="../builtin/index.html#error">error</a>)</pre>
<p>
Read reads up to len(b) bytes from the File.
It returns the number of bytes read and an error, if any.
EOF is signaled by a zero count with err set to io.EOF.
</p>
<h3 id="File.ReadAt">func (*File) <a href="http://localhost:6060/src/os/file.go?s=3697:3758#L99">ReadAt</a></h3>
<pre>func (f *<a href="index.html#File">File</a>) ReadAt(b []<a href="../builtin/index.html#byte">byte</a>, off <a href="../builtin/index.html#int64">int64</a>) (n <a href="../builtin/index.html#int">int</a>, err <a href="../builtin/index.html#error">error</a>)</pre>
<p>
ReadAt reads len(b) bytes from the File starting at byte offset off.
It returns the number of bytes read and the error, if any.
ReadAt always returns a non-nil error when n &lt; len(b).
At end of file, that error is io.EOF.
</p>
<h3 id="File.Readdir">func (*File) <a href="http://localhost:6060/src/os/doc.go?s=3941:3997#L105">Readdir</a></h3>
<pre>func (f *<a href="index.html#File">File</a>) Readdir(n <a href="../builtin/index.html#int">int</a>) (fi []<a href="index.html#FileInfo">FileInfo</a>, err <a href="../builtin/index.html#error">error</a>)</pre>
<p>
Readdir reads the contents of the directory associated with file and
returns a slice of up to n FileInfo values, as would be returned
by Lstat, in directory order. Subsequent calls on the same file will yield
further FileInfos.
</p>
<p>
If n &gt; 0, Readdir returns at most n FileInfo structures. In this case, if
Readdir returns an empty slice, it will return a non-nil error
explaining why. At the end of a directory, the error is io.EOF.
</p>
<p>
If n &lt;= 0, Readdir returns all the FileInfo from the directory in
a single slice. In this case, if Readdir succeeds (reads all
the way to the end of the directory), it returns the slice and a
nil error. If it encounters an error before the end of the
directory, Readdir returns the FileInfo read until that point
and a non-nil error.
</p>
<h3 id="File.Readdirnames">func (*File) <a href="http://localhost:6060/src/os/doc.go?s=4713:4775#L124">Readdirnames</a></h3>
<pre>func (f *<a href="index.html#File">File</a>) Readdirnames(n <a href="../builtin/index.html#int">int</a>) (names []<a href="../builtin/index.html#string">string</a>, err <a href="../builtin/index.html#error">error</a>)</pre>
<p>
Readdirnames reads and returns a slice of names from the directory f.
</p>
<p>
If n &gt; 0, Readdirnames returns at most n names. In this case, if
Readdirnames returns an empty slice, it will return a non-nil error
explaining why. At the end of a directory, the error is io.EOF.
</p>
<p>
If n &lt;= 0, Readdirnames returns all the names from the directory in
a single slice. In this case, if Readdirnames succeeds (reads all
the way to the end of the directory), it returns the slice and a
nil error. If it encounters an error before the end of the
directory, Readdirnames returns the names read until that point and
a non-nil error.
</p>
<h3 id="File.Seek">func (*File) <a href="http://localhost:6060/src/os/file.go?s=5263:5331#L167">Seek</a></h3>
<pre>func (f *<a href="index.html#File">File</a>) Seek(offset <a href="../builtin/index.html#int64">int64</a>, whence <a href="../builtin/index.html#int">int</a>) (ret <a href="../builtin/index.html#int64">int64</a>, err <a href="../builtin/index.html#error">error</a>)</pre>
<p>
Seek sets the offset for the next Read or Write on file to offset, interpreted
according to whence: 0 means relative to the origin of the file, 1 means
relative to the current offset, and 2 means relative to the end.
It returns the new offset and an error, if any.
The behavior of Seek on a file opened with O_APPEND is not specified.
</p>
<h3 id="File.Stat">func (*File) <a href="http://localhost:6060/src/os/file_unix.go?s=4060:4099#L142">Stat</a></h3>
<pre>func (f *<a href="index.html#File">File</a>) Stat() (<a href="index.html#FileInfo">FileInfo</a>, <a href="../builtin/index.html#error">error</a>)</pre>
<p>
Stat returns the FileInfo structure describing file.
If there is an error, it will be of type *PathError.
</p>
<h3 id="File.Sync">func (*File) <a href="http://localhost:6060/src/os/file_posix.go?s=3250:3277#L107">Sync</a></h3>
<pre>func (f *<a href="index.html#File">File</a>) Sync() <a href="../builtin/index.html#error">error</a></pre>
<p>
Sync commits the current contents of the file to stable storage.
Typically, this means flushing the file system&#39;s in-memory copy
of recently written data to disk.
</p>
<h3 id="File.Truncate">func (*File) <a href="http://localhost:6060/src/os/file_posix.go?s=2884:2925#L94">Truncate</a></h3>
<pre>func (f *<a href="index.html#File">File</a>) Truncate(size <a href="../builtin/index.html#int64">int64</a>) <a href="../builtin/index.html#error">error</a></pre>
<p>
Truncate changes the size of the file.
It does not change the I/O offset.
If there is an error, it will be of type *PathError.
</p>
<h3 id="File.Write">func (*File) <a href="http://localhost:6060/src/os/file.go?s=4174:4223#L122">Write</a></h3>
<pre>func (f *<a href="index.html#File">File</a>) Write(b []<a href="../builtin/index.html#byte">byte</a>) (n <a href="../builtin/index.html#int">int</a>, err <a href="../builtin/index.html#error">error</a>)</pre>
<p>
Write writes len(b) bytes to the File.
It returns the number of bytes written and an error, if any.
Write returns a non-nil error when n != len(b).
</p>
<h3 id="File.WriteAt">func (*File) <a href="http://localhost:6060/src/os/file.go?s=4640:4702#L145">WriteAt</a></h3>
<pre>func (f *<a href="index.html#File">File</a>) WriteAt(b []<a href="../builtin/index.html#byte">byte</a>, off <a href="../builtin/index.html#int64">int64</a>) (n <a href="../builtin/index.html#int">int</a>, err <a href="../builtin/index.html#error">error</a>)</pre>
<p>
WriteAt writes len(b) bytes to the File starting at byte offset off.
It returns the number of bytes written and an error, if any.
WriteAt returns a non-nil error when n != len(b).
</p>
<h3 id="File.WriteString">func (*File) <a href="http://localhost:6060/src/os/file.go?s=5653:5708#L183">WriteString</a></h3>
<pre>func (f *<a href="index.html#File">File</a>) WriteString(s <a href="../builtin/index.html#string">string</a>) (n <a href="../builtin/index.html#int">int</a>, err <a href="../builtin/index.html#error">error</a>)</pre>
<p>
WriteString is like Write, but writes the contents of string s rather than
a slice of bytes.
</p>
<h2 id="FileInfo">type <a href="http://localhost:6060/src/os/types.go?s=391:752#L6">FileInfo</a></h2>
<pre>type FileInfo interface {
Name() <a href="../builtin/index.html#string">string</a> <span class="comment">// base name of the file</span>
Size() <a href="../builtin/index.html#int64">int64</a> <span class="comment">// length in bytes for regular files; system-dependent for others</span>
Mode() <a href="index.html#FileMode">FileMode</a> <span class="comment">// file mode bits</span>
ModTime() <a href="../time/index.html">time</a>.<a href="../time/index.html#Time">Time</a> <span class="comment">// modification time</span>
IsDir() <a href="../builtin/index.html#bool">bool</a> <span class="comment">// abbreviation for Mode().IsDir()</span>
Sys() interface{} <span class="comment">// underlying data source (can return nil)</span>
}</pre>
<p>
A FileInfo describes a file and is returned by Stat and Lstat.
</p>
<h3 id="Lstat">func <a href="http://localhost:6060/src/os/file_unix.go?s=4885:4926#L171">Lstat</a></h3>
<pre>func Lstat(name <a href="../builtin/index.html#string">string</a>) (<a href="index.html#FileInfo">FileInfo</a>, <a href="../builtin/index.html#error">error</a>)</pre>
<p>
Lstat returns a FileInfo describing the named file.
If the file is a symbolic link, the returned FileInfo
describes the symbolic link. Lstat makes no attempt to follow the link.
If there is an error, it will be of type *PathError.
</p>
<h3 id="Stat">func <a href="http://localhost:6060/src/os/file_unix.go?s=4429:4469#L157">Stat</a></h3>
<pre>func Stat(name <a href="../builtin/index.html#string">string</a>) (<a href="index.html#FileInfo">FileInfo</a>, <a href="../builtin/index.html#error">error</a>)</pre>
<p>
Stat returns a FileInfo describing the named file.
If there is an error, it will be of type *PathError.
</p>
<h2 id="FileMode">type <a href="http://localhost:6060/src/os/types.go?s=1044:1064#L20">FileMode</a></h2>
<pre>type FileMode <a href="../builtin/index.html#uint32">uint32</a></pre>
<p>
A FileMode represents a file&#39;s mode and permission bits.
The bits have the same definition on all systems, so that
information about files can be moved from one system
to another portably. Not all bits apply to all systems.
The only required bit is ModeDir for directories.
</p>
<pre>const (
<span class="comment">// The single letters are the abbreviations</span>
<span class="comment">// used by the String method&#39;s formatting.</span>
<span id="ModeDir">ModeDir</span> <a href="index.html#FileMode">FileMode</a> = 1 &lt;&lt; (32 - 1 - <a href="../builtin/index.html#iota">iota</a>) <span class="comment">// d: is a directory</span>
<span id="ModeAppend">ModeAppend</span> <span class="comment">// a: append-only</span>
<span id="ModeExclusive">ModeExclusive</span> <span class="comment">// l: exclusive use</span>
<span id="ModeTemporary">ModeTemporary</span> <span class="comment">// T: temporary file (not backed up)</span>
<span id="ModeSymlink">ModeSymlink</span> <span class="comment">// L: symbolic link</span>
<span id="ModeDevice">ModeDevice</span> <span class="comment">// D: device file</span>
<span id="ModeNamedPipe">ModeNamedPipe</span> <span class="comment">// p: named pipe (FIFO)</span>
<span id="ModeSocket">ModeSocket</span> <span class="comment">// S: Unix domain socket</span>
<span id="ModeSetuid">ModeSetuid</span> <span class="comment">// u: setuid</span>
<span id="ModeSetgid">ModeSetgid</span> <span class="comment">// g: setgid</span>
<span id="ModeCharDevice">ModeCharDevice</span> <span class="comment">// c: Unix character device, when ModeDevice is set</span>
<span id="ModeSticky">ModeSticky</span> <span class="comment">// t: sticky</span>
<span class="comment">// Mask for the type bits. For regular files, none will be set.</span>
<span id="ModeType">ModeType</span> = <a href="index.html#ModeDir">ModeDir</a> | <a href="index.html#ModeSymlink">ModeSymlink</a> | <a href="index.html#ModeNamedPipe">ModeNamedPipe</a> | <a href="index.html#ModeSocket">ModeSocket</a> | <a href="index.html#ModeDevice">ModeDevice</a>
<span id="ModePerm">ModePerm</span> <a href="index.html#FileMode">FileMode</a> = 0777 <span class="comment">// Unix permission bits</span>
)</pre>
<p>
The defined file mode bits are the most significant bits of the FileMode.
The nine least-significant bits are the standard Unix rwxrwxrwx permissions.
The values of these bits should be considered part of the public API and
may be used in wire protocols or disk representations: they must not be
changed, although new bits might be added.
</p>
<h3 id="FileMode.IsDir">func (FileMode) <a href="http://localhost:6060/src/os/types.go?s=3075:3105#L77">IsDir</a></h3>
<pre>func (m <a href="index.html#FileMode">FileMode</a>) IsDir() <a href="../builtin/index.html#bool">bool</a></pre>
<p>
IsDir reports whether m describes a directory.
That is, it tests for the ModeDir bit being set in m.
</p>
<h3 id="FileMode.IsRegular">func (FileMode) <a href="http://localhost:6060/src/os/types.go?s=3244:3278#L83">IsRegular</a></h3>
<pre>func (m <a href="index.html#FileMode">FileMode</a>) IsRegular() <a href="../builtin/index.html#bool">bool</a></pre>
<p>
IsRegular reports whether m describes a regular file.
That is, it tests that no mode type bits are set.
</p>
<h3 id="FileMode.Perm">func (FileMode) <a href="http://localhost:6060/src/os/types.go?s=3355:3388#L88">Perm</a></h3>
<pre>func (m <a href="index.html#FileMode">FileMode</a>) Perm() <a href="index.html#FileMode">FileMode</a></pre>
<p>
Perm returns the Unix permission bits in m.
</p>
<h3 id="FileMode.String">func (FileMode) <a href="http://localhost:6060/src/os/types.go?s=2563:2596#L49">String</a></h3>
<pre>func (m <a href="index.html#FileMode">FileMode</a>) String() <a href="../builtin/index.html#string">string</a></pre>
<h2 id="LinkError">type <a href="http://localhost:6060/src/os/file.go?s=2872:2944#L67">LinkError</a></h2>
<pre>type LinkError struct {
Op <a href="../builtin/index.html#string">string</a>
Old <a href="../builtin/index.html#string">string</a>
New <a href="../builtin/index.html#string">string</a>
Err <a href="../builtin/index.html#error">error</a>
}</pre>
<p>
LinkError records an error during a link or symlink or rename
system call and the paths that caused it.
</p>
<h3 id="LinkError.Error">func (*LinkError) <a href="http://localhost:6060/src/os/file.go?s=2946:2980#L74">Error</a></h3>
<pre>func (e *<a href="index.html#LinkError">LinkError</a>) Error() <a href="../builtin/index.html#string">string</a></pre>
<h2 id="PathError">type <a href="http://localhost:6060/src/os/error.go?s=602:665#L10">PathError</a></h2>
<pre>type PathError struct {
Op <a href="../builtin/index.html#string">string</a>
Path <a href="../builtin/index.html#string">string</a>
Err <a href="../builtin/index.html#error">error</a>
}</pre>
<p>
PathError records an error and the operation and file path that caused it.
</p>
<h3 id="PathError.Error">func (*PathError) <a href="http://localhost:6060/src/os/error.go?s=667:701#L16">Error</a></h3>
<pre>func (e *<a href="index.html#PathError">PathError</a>) Error() <a href="../builtin/index.html#string">string</a></pre>
<h2 id="ProcAttr">type <a href="http://localhost:6060/src/os/exec.go?s=863:1757#L26">ProcAttr</a></h2>
<pre>type ProcAttr struct {
<span class="comment">// If Dir is non-empty, the child changes into the directory before</span>
<span class="comment">// creating the process.</span>
Dir <a href="../builtin/index.html#string">string</a>
<span class="comment">// If Env is non-nil, it gives the environment variables for the</span>
<span class="comment">// new process in the form returned by Environ.</span>
<span class="comment">// If it is nil, the result of Environ will be used.</span>
Env []<a href="../builtin/index.html#string">string</a>
<span class="comment">// Files specifies the open files inherited by the new process. The</span>
<span class="comment">// first three entries correspond to standard input, standard output, and</span>
<span class="comment">// standard error. An implementation may support additional entries,</span>
<span class="comment">// depending on the underlying operating system. A nil entry corresponds</span>
<span class="comment">// to that file being closed when the process starts.</span>
Files []*<a href="index.html#File">File</a>
<span class="comment">// Operating system-specific process creation attributes.</span>
<span class="comment">// Note that setting this field means that your program</span>
<span class="comment">// may not execute properly or even compile on some</span>
<span class="comment">// operating systems.</span>
Sys *<a href="../syscall/index.html">syscall</a>.<a href="../syscall/index.html#SysProcAttr">SysProcAttr</a>
}</pre>
<p>
ProcAttr holds the attributes that will be applied to a new process
started by StartProcess.
</p>
<h2 id="Process">type <a href="http://localhost:6060/src/os/exec.go?s=296:468#L4">Process</a></h2>
<pre>type Process struct {
Pid <a href="../builtin/index.html#int">int</a>
<span class="comment">// contains filtered or unexported fields</span>
}</pre>
<p>
Process stores the information about a process created by StartProcess.
</p>
<h3 id="FindProcess">func <a href="http://localhost:6060/src/os/doc.go?s=492:535#L6">FindProcess</a></h3>
<pre>func FindProcess(pid <a href="../builtin/index.html#int">int</a>) (*<a href="index.html#Process">Process</a>, <a href="../builtin/index.html#error">error</a>)</pre>
<p>
FindProcess looks for a running process by its pid.
</p>
<p>
The Process it returns can be used to obtain information
about the underlying operating system process.
</p>
<p>
On Unix systems, FindProcess always succeeds and returns a Process
for the given pid, regardless of whether the process exists.
</p>
<h3 id="StartProcess">func <a href="http://localhost:6060/src/os/doc.go?s=844:923#L17">StartProcess</a></h3>
<pre>func StartProcess(name <a href="../builtin/index.html#string">string</a>, argv []<a href="../builtin/index.html#string">string</a>, attr *<a href="index.html#ProcAttr">ProcAttr</a>) (*<a href="index.html#Process">Process</a>, <a href="../builtin/index.html#error">error</a>)</pre>
<p>
StartProcess starts a new process with the program, arguments and attributes
specified by name, argv and attr.
</p>
<p>
StartProcess is a low-level interface. The os/exec package provides
higher-level interfaces.
</p>
<p>
If there is an error, it will be of type *PathError.
</p>
<h3 id="Process.Kill">func (*Process) <a href="http://localhost:6060/src/os/doc.go?s=1231:1261#L29">Kill</a></h3>
<pre>func (p *<a href="index.html#Process">Process</a>) Kill() <a href="../builtin/index.html#error">error</a></pre>
<p>
Kill causes the Process to exit immediately.
</p>
<h3 id="Process.Release">func (*Process) <a href="http://localhost:6060/src/os/doc.go?s=1124:1157#L24">Release</a></h3>
<pre>func (p *<a href="index.html#Process">Process</a>) Release() <a href="../builtin/index.html#error">error</a></pre>
<p>
Release releases any resources associated with the Process p,
rendering it unusable in the future.
Release only needs to be called if Wait is not.
</p>
<h3 id="Process.Signal">func (*Process) <a href="http://localhost:6060/src/os/doc.go?s=1739:1781#L44">Signal</a></h3>
<pre>func (p *<a href="index.html#Process">Process</a>) Signal(sig <a href="index.html#Signal">Signal</a>) <a href="../builtin/index.html#error">error</a></pre>
<p>
Signal sends a signal to the Process.
Sending Interrupt on Windows is not implemented.
</p>
<h3 id="Process.Wait">func (*Process) <a href="http://localhost:6060/src/os/doc.go?s=1576:1623#L38">Wait</a></h3>
<pre>func (p *<a href="index.html#Process">Process</a>) Wait() (*<a href="index.html#ProcessState">ProcessState</a>, <a href="../builtin/index.html#error">error</a>)</pre>
<p>
Wait waits for the Process to exit, and then returns a
ProcessState describing its status and an error, if any.
Wait releases any resources associated with the Process.
On most operating systems, the Process must be a child
of the current process or an error will be returned.
</p>
<h2 id="ProcessState">type <a href="http://localhost:6060/src/os/exec_posix.go?s=1457:1617#L47">ProcessState</a></h2>
<pre>type ProcessState struct {
<span class="comment">// contains filtered or unexported fields</span>
}</pre>
<p>
ProcessState stores information about a process, as reported by Wait.
</p>
<h3 id="ProcessState.Exited">func (*ProcessState) <a href="http://localhost:6060/src/os/doc.go?s=2171:2207#L59">Exited</a></h3>
<pre>func (p *<a href="index.html#ProcessState">ProcessState</a>) Exited() <a href="../builtin/index.html#bool">bool</a></pre>
<p>
Exited reports whether the program has exited.
</p>
<h3 id="ProcessState.Pid">func (*ProcessState) <a href="http://localhost:6060/src/os/exec_posix.go?s=1672:1704#L54">Pid</a></h3>
<pre>func (p *<a href="index.html#ProcessState">ProcessState</a>) Pid() <a href="../builtin/index.html#int">int</a></pre>
<p>
Pid returns the process id of the exited process.
</p>
<h3 id="ProcessState.String">func (*ProcessState) <a href="http://localhost:6060/src/os/exec_posix.go?s=2001:2039#L74">String</a></h3>
<pre>func (p *<a href="index.html#ProcessState">ProcessState</a>) String() <a href="../builtin/index.html#string">string</a></pre>
<h3 id="ProcessState.Success">func (*ProcessState) <a href="http://localhost:6060/src/os/doc.go?s=2331:2368#L65">Success</a></h3>
<pre>func (p *<a href="index.html#ProcessState">ProcessState</a>) Success() <a href="../builtin/index.html#bool">bool</a></pre>
<p>
Success reports whether the program exited successfully,
such as with exit status 0 on Unix.
</p>
<h3 id="ProcessState.Sys">func (*ProcessState) <a href="http://localhost:6060/src/os/doc.go?s=2576:2616#L72">Sys</a></h3>
<pre>func (p *<a href="index.html#ProcessState">ProcessState</a>) Sys() interface{}</pre>
<p>
Sys returns system-dependent exit information about
the process. Convert it to the appropriate underlying
type, such as syscall.WaitStatus on Unix, to access its contents.
</p>
<h3 id="ProcessState.SysUsage">func (*ProcessState) <a href="http://localhost:6060/src/os/doc.go?s=2938:2983#L81">SysUsage</a></h3>
<pre>func (p *<a href="index.html#ProcessState">ProcessState</a>) SysUsage() interface{}</pre>
<p>
SysUsage returns system-dependent resource usage information about
the exited process. Convert it to the appropriate underlying
type, such as *syscall.Rusage on Unix, to access its contents.
(On Unix, *syscall.Rusage matches struct rusage as defined in the
getrusage(2) manual page.)
</p>
<h3 id="ProcessState.SystemTime">func (*ProcessState) <a href="http://localhost:6060/src/os/doc.go?s=2043:2092#L54">SystemTime</a></h3>
<pre>func (p *<a href="index.html#ProcessState">ProcessState</a>) SystemTime() <a href="../time/index.html">time</a>.<a href="../time/index.html#Duration">Duration</a></pre>
<p>
SystemTime returns the system CPU time of the exited process and its children.
</p>
<h3 id="ProcessState.UserTime">func (*ProcessState) <a href="http://localhost:6060/src/os/doc.go?s=1887:1934#L49">UserTime</a></h3>
<pre>func (p *<a href="index.html#ProcessState">ProcessState</a>) UserTime() <a href="../time/index.html">time</a>.<a href="../time/index.html#Duration">Duration</a></pre>
<p>
UserTime returns the user CPU time of the exited process and its children.
</p>
<h2 id="Signal">type <a href="http://localhost:6060/src/os/exec.go?s=1913:2004#L51">Signal</a></h2>
<pre>type Signal interface {
String() <a href="../builtin/index.html#string">string</a>
Signal() <span class="comment">// to distinguish from other Stringers</span>
}</pre>
<p>
A Signal represents an operating system signal.
The usual underlying implementation is operating system-dependent:
on Unix it is syscall.Signal.
</p>
<pre>var (
<span id="Interrupt">Interrupt</span> <a href="index.html#Signal">Signal</a> = <a href="../syscall/index.html">syscall</a>.<a href="../syscall/index.html#SIGINT">SIGINT</a>
<span id="Kill">Kill</span> <a href="index.html#Signal">Signal</a> = <a href="../syscall/index.html">syscall</a>.<a href="../syscall/index.html#SIGKILL">SIGKILL</a>
)</pre>
<p>
The only signal values guaranteed to be present on all systems
are Interrupt (send the process an interrupt) and Kill (force
the process to exit).
</p>
<h2 id="SyscallError">type <a href="http://localhost:6060/src/os/error.go?s=819:878#L19">SyscallError</a></h2>
<pre>type SyscallError struct {
Syscall <a href="../builtin/index.html#string">string</a>
Err <a href="../builtin/index.html#error">error</a>
}</pre>
<p>
SyscallError records an error from a specific system call.
</p>
<h3 id="SyscallError.Error">func (*SyscallError) <a href="http://localhost:6060/src/os/error.go?s=880:917#L24">Error</a></h3>
<pre>func (e *<a href="index.html#SyscallError">SyscallError</a>) Error() <a href="../builtin/index.html#string">string</a></pre>
<h2 id="pkg-subdirectories">Subdirectories</h2>
<div class="pkg-dir">
<table>
<tr>
<th class="pkg-name">Name</th>
<th class="pkg-synopsis">Synopsis</th>
</tr>
<tr>
<td colspan="2"><a href="http://localhost:6060/pkg/">..</a></td>
</tr>
<tr>
<td class="pkg-name" style="padding-left: 0px;">
<a href="exec/index.html">exec</a>
</td>
<td class="pkg-synopsis">
Package exec runs external commands.
</td>
</tr>
<tr>
<td class="pkg-name" style="padding-left: 0px;">
<a href="signal/index.html">signal</a>
</td>
<td class="pkg-synopsis">
Package signal implements access to incoming signals.
</td>
</tr>
<tr>
<td class="pkg-name" style="padding-left: 0px;">
<a href="user/index.html">user</a>
</td>
<td class="pkg-synopsis">
Package user allows user account lookups by name or id.
</td>
</tr>
</table>
</div>
<div id="footer">
Build version go1.6.<br>
Except as <a href="https://developers.google.com/site-policies#restrictions">noted</a>,
the content of this page is licensed under the
Creative Commons Attribution 3.0 License,
and code is licensed under a <a href="http://localhost:6060/LICENSE">BSD license</a>.<br>
<a href="http://localhost:6060/doc/tos.html">Terms of Service</a> |
<a href="http://www.google.com/intl/en/policies/privacy/">Privacy Policy</a>
</div>
</div><!-- .container -->
</div><!-- #page -->
<!-- TODO(adonovan): load these from <head> using "defer" attribute? -->
<script type="text/javascript" src="../../lib/godoc/jquery.js"></script>
<script type="text/javascript" src="../../lib/godoc/jquery.treeview.js"></script>
<script type="text/javascript" src="../../lib/godoc/jquery.treeview.edit.js"></script>
<script type="text/javascript" src="../../lib/godoc/godocs.js"></script>
</body>
</html>