Skip to content
This repository has been archived by the owner on Mar 22, 2021. It is now read-only.

Commit

Permalink
Fix conversions for rune type
Browse files Browse the repository at this point in the history
  • Loading branch information
miekg committed May 10, 2012
1 parent 43620b6 commit 1acf43c
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 12 deletions.
5 changes: 4 additions & 1 deletion ex-packages/ex-stack-package.tex
Expand Up @@ -25,16 +25,19 @@
\lstinputlisting[caption=Push/Pop test]{ex-packages/src/pushpop_test.go} \lstinputlisting[caption=Push/Pop test]{ex-packages/src/pushpop_test.go}


For \prog{go test} to work we need to put our package files in a directory For \prog{go test} to work we need to put our package files in a directory
under \var{\$GOPATH/src} (see page \pageref{"sec:settings used"}). under \var{\$GOPATH/src}:\\


\begin{display} \begin{display}
\pr \user{mkdir $GOPATH/src/stack} \pr \user{mkdir $GOPATH/src/stack}
\pr \user{cp pushpop_test.go $GOPATH/src/stack} \pr \user{cp pushpop_test.go $GOPATH/src/stack}
\pr \user{cp stack-as-package.go $GOPATH/src/stack} \pr \user{cp stack-as-package.go $GOPATH/src/stack}
\end{display} \end{display}
Yields:\\
\begin{display} \begin{display}
\pr \user{go test stack} \pr \user{go test stack}
ok stack 0.001s ok stack 0.001s
\end{display} \end{display}
\end{Answer} \end{Answer}
2 changes: 1 addition & 1 deletion go-basics.tex
Expand Up @@ -88,7 +88,7 @@ \section{Compiling and running code}
\ \newline \ \newline


\section{Settings used in this book} \section{Settings used in this book}
\label{sec:settings used} \label{sec:settings_used}
\begin{itemize} \begin{itemize}
\item Go itself is installed in \file{\~{}/go} ; \item Go itself is installed in \file{\~{}/go} ;
\item Go source code we want to compile ourself is placed in \file{\~{}/g/src} and \item Go source code we want to compile ourself is placed in \file{\~{}/g/src} and
Expand Down
4 changes: 2 additions & 2 deletions go-beyond.tex
Expand Up @@ -354,7 +354,7 @@ \section{Conversions}


\begin{itemize} \begin{itemize}
\item{ \item{
From a \lstinline{string} to a slice of bytes or rune. From a \lstinline{string} to a slice of bytes or runes.
\begin{lstlisting} \begin{lstlisting}
mystring := "hello this is string" mystring := "hello this is string"
\end{lstlisting} \end{lstlisting}
Expand All @@ -367,7 +367,7 @@ \section{Conversions}
are encoded in UTF-8 some characters in the string may end up in 1, 2, 3 are encoded in UTF-8 some characters in the string may end up in 1, 2, 3
or 4 bytes. or 4 bytes.
\begin{lstlisting} \begin{lstlisting}
intslice := []rune(mystring) runeslice := []rune(mystring)
\end{lstlisting} \end{lstlisting}
Converts to an \type{rune} slice, each \type{rune} contains a Unicode code Converts to an \type{rune} slice, each \type{rune} contains a Unicode code
point. Every character from the string corresponds to one rune. point. Every character from the string corresponds to one rune.
Expand Down
17 changes: 9 additions & 8 deletions tab/conversion.tex
@@ -1,10 +1,11 @@
\begin{tabular}{lllllll} \begin{tabular}{llllllll}
\textbf{From} & \verb|xb []byte|& \verb|xi []int|& \verb|s string| & \verb|f float32| & \verb|i int| \\ \cmidrule(r){1-6} \textbf{From} & \verb|xb []byte|& \verb|xi []int| & \verb|xr []rune| & \verb|s string| & \verb|f float32| & \verb|i int| \\ \cmidrule(r){1-7}
\textbf{To} & & & & & \\ \cmidrule(r){1-1} \textbf{To} & & & & & & \\ \cmidrule(r){1-1}
\verb|[]byte| & $\texttimes$ & & \verb|[]byte(s)| & & \\ \verb|[]byte| & $\texttimes$ & & & \verb|[]byte(s)| & & \\
\verb|[]int| & & $\texttimes$ & \verb|[]int(s)| & & \\ \verb|[]int| & & $\texttimes$ & & \verb|[]int(s)| & & \\
\verb|string| &\verb|string(xb)| &\verb|string(xi)|& $\texttimes$ & & \\ \verb|[]rune| & & & $\texttimes$ & \verb|[]rune(s)| & & \\
\verb|float32| & & & & $\texttimes$ & \verb|float32(i)|\\ \verb|string| &\verb|string(xb)| &\verb|string(xi)| & \verb|string(xr)| & $\texttimes$ & & \\
\verb|int| & & & & \verb|int(f)| & $\texttimes$ \\ \verb|float32| & & & & & $\texttimes$ & \verb|float32(i)|\\
\verb|int| & & & & & \verb|int(f)| & $\texttimes$ \\
%%\bottomrule %%\bottomrule
\end{tabular} \end{tabular}

0 comments on commit 1acf43c

Please sign in to comment.