mirror of
https://github.com/golang/go
synced 2024-11-21 21:14:47 -07:00
doc/progs: update for go 1
Fixes #3076. R=golang-dev, dsymonds, r CC=golang-dev https://golang.org/cl/5727056
This commit is contained in:
parent
2c0a46d604
commit
f5a1dd888d
@ -953,7 +953,7 @@ func sleepUntil(wakeup time.Time) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
delta := wakeup.Sub(now) // A Duration.
|
delta := wakeup.Sub(now) // A Duration.
|
||||||
log.Printf("Sleeping for %.3fs", delta.Seconds())
|
fmt.Printf("Sleeping for %.3fs\n", delta.Seconds())
|
||||||
time.Sleep(delta)
|
time.Sleep(delta)
|
||||||
}</pre>
|
}</pre>
|
||||||
|
|
||||||
|
@ -102,7 +102,10 @@ func decodeError(dec *json.Decoder, val struct{}) error { // OMIT
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func findLine(os.FileInfo, int64) (int, int)
|
func findLine(os.FileInfo, int64) (int, int) {
|
||||||
|
// place holder; no need to run
|
||||||
|
return 0, 0
|
||||||
|
}
|
||||||
|
|
||||||
func netError(err error) { // OMIT
|
func netError(err error) { // OMIT
|
||||||
for { // OMIT
|
for { // OMIT
|
||||||
|
@ -35,6 +35,11 @@ func main() {
|
|||||||
|
|
||||||
var timeout = flag.Duration("timeout", 30*time.Second, "how long to wait for completion")
|
var timeout = flag.Duration("timeout", 30*time.Second, "how long to wait for completion")
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
// canonicalize the logging
|
||||||
|
log.SetFlags(0)
|
||||||
|
}
|
||||||
|
|
||||||
func mapDelete() {
|
func mapDelete() {
|
||||||
m := map[string]int{"7": 7, "23": 23}
|
m := map[string]int{"7": 7, "23": 23}
|
||||||
k := "7"
|
k := "7"
|
||||||
@ -177,7 +182,7 @@ func sleepUntil(wakeup time.Time) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
delta := wakeup.Sub(now) // A Duration.
|
delta := wakeup.Sub(now) // A Duration.
|
||||||
log.Printf("Sleeping for %.3fs", delta.Seconds())
|
fmt.Printf("Sleeping for %.3fs\n", delta.Seconds())
|
||||||
time.Sleep(delta)
|
time.Sleep(delta)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,63 +5,49 @@
|
|||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
eval $(gomake --no-print-directory -f ../../src/Make.inc go-env)
|
|
||||||
|
|
||||||
if [ -z "$O" ]; then
|
|
||||||
echo 'missing $O - maybe no Make.$GOARCH?' 1>&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
rm -f *.$O
|
|
||||||
|
|
||||||
defer_panic_recover="
|
defer_panic_recover="
|
||||||
defer.go
|
defer
|
||||||
defer2.go
|
defer2
|
||||||
"
|
"
|
||||||
|
|
||||||
effective_go="
|
effective_go="
|
||||||
eff_bytesize.go
|
eff_bytesize
|
||||||
eff_qr.go
|
eff_qr
|
||||||
eff_sequence.go
|
eff_sequence
|
||||||
"
|
"
|
||||||
|
|
||||||
error_handling="
|
error_handling="
|
||||||
error.go
|
error
|
||||||
error2.go
|
error2
|
||||||
error3.go
|
error3
|
||||||
error4.go
|
error4
|
||||||
"
|
"
|
||||||
|
|
||||||
for i in \
|
all=$(echo $defer_panic_recover $effective_go $error_handling slices go1)
|
||||||
$defer_panic_recover \
|
|
||||||
$effective_go \
|
for i in $all; do
|
||||||
$error_handling \
|
go build $i.go
|
||||||
slices.go \
|
|
||||||
go1.go \
|
|
||||||
; do
|
|
||||||
$GC $i
|
|
||||||
done
|
done
|
||||||
|
|
||||||
# Write to temporary file to avoid mingw bash bug.
|
# Write to temporary file to avoid mingw bash bug.
|
||||||
TMPFILE="/tmp/gotest3.$USER"
|
TMPFILE="/tmp/gotest3.$USER"
|
||||||
|
|
||||||
function testit {
|
function testit {
|
||||||
$LD $1.$O
|
./$1 >"$TMPFILE" 2>&1 || true
|
||||||
./$O.out $2 2>&1 >"$TMPFILE" || true
|
|
||||||
x=$(echo $(cat "$TMPFILE")) # extra echo canonicalizes
|
x=$(echo $(cat "$TMPFILE")) # extra echo canonicalizes
|
||||||
if [ "$x" != "$3" ]
|
if ! echo "$x" | grep "$2" > /dev/null
|
||||||
then
|
then
|
||||||
echo $1 failed: '"'$x'"' is not '"'$3'"'
|
echo $1 failed: '"'$x'"' is not '"'$2'"'
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
testit defer "" "0 3210 2"
|
testit defer '^0 3210 2$'
|
||||||
testit defer2 "" "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."
|
testit defer2 '^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.$'
|
||||||
|
|
||||||
testit eff_bytesize "" "1.00YB 9.09TB"
|
testit eff_bytesize '^1.00YB 9.09TB$'
|
||||||
testit eff_sequence "" "[-1 2 6 16 44]"
|
testit eff_sequence '^\[-1 2 6 16 44\]$'
|
||||||
|
|
||||||
testit go1 "" "Christmas is a holiday: true"
|
testit go1 '^Christmas is a holiday: true Sleeping for 0.123s.*go1.go already exists$'
|
||||||
|
|
||||||
rm -f $O.out $O.out.exe *.$O "$TMPFILE"
|
rm -f $all "$TMPFILE"
|
||||||
|
@ -57,3 +57,7 @@ func CopyDigits(filename string) []byte {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// STOP OMIT
|
// STOP OMIT
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
// place holder; no need to run
|
||||||
|
}
|
||||||
|
@ -72,7 +72,6 @@ $BROKEN ||
|
|||||||
./test.bash
|
./test.bash
|
||||||
) || exit $?
|
) || exit $?
|
||||||
|
|
||||||
$BROKEN ||
|
|
||||||
(xcd ../doc/progs
|
(xcd ../doc/progs
|
||||||
time ./run
|
time ./run
|
||||||
) || exit $?
|
) || exit $?
|
||||||
|
Loading…
Reference in New Issue
Block a user