Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
go
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
go
Commits
468e692e
Commit
468e692e
authored
Jan 09, 2012
by
Andrew Gerrand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
doc: only trim newlines in tmpltohtml, gofmt progs
R=golang-dev, r, r CC=golang-dev
https://golang.org/cl/5530048
parent
c7e91724
Changes
13
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
43 additions
and
29 deletions
+43
-29
doc/articles/error_handling.html
doc/articles/error_handling.html
+5
-5
doc/go1.html
doc/go1.html
+9
-9
doc/go_tutorial.html
doc/go_tutorial.html
+9
-10
doc/progs/cat_rot13.go
doc/progs/cat_rot13.go
+2
-1
doc/progs/defer2.go
doc/progs/defer2.go
+2
-0
doc/progs/echo.go
doc/progs/echo.go
+1
-1
doc/progs/error.go
doc/progs/error.go
+5
-0
doc/progs/error2.go
doc/progs/error2.go
+1
-0
doc/progs/error3.go
doc/progs/error3.go
+3
-0
doc/progs/error4.go
doc/progs/error4.go
+3
-0
doc/progs/go1.go
doc/progs/go1.go
+1
-0
doc/progs/sortmain.go
doc/progs/sortmain.go
+1
-2
doc/tmpltohtml.go
doc/tmpltohtml.go
+1
-1
No files found.
doc/articles/error_handling.html
View file @
468e692e
...
@@ -20,7 +20,7 @@ occurs it calls <code>log.Fatal</code> to print the error message and stop.
...
@@ -20,7 +20,7 @@ occurs it calls <code>log.Fatal</code> to print the error message and stop.
</p>
</p>
<pre>
<!--{{code "progs/error.go" `/func openFile/` `/STOP/`}}
<pre>
<!--{{code "progs/error.go" `/func openFile/` `/STOP/`}}
-->
f, err := os.Open(
"
filename.ext
"
)
-->
f, err := os.Open(
"
filename.ext
"
)
if err != nil {
if err != nil {
log.Fatal(err)
log.Fatal(err)
}
}
...
@@ -100,7 +100,7 @@ A caller passing a negative argument to <code>Sqrt</code> receives a non-nil
...
@@ -100,7 +100,7 @@ A caller passing a negative argument to <code>Sqrt</code> receives a non-nil
</p>
</p>
<pre>
<!--{{code "progs/error.go" `/func printErr/` `/STOP/`}}
<pre>
<!--{{code "progs/error.go" `/func printErr/` `/STOP/`}}
-->
f, err := Sqrt(-1)
-->
f, err := Sqrt(-1)
if err != nil {
if err != nil {
fmt.Println(err)
fmt.Println(err)
}
</pre>
}
</pre>
...
@@ -125,7 +125,7 @@ rules and returns it as an <code>error</code> created by
...
@@ -125,7 +125,7 @@ rules and returns it as an <code>error</code> created by
</p>
</p>
<pre>
<!--{{code "progs/error.go" `/fmtError/` `/STOP/`}}
<pre>
<!--{{code "progs/error.go" `/fmtError/` `/STOP/`}}
-->
if f
<
0 {
-->
if f
<
0 {
return 0, fmt.Errorf(
"
math: square root of negative number %g
"
, f)
return 0, fmt.Errorf(
"
math: square root of negative number %g
"
, f)
}
</pre>
}
</pre>
...
@@ -177,7 +177,7 @@ messages:
...
@@ -177,7 +177,7 @@ messages:
</p>
</p>
<pre>
<!--{{code "progs/error.go" `/func decodeError/` `/STOP/`}}
<pre>
<!--{{code "progs/error.go" `/func decodeError/` `/STOP/`}}
-->
if err := dec.Decode(
&
val); err != nil {
-->
if err := dec.Decode(
&
val); err != nil {
if serr, ok := err.(*json.SyntaxError); ok {
if serr, ok := err.(*json.SyntaxError); ok {
line, col := findLine(f, serr.Offset)
line, col := findLine(f, serr.Offset)
return fmt.Errorf(
"
%s:%d:%d: %v
"
, f.Name(), line, col, err)
return fmt.Errorf(
"
%s:%d:%d: %v
"
, f.Name(), line, col, err)
...
@@ -216,7 +216,7 @@ up otherwise.
...
@@ -216,7 +216,7 @@ up otherwise.
</p>
</p>
<pre>
<!--{{code "progs/error.go" `/func netError/` `/STOP/`}}
<pre>
<!--{{code "progs/error.go" `/func netError/` `/STOP/`}}
-->
if nerr, ok := err.(net.Error); ok
&&
nerr.Temporary() {
-->
if nerr, ok := err.(net.Error); ok
&&
nerr.Temporary() {
time.Sleep(1e9)
time.Sleep(1e9)
continue
continue
}
}
...
...
doc/go1.html
View file @
468e692e
...
@@ -44,7 +44,7 @@ call.
...
@@ -44,7 +44,7 @@ call.
</p>
</p>
<pre>
<!--{{code "progs/go1.go" `/greeting := ..byte/` `/append.*hello/`}}
<pre>
<!--{{code "progs/go1.go" `/greeting := ..byte/` `/append.*hello/`}}
-->
greeting := []byte{}
-->
greeting := []byte{}
greeting = append(greeting, []byte(
"
hello
"
)...)
</pre>
greeting = append(greeting, []byte(
"
hello
"
)...)
</pre>
<p>
<p>
...
@@ -54,7 +54,7 @@ slice; the conversion is no longer necessary:
...
@@ -54,7 +54,7 @@ slice; the conversion is no longer necessary:
</p>
</p>
<pre>
<!--{{code "progs/go1.go" `/append.*world/`}}
<pre>
<!--{{code "progs/go1.go" `/append.*world/`}}
-->
greeting = append(greeting,
"
world
"
...)
</pre>
-->
greeting = append(greeting,
"
world
"
...)
</pre>
<p>
<p>
<em>
Updating
</em>
:
<em>
Updating
</em>
:
...
@@ -95,7 +95,7 @@ All four of the initializations in this example are legal; the last one was ille
...
@@ -95,7 +95,7 @@ All four of the initializations in this example are legal; the last one was ille
</p>
</p>
<pre>
<!--{{code "progs/go1.go" `/type Date struct/` `/STOP/`}}
<pre>
<!--{{code "progs/go1.go" `/type Date struct/` `/STOP/`}}
-->
type Date struct {
-->
type Date struct {
month string
month string
day int
day int
}
}
...
@@ -182,7 +182,7 @@ relatives now take and return a <code>rune</code>.
...
@@ -182,7 +182,7 @@ relatives now take and return a <code>rune</code>.
</p>
</p>
<pre>
<!--{{code "progs/go1.go" `/STARTRUNE/` `/ENDRUNE/`}}
<pre>
<!--{{code "progs/go1.go" `/STARTRUNE/` `/ENDRUNE/`}}
-->
delta :=
'
δ
'
// delta has type rune.
-->
delta :=
'
δ
'
// delta has type rune.
var DELTA rune
var DELTA rune
DELTA = unicode.ToUpper(delta)
DELTA = unicode.ToUpper(delta)
epsilon := unicode.ToLower(DELTA + 1)
epsilon := unicode.ToLower(DELTA + 1)
...
@@ -231,7 +231,7 @@ function, <code>delete</code>. The call
...
@@ -231,7 +231,7 @@ function, <code>delete</code>. The call
</p>
</p>
<pre>
<!--{{code "progs/go1.go" `/delete\(m, k\)/`}}
<pre>
<!--{{code "progs/go1.go" `/delete\(m, k\)/`}}
-->
delete(m, k)
</pre>
-->
delete(m, k)
</pre>
<p>
<p>
will delete the map entry retrieved by the expression
<code>
m[k]
</code>
.
will delete the map entry retrieved by the expression
<code>
m[k]
</code>
.
...
@@ -258,7 +258,7 @@ Code should not assume that the elements are visited in any particular order.
...
@@ -258,7 +258,7 @@ Code should not assume that the elements are visited in any particular order.
</p>
</p>
<pre>
<!--{{code "progs/go1.go" `/Sunday/` `/^ }/`}}
<pre>
<!--{{code "progs/go1.go" `/Sunday/` `/^ }/`}}
-->
m := map[string]int{
"
Sunday
"
: 0,
"
Monday
"
: 1}
-->
m := map[string]int{
"
Sunday
"
: 0,
"
Monday
"
: 1}
for name, value := range m {
for name, value := range m {
// This loop should not assume Sunday will be visited first.
// This loop should not assume Sunday will be visited first.
f(name, value)
f(name, value)
...
@@ -292,7 +292,7 @@ These examples illustrate the behavior.
...
@@ -292,7 +292,7 @@ These examples illustrate the behavior.
</p>
</p>
<pre>
<!--{{code "progs/go1.go" `/sa :=/` `/then sc.0. = 2/`}}
<pre>
<!--{{code "progs/go1.go" `/sa :=/` `/then sc.0. = 2/`}}
-->
sa := []int{1, 2, 3}
-->
sa := []int{1, 2, 3}
i := 0
i := 0
i, sa[i] = 1, 2 // sets i = 1, sa[0] = 2
i, sa[i] = 1, 2 // sets i = 1, sa[0] = 2
...
@@ -409,7 +409,7 @@ As a result, structs and arrays can now be used as map keys:
...
@@ -409,7 +409,7 @@ As a result, structs and arrays can now be used as map keys:
</p>
</p>
<pre>
<!--{{code "progs/go1.go" `/type Day struct/` `/Printf/`}}
<pre>
<!--{{code "progs/go1.go" `/type Day struct/` `/Printf/`}}
-->
type Day struct {
-->
type Day struct {
long string
long string
short string
short string
}
}
...
@@ -585,7 +585,7 @@ to turn a string into an error. It replaces the old <code>os.NewError</code>.
...
@@ -585,7 +585,7 @@ to turn a string into an error. It replaces the old <code>os.NewError</code>.
</p>
</p>
<pre>
<!--{{code "progs/go1.go" `/ErrSyntax/`}}
<pre>
<!--{{code "progs/go1.go" `/ErrSyntax/`}}
-->
var ErrSyntax = errors.New(
"
syntax error
"
)
</pre>
-->
var ErrSyntax = errors.New(
"
syntax error
"
)
</pre>
<p>
<p>
<em>
Updating
</em>
:
<em>
Updating
</em>
:
...
...
doc/go_tutorial.html
View file @
468e692e
...
@@ -119,8 +119,8 @@ Next up, here's a version of the Unix utility <code>echo(1)</code>:
...
@@ -119,8 +119,8 @@ Next up, here's a version of the Unix utility <code>echo(1)</code>:
-->
package main
-->
package main
import (
import (
"
os
"
"
flag
"
// command line option parser
"
flag
"
// command line option parser
"
os
"
)
)
var omitNewline = flag.Bool(
"
n
"
, false,
"
don
'
t print final newline
"
)
var omitNewline = flag.Bool(
"
n
"
, false,
"
don
'
t print final newline
"
)
...
@@ -209,7 +209,7 @@ The <code>:=</code> operator is used a lot in Go to represent an initializing de
...
@@ -209,7 +209,7 @@ The <code>:=</code> operator is used a lot in Go to represent an initializing de
There's one in the
<code>
for
</code>
clause on the next line:
There's one in the
<code>
for
</code>
clause on the next line:
<p>
<p>
<pre>
<!--{{code "progs/echo.go" `/for/`}}
<pre>
<!--{{code "progs/echo.go" `/for/`}}
-->
for i := 0; i
<
flag.NArg(); i++ {
</pre>
-->
for i := 0; i
<
flag.NArg(); i++ {
</pre>
<p>
<p>
The
<code>
flag
</code>
package has parsed the arguments and left the non-flag arguments
The
<code>
flag
</code>
package has parsed the arguments and left the non-flag arguments
in a list that can be iterated over in the obvious way.
in a list that can be iterated over in the obvious way.
...
@@ -258,7 +258,7 @@ of course you can change a string <i>variable</i> simply by
...
@@ -258,7 +258,7 @@ of course you can change a string <i>variable</i> simply by
reassigning it. This snippet from
<code>
strings.go
</code>
is legal code:
reassigning it. This snippet from
<code>
strings.go
</code>
is legal code:
<p>
<p>
<pre>
<!--{{code "progs/strings.go" `/hello/` `/ciao/`}}
<pre>
<!--{{code "progs/strings.go" `/hello/` `/ciao/`}}
-->
s :=
"
hello
"
-->
s :=
"
hello
"
if s[1] !=
'
e
'
{
if s[1] !=
'
e
'
{
os.Exit(1)
os.Exit(1)
}
}
...
@@ -811,8 +811,7 @@ func (r13 *rotate13) Read(b []byte) (ret int, err error) {
...
@@ -811,8 +811,7 @@ func (r13 *rotate13) Read(b []byte) (ret int, err error) {
func (r13 *rotate13) String() string {
func (r13 *rotate13) String() string {
return r13.source.String()
return r13.source.String()
}
}
</pre>
// end of rotate13 implementation
</pre>
<p>
<p>
(The
<code>
rot13
</code>
function called in
<code>
Read
</code>
is trivial and not worth reproducing here.)
(The
<code>
rot13
</code>
function called in
<code>
Read
</code>
is trivial and not worth reproducing here.)
<p>
<p>
...
@@ -990,7 +989,7 @@ can just say <code>%d</code>; <code>Printf</code> knows the size and signedness
...
@@ -990,7 +989,7 @@ can just say <code>%d</code>; <code>Printf</code> knows the size and signedness
integer and can do the right thing for you. The snippet
integer and can do the right thing for you. The snippet
<p>
<p>
<pre>
<!--{{code "progs/print.go" 10 11}}
<pre>
<!--{{code "progs/print.go" 10 11}}
-->
var u64 uint64 = 1
<<
64 - 1
-->
var u64 uint64 = 1
<<
64 - 1
fmt.Printf(
"
%d %d\n
"
, u64, int64(u64))
</pre>
fmt.Printf(
"
%d %d\n
"
, u64, int64(u64))
</pre>
<p>
<p>
prints
prints
...
@@ -1003,7 +1002,7 @@ In fact, if you're lazy the format <code>%v</code> will print, in a simple
...
@@ -1003,7 +1002,7 @@ In fact, if you're lazy the format <code>%v</code> will print, in a simple
appropriate style, any value, even an array or structure. The output of
appropriate style, any value, even an array or structure. The output of
<p>
<p>
<pre>
<!--{{code "progs/print.go" 14 20}}
<pre>
<!--{{code "progs/print.go" 14 20}}
-->
type T struct {
-->
type T struct {
a int
a int
b string
b string
}
}
...
@@ -1025,7 +1024,7 @@ and adds a newline. The output of each of these two lines is identical
...
@@ -1025,7 +1024,7 @@ and adds a newline. The output of each of these two lines is identical
to that of the
<code>
Printf
</code>
call above.
to that of the
<code>
Printf
</code>
call above.
<p>
<p>
<pre>
<!--{{code "progs/print.go" 21 22}}
<pre>
<!--{{code "progs/print.go" 21 22}}
-->
fmt.Print(u64,
"
"
, t,
"
"
, a,
"
\n
"
)
-->
fmt.Print(u64,
"
"
, t,
"
"
, a,
"
\n
"
)
fmt.Println(u64, t, a)
</pre>
fmt.Println(u64, t, a)
</pre>
<p>
<p>
If you have your own type you'd like
<code>
Printf
</code>
or
<code>
Print
</code>
to format,
If you have your own type you'd like
<code>
Printf
</code>
or
<code>
Print
</code>
to format,
...
@@ -1442,10 +1441,10 @@ All that's left is to strobe the <code>quit</code> channel
...
@@ -1442,10 +1441,10 @@ All that's left is to strobe the <code>quit</code> channel
at the end of main:
at the end of main:
<p>
<p>
<pre>
<!--{{code "progs/server1.go" `/adder,.quit/`}}
<pre>
<!--{{code "progs/server1.go" `/adder,.quit/`}}
-->
adder, quit := startServer(func(a, b int) int { return a + b })
</pre>
-->
adder, quit := startServer(func(a, b int) int { return a + b })
</pre>
...
...
<pre>
<!--{{code "progs/server1.go" `/quit....true/`}}
<pre>
<!--{{code "progs/server1.go" `/quit....true/`}}
-->
quit
<
- true
</pre>
-->
quit
<
- true
</pre>
<p>
<p>
There's a lot more to Go programming and concurrent programming in general but this
There's a lot more to Go programming and concurrent programming in general but this
quick tour should give you some of the basics.
quick tour should give you some of the basics.
doc/progs/cat_rot13.go
View file @
468e692e
...
@@ -47,7 +47,8 @@ func (r13 *rotate13) Read(b []byte) (ret int, err error) {
...
@@ -47,7 +47,8 @@ func (r13 *rotate13) Read(b []byte) (ret int, err error) {
func
(
r13
*
rotate13
)
String
()
string
{
func
(
r13
*
rotate13
)
String
()
string
{
return
r13
.
source
.
String
()
return
r13
.
source
.
String
()
}
}
// end of rotate13 implementation
// end of rotate13 implementation OMIT
func
cat
(
r
reader
)
{
func
cat
(
r
reader
)
{
const
NBUF
=
512
const
NBUF
=
512
...
...
doc/progs/defer2.go
View file @
468e692e
...
@@ -35,6 +35,7 @@ func g(i int) {
...
@@ -35,6 +35,7 @@ func g(i int) {
fmt
.
Println
(
"Printing in g"
,
i
)
fmt
.
Println
(
"Printing in g"
,
i
)
g
(
i
+
1
)
g
(
i
+
1
)
}
}
// STOP OMIT
// STOP OMIT
// Revised version.
// Revised version.
...
@@ -53,4 +54,5 @@ func CopyFile(dstName, srcName string) (written int64, err error) {
...
@@ -53,4 +54,5 @@ func CopyFile(dstName, srcName string) (written int64, err error) {
return
io
.
Copy
(
dst
,
src
)
return
io
.
Copy
(
dst
,
src
)
}
}
// STOP OMIT
// STOP OMIT
doc/progs/echo.go
View file @
468e692e
...
@@ -5,8 +5,8 @@
...
@@ -5,8 +5,8 @@
package
main
package
main
import
(
import
(
"os"
"flag"
// command line option parser
"flag"
// command line option parser
"os"
)
)
var
omitNewline
=
flag
.
Bool
(
"n"
,
false
,
"don't print final newline"
)
var
omitNewline
=
flag
.
Bool
(
"n"
,
false
,
"don't print final newline"
)
...
...
doc/progs/error.go
View file @
468e692e
...
@@ -38,12 +38,14 @@ type errorString struct {
...
@@ -38,12 +38,14 @@ type errorString struct {
func
(
e
*
errorString
)
Error
()
string
{
func
(
e
*
errorString
)
Error
()
string
{
return
e
.
s
return
e
.
s
}
}
// STOP OMIT
// STOP OMIT
// New returns an error that formats as the given text.
// New returns an error that formats as the given text.
func
New
(
text
string
)
error
{
func
New
(
text
string
)
error
{
return
&
errorString
{
text
}
return
&
errorString
{
text
}
}
}
// STOP OMIT
// STOP OMIT
func
Sqrt
(
f
float64
)
(
float64
,
error
)
{
func
Sqrt
(
f
float64
)
(
float64
,
error
)
{
...
@@ -53,6 +55,7 @@ func Sqrt(f float64) (float64, error) {
...
@@ -53,6 +55,7 @@ func Sqrt(f float64) (float64, error) {
// implementation
// implementation
return
0
,
nil
// OMIT
return
0
,
nil
// OMIT
}
}
// STOP OMIT
// STOP OMIT
func
printErr
()
(
int
,
error
)
{
// OMIT
func
printErr
()
(
int
,
error
)
{
// OMIT
...
@@ -74,6 +77,7 @@ type NegativeSqrtError float64
...
@@ -74,6 +77,7 @@ type NegativeSqrtError float64
func
(
f
NegativeSqrtError
)
Error
()
string
{
func
(
f
NegativeSqrtError
)
Error
()
string
{
return
fmt
.
Sprintf
(
"math: square root of negative number %g"
,
float64
(
f
))
return
fmt
.
Sprintf
(
"math: square root of negative number %g"
,
float64
(
f
))
}
}
// STOP OMIT
// STOP OMIT
type
SyntaxError
struct
{
type
SyntaxError
struct
{
...
@@ -82,6 +86,7 @@ type SyntaxError struct {
...
@@ -82,6 +86,7 @@ type SyntaxError struct {
}
}
func
(
e
*
SyntaxError
)
Error
()
string
{
return
e
.
msg
}
func
(
e
*
SyntaxError
)
Error
()
string
{
return
e
.
msg
}
// STOP OMIT
// STOP OMIT
func
decodeError
(
dec
*
json
.
Decoder
,
val
struct
{})
error
{
// OMIT
func
decodeError
(
dec
*
json
.
Decoder
,
val
struct
{})
error
{
// OMIT
...
...
doc/progs/error2.go
View file @
468e692e
...
@@ -27,6 +27,7 @@ func viewRecord(w http.ResponseWriter, r *http.Request) {
...
@@ -27,6 +27,7 @@ func viewRecord(w http.ResponseWriter, r *http.Request) {
http
.
Error
(
w
,
err
.
Error
(),
500
)
http
.
Error
(
w
,
err
.
Error
(),
500
)
}
}
}
}
// STOP OMIT
// STOP OMIT
type
ap
struct
{}
type
ap
struct
{}
...
...
doc/progs/error3.go
View file @
468e692e
...
@@ -14,6 +14,7 @@ import (
...
@@ -14,6 +14,7 @@ import (
func
init
()
{
func
init
()
{
http
.
Handle
(
"/view"
,
appHandler
(
viewRecord
))
http
.
Handle
(
"/view"
,
appHandler
(
viewRecord
))
}
}
// STOP OMIT
// STOP OMIT
func
viewRecord
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
error
{
func
viewRecord
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
error
{
...
@@ -25,6 +26,7 @@ func viewRecord(w http.ResponseWriter, r *http.Request) error {
...
@@ -25,6 +26,7 @@ func viewRecord(w http.ResponseWriter, r *http.Request) error {
}
}
return
viewTemplate
.
Execute
(
w
,
record
)
return
viewTemplate
.
Execute
(
w
,
record
)
}
}
// STOP OMIT
// STOP OMIT
type
appHandler
func
(
http
.
ResponseWriter
,
*
http
.
Request
)
error
type
appHandler
func
(
http
.
ResponseWriter
,
*
http
.
Request
)
error
...
@@ -34,6 +36,7 @@ func (fn appHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
...
@@ -34,6 +36,7 @@ func (fn appHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
http
.
Error
(
w
,
err
.
Error
(),
500
)
http
.
Error
(
w
,
err
.
Error
(),
500
)
}
}
}
}
// STOP OMIT
// STOP OMIT
type
ap
struct
{}
type
ap
struct
{}
...
...
doc/progs/error4.go
View file @
468e692e
...
@@ -16,6 +16,7 @@ type appError struct {
...
@@ -16,6 +16,7 @@ type appError struct {
Message
string
Message
string
Code
int
Code
int
}
}
// STOP OMIT
// STOP OMIT
type
appHandler
func
(
http
.
ResponseWriter
,
*
http
.
Request
)
*
appError
type
appHandler
func
(
http
.
ResponseWriter
,
*
http
.
Request
)
*
appError
...
@@ -27,6 +28,7 @@ func (fn appHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
...
@@ -27,6 +28,7 @@ func (fn appHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
http
.
Error
(
w
,
e
.
Message
,
e
.
Code
)
http
.
Error
(
w
,
e
.
Message
,
e
.
Code
)
}
}
}
}
// STOP OMIT
// STOP OMIT
func
viewRecord
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
*
appError
{
func
viewRecord
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
*
appError
{
...
@@ -41,6 +43,7 @@ func viewRecord(w http.ResponseWriter, r *http.Request) *appError {
...
@@ -41,6 +43,7 @@ func viewRecord(w http.ResponseWriter, r *http.Request) *appError {
}
}
return
nil
return
nil
}
}
// STOP OMIT
// STOP OMIT
func
init
()
{
func
init
()
{
...
...
doc/progs/go1.go
View file @
468e692e
...
@@ -147,6 +147,7 @@ type SyntaxError struct {
...
@@ -147,6 +147,7 @@ type SyntaxError struct {
func
(
se
*
SyntaxError
)
Error
()
string
{
func
(
se
*
SyntaxError
)
Error
()
string
{
return
fmt
.
Sprintf
(
"%s:%d: %s"
,
se
.
File
,
se
.
Line
,
se
.
Message
)
return
fmt
.
Sprintf
(
"%s:%d: %s"
,
se
.
File
,
se
.
Line
,
se
.
Message
)
}
}
// END ERROR EXAMPLE OMIT
// END ERROR EXAMPLE OMIT
func
errorExample
()
{
func
errorExample
()
{
...
...
doc/progs/sortmain.go
View file @
468e692e
...
@@ -5,8 +5,8 @@
...
@@ -5,8 +5,8 @@
package
main
package
main
import
(
import
(
"fmt"
"./sort"
"./sort"
"fmt"
)
)
func
ints
()
{
func
ints
()
{
...
@@ -61,7 +61,6 @@ func days() {
...
@@ -61,7 +61,6 @@ func days() {
fmt
.
Printf
(
"
\n
"
)
fmt
.
Printf
(
"
\n
"
)
}
}
func
main
()
{
func
main
()
{
ints
()
ints
()
strings
()
strings
()
...
...
doc/tmpltohtml.go
View file @
468e692e
...
@@ -114,7 +114,7 @@ func code(file string, arg ...interface{}) (string, error) {
...
@@ -114,7 +114,7 @@ func code(file string, arg ...interface{}) (string, error) {
return
""
,
fmt
.
Errorf
(
"incorrect code invocation: code %q %q"
,
file
,
arg
)
return
""
,
fmt
.
Errorf
(
"incorrect code invocation: code %q %q"
,
file
,
arg
)
}
}
// Trim spaces from output.
// Trim spaces from output.
text
=
strings
.
Trim
Space
(
text
)
text
=
strings
.
Trim
(
text
,
"
\n
"
)
// Replace tabs by spaces, which work better in HTML.
// Replace tabs by spaces, which work better in HTML.
text
=
strings
.
Replace
(
text
,
"
\t
"
,
" "
,
-
1
)
text
=
strings
.
Replace
(
text
,
"
\t
"
,
" "
,
-
1
)
// Escape the program text for HTML.
// Escape the program text for HTML.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment