Skip to content

time: Nanosecond() on Windows return identical value in loop execution #28084

Closed
@we-zhang

Description

@we-zhang

What version of Go are you using (go version)?

1.9.4

Does this issue reproduce with the latest release?

yes

What operating system and processor architecture are you using (go env)?

Build Windows executable on Mac, and run the executable on Windows

What did you do?

func main() {

	t := os.Getenv("IN_TIMES")
	count, err := strconv.Atoi(t)
	if err != nil {
		count = 10
	}

	for i := 0; i < count; i++ {
		fmt.Printf("current time nano: %s \n", strconv.Itoa(time.Now().Nanosecond()))
	}
}

What did you expect to see?

Except to see different output nasosecond value

What did you see instead?

See identical output:

current time nano: 9116500
current time nano: 9116500
current time nano: 9116500
current time nano: 9116500
current time nano: 9116500
current time nano: 9116500
current time nano: 9116500
current time nano: 9116500
current time nano: 9116500
current time nano: 9116500

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions