diff options
Diffstat (limited to 'doc/progs')
49 files changed, 159 insertions, 5 deletions
diff --git a/doc/progs/cgo1.go b/doc/progs/cgo1.go index b79ee368a..1a2dc6c96 100644 --- a/doc/progs/cgo1.go +++ b/doc/progs/cgo1.go @@ -1,3 +1,5 @@ +// skip + // Copyright 2012 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. diff --git a/doc/progs/cgo2.go b/doc/progs/cgo2.go index f38473b13..9999af344 100644 --- a/doc/progs/cgo2.go +++ b/doc/progs/cgo2.go @@ -1,3 +1,5 @@ +// skip + // Copyright 2012 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. diff --git a/doc/progs/cgo3.go b/doc/progs/cgo3.go index 435fd0402..c4f4791e8 100644 --- a/doc/progs/cgo3.go +++ b/doc/progs/cgo3.go @@ -1,3 +1,5 @@ +// skip + // Copyright 2012 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. diff --git a/doc/progs/cgo4.go b/doc/progs/cgo4.go index 3808d6217..30b893572 100644 --- a/doc/progs/cgo4.go +++ b/doc/progs/cgo4.go @@ -1,3 +1,5 @@ +// skip + // Copyright 2012 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. diff --git a/doc/progs/defer.go b/doc/progs/defer.go index 2e11020ab..006a474b5 100644 --- a/doc/progs/defer.go +++ b/doc/progs/defer.go @@ -1,3 +1,5 @@ +// cmpout + // Copyright 2011 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. diff --git a/doc/progs/defer.out b/doc/progs/defer.out new file mode 100644 index 000000000..0cdf53a27 --- /dev/null +++ b/doc/progs/defer.out @@ -0,0 +1,3 @@ +0 +3210 +2 diff --git a/doc/progs/defer2.go b/doc/progs/defer2.go index cad66b070..ff7eaf9d8 100644 --- a/doc/progs/defer2.go +++ b/doc/progs/defer2.go @@ -1,3 +1,5 @@ +// cmpout + // Copyright 2011 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. diff --git a/doc/progs/defer2.out b/doc/progs/defer2.out new file mode 100644 index 000000000..6110685cd --- /dev/null +++ b/doc/progs/defer2.out @@ -0,0 +1,12 @@ +Calling g. +Printing in g 0 +Printing in g 1 +Printing in g 2 +Printing in g 3 +Panicking! +Defer in g 3 +Defer in g 2 +Defer in g 1 +Defer in g 0 +Recovered in f 4 +Returned normally from f. diff --git a/doc/progs/eff_bytesize.go b/doc/progs/eff_bytesize.go index b45961114..a0c3d5058 100644 --- a/doc/progs/eff_bytesize.go +++ b/doc/progs/eff_bytesize.go @@ -1,3 +1,5 @@ +// cmpout + // 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. diff --git a/doc/progs/eff_bytesize.out b/doc/progs/eff_bytesize.out new file mode 100644 index 000000000..df763f3b3 --- /dev/null +++ b/doc/progs/eff_bytesize.out @@ -0,0 +1 @@ +1.00YB 9.09TB diff --git a/doc/progs/eff_qr.go b/doc/progs/eff_qr.go index de96a0208..861131ddf 100644 --- a/doc/progs/eff_qr.go +++ b/doc/progs/eff_qr.go @@ -1,10 +1,16 @@ +// compile + +// 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. + package main import ( "flag" + "html/template" "log" "net/http" - "text/template" ) var addr = flag.String("addr", ":1718", "http service address") // Q=17, R=18 @@ -31,9 +37,9 @@ const templateStr = ` </head> <body> {{if .}} -<img src="http://chart.apis.google.com/chart?chs=300x300&cht=qr&choe=UTF-8&chl={{urlquery .}}" /> +<img src="http://chart.apis.google.com/chart?chs=300x300&cht=qr&choe=UTF-8&chl={{.}}" /> <br> -{{html .}} +{{.}} <br> <br> {{end}} diff --git a/doc/progs/eff_sequence.go b/doc/progs/eff_sequence.go index 11c885abf..c9b18ba93 100644 --- a/doc/progs/eff_sequence.go +++ b/doc/progs/eff_sequence.go @@ -1,3 +1,5 @@ +// cmpout + // 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. diff --git a/doc/progs/eff_sequence.out b/doc/progs/eff_sequence.out new file mode 100644 index 000000000..fd01a7d47 --- /dev/null +++ b/doc/progs/eff_sequence.out @@ -0,0 +1 @@ +[-1 2 6 16 44] diff --git a/doc/progs/error.go b/doc/progs/error.go index f85a5273a..57854c5fe 100644 --- a/doc/progs/error.go +++ b/doc/progs/error.go @@ -1,3 +1,5 @@ +// compile + // Copyright 2011 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. @@ -18,7 +20,11 @@ import ( type File struct{} -func Open(name string) (file *File, err error) +func Open(name string) (file *File, err error) { + // OMIT + panic(1) + // STOP OMIT +} func openFile() { // OMIT f, err := os.Open("filename.ext") diff --git a/doc/progs/error2.go b/doc/progs/error2.go index 2b0e0c356..aad1dc8e8 100644 --- a/doc/progs/error2.go +++ b/doc/progs/error2.go @@ -1,3 +1,5 @@ +// compile + // Copyright 2011 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. diff --git a/doc/progs/error3.go b/doc/progs/error3.go index e4e57e077..9f1b30072 100644 --- a/doc/progs/error3.go +++ b/doc/progs/error3.go @@ -1,3 +1,5 @@ +// compile + // Copyright 2011 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. diff --git a/doc/progs/error4.go b/doc/progs/error4.go index 8f35cf74b..d40fc6eb2 100644 --- a/doc/progs/error4.go +++ b/doc/progs/error4.go @@ -1,3 +1,5 @@ +// compile + // Copyright 2011 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. @@ -22,7 +24,7 @@ type appError struct { type appHandler func(http.ResponseWriter, *http.Request) *appError func (fn appHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { - if e := fn(w, r); e != nil { // e is *appError, not os.Error. + if e := fn(w, r); e != nil { // e is *appError, not error. c := appengine.NewContext(r) c.Errorf("%v", e.Error) http.Error(w, e.Message, e.Code) diff --git a/doc/progs/go1.go b/doc/progs/go1.go index 50fd93441..a4dc64d46 100644 --- a/doc/progs/go1.go +++ b/doc/progs/go1.go @@ -1,3 +1,6 @@ +// compile +// this file will output a list of filenames in cwd, not suitable for cmpout + // Copyright 2011 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. diff --git a/doc/progs/gobs1.go b/doc/progs/gobs1.go index 7077ca159..d95f765d8 100644 --- a/doc/progs/gobs1.go +++ b/doc/progs/gobs1.go @@ -1,3 +1,5 @@ +// compile + // Copyright 2011 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. diff --git a/doc/progs/gobs2.go b/doc/progs/gobs2.go index 85bb41cdc..acd18382f 100644 --- a/doc/progs/gobs2.go +++ b/doc/progs/gobs2.go @@ -1,3 +1,5 @@ +// compile + // Copyright 2011 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. diff --git a/doc/progs/image_draw.go b/doc/progs/image_draw.go index bb73c8a71..0a1f7acb1 100644 --- a/doc/progs/image_draw.go +++ b/doc/progs/image_draw.go @@ -1,3 +1,5 @@ +// compile + // Copyright 2012 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. diff --git a/doc/progs/image_package1.go b/doc/progs/image_package1.go index c4c401e72..d331834fc 100644 --- a/doc/progs/image_package1.go +++ b/doc/progs/image_package1.go @@ -1,3 +1,5 @@ +// cmpout + // Copyright 2012 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. diff --git a/doc/progs/image_package1.out b/doc/progs/image_package1.out new file mode 100644 index 000000000..809b31bf6 --- /dev/null +++ b/doc/progs/image_package1.out @@ -0,0 +1 @@ +X is 2 Y is 1 diff --git a/doc/progs/image_package2.go b/doc/progs/image_package2.go index fcb5d9fd0..e5b78b485 100644 --- a/doc/progs/image_package2.go +++ b/doc/progs/image_package2.go @@ -1,3 +1,5 @@ +// cmpout + // Copyright 2012 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. diff --git a/doc/progs/image_package2.out b/doc/progs/image_package2.out new file mode 100644 index 000000000..616d3078b --- /dev/null +++ b/doc/progs/image_package2.out @@ -0,0 +1 @@ +3 4 false diff --git a/doc/progs/image_package3.go b/doc/progs/image_package3.go index 13d0f0807..95d72a0b2 100644 --- a/doc/progs/image_package3.go +++ b/doc/progs/image_package3.go @@ -1,3 +1,5 @@ +// cmpout + // Copyright 2012 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. diff --git a/doc/progs/image_package3.out b/doc/progs/image_package3.out new file mode 100644 index 000000000..3fe35dea5 --- /dev/null +++ b/doc/progs/image_package3.out @@ -0,0 +1 @@ +3 4 true diff --git a/doc/progs/image_package4.go b/doc/progs/image_package4.go index c46fddf07..ec0e4613d 100644 --- a/doc/progs/image_package4.go +++ b/doc/progs/image_package4.go @@ -1,3 +1,5 @@ +// cmpout + // Copyright 2012 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. diff --git a/doc/progs/image_package4.out b/doc/progs/image_package4.out new file mode 100644 index 000000000..cb1b7776b --- /dev/null +++ b/doc/progs/image_package4.out @@ -0,0 +1 @@ +image.Point{X:2, Y:1} diff --git a/doc/progs/image_package5.go b/doc/progs/image_package5.go index 0bb5c7608..b9e27d6da 100644 --- a/doc/progs/image_package5.go +++ b/doc/progs/image_package5.go @@ -1,3 +1,5 @@ +// cmpout + // Copyright 2012 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. diff --git a/doc/progs/image_package5.out b/doc/progs/image_package5.out new file mode 100644 index 000000000..2da80c1fb --- /dev/null +++ b/doc/progs/image_package5.out @@ -0,0 +1 @@ +{255 0 0 255} diff --git a/doc/progs/image_package6.go b/doc/progs/image_package6.go index 62eeecdb9..5e6eefa04 100644 --- a/doc/progs/image_package6.go +++ b/doc/progs/image_package6.go @@ -1,3 +1,5 @@ +// cmpout + // Copyright 2012 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. diff --git a/doc/progs/image_package6.out b/doc/progs/image_package6.out new file mode 100644 index 000000000..fcd13c0c0 --- /dev/null +++ b/doc/progs/image_package6.out @@ -0,0 +1,2 @@ +8 4 +true diff --git a/doc/progs/interface.go b/doc/progs/interface.go index c2925d590..6972b7287 100644 --- a/doc/progs/interface.go +++ b/doc/progs/interface.go @@ -1,3 +1,5 @@ +// compile + // Copyright 2012 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. diff --git a/doc/progs/interface2.go b/doc/progs/interface2.go index a541d94e4..85e7d5163 100644 --- a/doc/progs/interface2.go +++ b/doc/progs/interface2.go @@ -1,3 +1,5 @@ +// cmpout + // Copyright 2012 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. diff --git a/doc/progs/interface2.out b/doc/progs/interface2.out new file mode 100644 index 000000000..085bd017a --- /dev/null +++ b/doc/progs/interface2.out @@ -0,0 +1 @@ +type: float64 diff --git a/doc/progs/json1.go b/doc/progs/json1.go index 9e10f4743..887d7d183 100644 --- a/doc/progs/json1.go +++ b/doc/progs/json1.go @@ -1,3 +1,5 @@ +// run + // Copyright 2012 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. diff --git a/doc/progs/json2.go b/doc/progs/json2.go index 6089ae671..f358feaa2 100644 --- a/doc/progs/json2.go +++ b/doc/progs/json2.go @@ -1,3 +1,5 @@ +// cmpout + // Copyright 2012 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. diff --git a/doc/progs/json2.out b/doc/progs/json2.out new file mode 100644 index 000000000..8f2dea57d --- /dev/null +++ b/doc/progs/json2.out @@ -0,0 +1,2 @@ +the circle's area 24.227111172875365 +the reciprocal of i is 0.3601008282319049 diff --git a/doc/progs/json3.go b/doc/progs/json3.go index a04fdfa50..41eb3730c 100644 --- a/doc/progs/json3.go +++ b/doc/progs/json3.go @@ -1,3 +1,5 @@ +// compile + // Copyright 2012 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. diff --git a/doc/progs/json4.go b/doc/progs/json4.go index 492630220..ee38f31ad 100644 --- a/doc/progs/json4.go +++ b/doc/progs/json4.go @@ -1,3 +1,5 @@ +// run + // Copyright 2012 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. diff --git a/doc/progs/json5.go b/doc/progs/json5.go index 6d7a4ca8c..9ab972df8 100644 --- a/doc/progs/json5.go +++ b/doc/progs/json5.go @@ -1,3 +1,5 @@ +// compile + // Copyright 2012 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. diff --git a/doc/progs/run b/doc/progs/run index 92c8da5cd..da777f329 100755 --- a/doc/progs/run +++ b/doc/progs/run @@ -40,6 +40,15 @@ c_go_cgo=" if [ "$goos" == "freebsd" ]; then c_go_cgo="cgo3 cgo4" fi +# cgo1 and cgo2 don't run on netbsd, srandom has a different signature +# cgo3 and cgo4 don't run on netbsd, since cgo cannot handle stdout correctly +if [ "$goos" == "netbsd" ]; then + c_go_cgo="" +fi +# cgo3 and cgo4 don't run on openbsd, since cgo cannot handle stdout correctly +if [ "$goos" == "openbsd" ]; then + c_go_cgo="cgo1 cgo2" +fi timeout=" timeout1 diff --git a/doc/progs/slices.go b/doc/progs/slices.go index 8e440103e..0461684b7 100644 --- a/doc/progs/slices.go +++ b/doc/progs/slices.go @@ -1,3 +1,5 @@ +// compile + // Copyright 2012 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. diff --git a/doc/progs/timeout1.go b/doc/progs/timeout1.go index 5221770ec..fbc39caac 100644 --- a/doc/progs/timeout1.go +++ b/doc/progs/timeout1.go @@ -1,3 +1,5 @@ +// compile + // Copyright 2012 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. diff --git a/doc/progs/timeout2.go b/doc/progs/timeout2.go index 7145bc93e..a12bc2ab1 100644 --- a/doc/progs/timeout2.go +++ b/doc/progs/timeout2.go @@ -1,3 +1,5 @@ +// compile + // Copyright 2012 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. diff --git a/doc/progs/unused1.go b/doc/progs/unused1.go new file mode 100644 index 000000000..96a6d98a3 --- /dev/null +++ b/doc/progs/unused1.go @@ -0,0 +1,12 @@ +// skip + +package main + +import ( + "fmt" + "io" +) + +func main() { + greeting := "hello, world" +} diff --git a/doc/progs/unused2.go b/doc/progs/unused2.go new file mode 100644 index 000000000..5c5f9d74f --- /dev/null +++ b/doc/progs/unused2.go @@ -0,0 +1,16 @@ +// compile + +package main + +import ( + "fmt" + "io" +) + +var _ = fmt.Printf +var _ io.Reader + +func main() { + greeting := "hello, world" + _ = greeting +} diff --git a/doc/progs/update.bash b/doc/progs/update.bash new file mode 100755 index 000000000..d4ecfbeba --- /dev/null +++ b/doc/progs/update.bash @@ -0,0 +1,15 @@ +#!/usr/bin/env bash +# Copyright 2012 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. + +set -e + +rm -f *.out *.rej *.orig [568].out + +for i in *.go; do + if grep -q '^// cmpout$' $i; then + echo $i + go run $i &> ${i/.go/.out} + fi +done |