Permalink
Browse files

os.Error is no longer

  • Loading branch information...
1 parent b4d7f06 commit d1597487e283d395e15c87bdbc1f875f6e07e8e5 @miekg committed Feb 10, 2012
Showing with 8 additions and 58 deletions.
  1. +4 −4 go-communication.tex
  2. +4 −4 go-functions.tex
  3. +0 −50 go-misc.tex
@@ -110,15 +110,15 @@ \section{Networking}
\begin{quote}
// \func{Read} reads data from the connection.\\
// \func{Read} can be made to time out and return a \var{net.Error} with \lstinline{Timeout() == true}\\
-// after a fixed time limit; see \func{SetTimeout} and \func{SetReadTimeout}.\\
-\lstinline{Read(b []byte) (n int, err os.Error)}
+// after a fixed time limit; see \func{SetDeadline} and \func{SetReadDeadline}.\\
+\lstinline{Read(b []byte) (n int, err error)}
\end{quote}
\begin{quote}
// \func{Write} writes data to the connection.\\
// \func{Write} can be made to time out and return a \var{net.Error} with \lstinline{Timeout() == true}\\
-// after a fixed time limit; see \func{SetTimeout} and \func{SetWriteTimeout}.\\
-\lstinline{Write(b []byte) (n int, err os.Error)}
+// after a fixed time limit; see \func{SetDeadline} and \func{SetWriteDeadline}.\\
+\lstinline{Write(b []byte) (n int, err error)}
\end{quote}
But these are the low level nooks and crannies\footnote{Exercise Q\ref{ex:echo} is about using
View
@@ -99,10 +99,10 @@ \section{Multiple return values}
device". The signature of \lstinline{*File.Write} in package
\package{os} is:
\begin{lstlisting}
-func (file *File) Write(b []byte) (n int, err Error)
+func (file *File) Write(b []byte) (n int, err error)
\end{lstlisting}
and as the documentation says, it returns the number of bytes written and a
-non-\lstinline{nil} \var{Error} when \lstinline{n != len(b)}. This is a common
+non-\lstinline{nil} \var{error} when \lstinline{n != len(b)}. This is a common
style in Go.
A similar approach obviates the need to pass a pointer to a return value to
@@ -153,10 +153,10 @@ \section{Named result parameters}
Because named results are initialized and tied to an unadorned
\key{return},
they can simplify as well as clarify. Here's a version of
-\lstinline{ioutil.ReadFull} that uses them well:
+\lstinline{io.ReadFull} that uses them well:
\begin{lstlisting}
-func ReadFull(r Reader, buf []byte) (n int, err os.Error) {
+func ReadFull(r Reader, buf []byte) (n int, err error) {
for len(buf) > 0 && err == nil {
var nr int
nr, err = r.Read(buf)
View
@@ -6,53 +6,3 @@ \section{Profiling}
\section{Gofix}
\label{sec:gofix}
-
-
-
-
-
-
-\section{Calling C from Go}
-\label{sec:cgo}
-%%
-%%Must use a package
-%%
-%%command cgo
-%%
-%%Cgo enables the creation of Go packages that call C code.
-%%
-%%Usage: cgo \[compiler options\] file.go
-%%
-%%The compiler options are passed through uninterpreted when invoking gcc to compile the C parts of the package.
-%%
-%%The input file.go is a syntactically valid Go source file that imports
-%%the pseudo-package "C" and then refers to types such as C.size\_t,
-%%variables such as C.stdout, or functions such as C.putchar.
-%%
-%%If the import of "C" is immediately preceded by a comment, that comment
-%%is used as a header when compiling the C parts of the package. For
-%%example:
-%%
-%%\begin{display}
-%%// #include <stdio.h>
-%%// #include <errno.h>
-%%\end{display}
-%%import "C"
-%%C identifiers or field names that are keywords in Go can be accessed by
-%%prefixing them with an underscore: if x points at a C struct with a
-%%field named "type", x.\_type accesses the field.
-%%
-%%To access a struct, union, or enum type directly, prefix it with
-%%struct\_, union\_, or enum\_, as in C.struct\_stat.
-%%
-%%Any C function that returns a value may be called in a multiple
-%%assignment context to retrieve both the return value and the C errno
-%%variable as an os.Error. For example:
-%%
-%%n, err := C.atoi("abc")
-%%Cgo transforms the input file into four output files: two Go source
-%%files, a C file for 6c (or 8c or 5c), and a C file for gcc.
-%%
-%%%The standard package makefile rules in Make.pkg automate the process of
-%%%using cgo. See $GOROOT/misc/cgo/stdio and $GOROOT/misc/cgo/gmp for
-%%%examples.

0 comments on commit d159748

Please sign in to comment.