Source file src/runtime/testdata/testfaketime/faketime.go

     1  // Copyright 2019 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  // Test faketime support. This is its own test program because we have
     6  // to build it with custom build tags and hence want to minimize
     7  // dependencies.
     8  
     9  package main
    10  
    11  import (
    12  	"os"
    13  	"time"
    14  )
    15  
    16  func main() {
    17  	println("line 1")
    18  	// Stream switch, increments time
    19  	os.Stdout.WriteString("line 2\n")
    20  	os.Stdout.WriteString("line 3\n")
    21  	// Stream switch, increments time
    22  	os.Stderr.WriteString("line 4\n")
    23  	// Time jump
    24  	time.Sleep(1 * time.Second)
    25  	os.Stdout.WriteString("line 5\n")
    26  	// Print the current time.
    27  	os.Stdout.WriteString(time.Now().UTC().Format(time.RFC3339))
    28  }
    29  

View as plain text