mirror of
https://github.com/gopl-zh/gopl-zh.github.com.git
synced 2024-11-28 17:19:06 +00:00
25 lines
641 B
Go
25 lines
641 B
Go
|
// Copyright © 2016 Alan A. A. Donovan & Brian W. Kernighan.
|
||
|
// License: https://creativecommons.org/licenses/by-nc-sa/4.0/
|
||
|
|
||
|
package format_test
|
||
|
|
||
|
import (
|
||
|
"fmt"
|
||
|
"testing"
|
||
|
"time"
|
||
|
|
||
|
"gopl.io/ch12/format"
|
||
|
)
|
||
|
|
||
|
func Test(t *testing.T) {
|
||
|
// The pointer values are just examples, and may vary from run to run.
|
||
|
//!+time
|
||
|
var x int64 = 1
|
||
|
var d time.Duration = 1 * time.Nanosecond
|
||
|
fmt.Println(format.Any(x)) // "1"
|
||
|
fmt.Println(format.Any(d)) // "1"
|
||
|
fmt.Println(format.Any([]int64{x})) // "[]int64 0x8202b87b0"
|
||
|
fmt.Println(format.Any([]time.Duration{d})) // "[]time.Duration 0x8202b87e0"
|
||
|
//!-time
|
||
|
}
|