OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [libgo/] [go/] [time/] [example_test.go] - Blame information for rev 858

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 747 jeremybenn
// Copyright 2011 The Go Authors.  All rights reserved.
2
// Use of this source code is governed by a BSD-style
3
// license that can be found in the LICENSE file.
4
 
5
package time_test
6
 
7
import (
8
        "fmt"
9
        "time"
10
)
11
 
12
func expensiveCall() {}
13
 
14
func ExampleDuration() {
15
        t0 := time.Now()
16
        expensiveCall()
17
        t1 := time.Now()
18
        fmt.Printf("The call took %v to run.\n", t1.Sub(t0))
19
}
20
 
21
var c chan int
22
 
23
func handle(int) {}
24
 
25
func ExampleAfter() {
26
        select {
27
        case m := <-c:
28
                handle(m)
29
        case <-time.After(5 * time.Minute):
30
                fmt.Println("timed out")
31
        }
32
}
33
 
34
func ExampleSleep() {
35
        time.Sleep(100 * time.Millisecond)
36
}
37
 
38
func statusUpdate() string { return "" }
39
 
40
func ExampleTick() {
41
        c := time.Tick(1 * time.Minute)
42
        for now := range c {
43
                fmt.Printf("%v %s\n", now, statusUpdate())
44
        }
45
}
46
 
47
func ExampleMonth() {
48
        _, month, day := time.Now().Date()
49
        if month == time.November && day == 10 {
50
                fmt.Println("Happy Go day!")
51
        }
52
}
53
 
54
// Go launched at Tue Nov 10 15:00:00 -0800 PST 2009
55
func ExampleDate() {
56
        t := time.Date(2009, time.November, 10, 23, 0, 0, 0, time.UTC)
57
        fmt.Printf("Go launched at %s\n", t.Local())
58
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.