]> Cypherpunks repositories - gostls13.git/commitdiff
time: example in doc for time.AppendFormat func
authorRadek Sohlich <sohlich@gmail.com>
Fri, 3 Nov 2017 19:36:12 +0000 (20:36 +0100)
committerIan Lance Taylor <iant@golang.org>
Mon, 6 Nov 2017 17:57:52 +0000 (17:57 +0000)
The simple example would contribute to better understanding
what function does.

Change-Id: I36a2952df8b0e1762ec0cd908a867c457f39366e
Reviewed-on: https://go-review.googlesource.com/75970
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

src/time/example_test.go

index 1507f3f17528ab88ca6f3f8d8aa144bd284758fa..bab129db3c95e75035808d5f2a5cf4b5e61a780a 100644 (file)
@@ -569,3 +569,14 @@ func ExampleTime_Sub() {
        // Output:
        // difference = 12h0m0s
 }
+
+func ExampleTime_AppendFormat() {
+       t := time.Date(2017, time.November, 4, 11, 0, 0, 0, time.UTC)
+       text := []byte("Time: ")
+
+       text = t.AppendFormat(text, time.Kitchen)
+       fmt.Println(string(text))
+
+       // Output:
+       // Time: 11:00AM
+}