cd /news/developer-tools/go-pop-quiz-what-time-was-it · home topics developer-tools article
[ARTICLE · art-54914] src=dave.cheney.net ↗ pub= topic=developer-tools verified=true sentiment=· neutral

Go Pop quiz: what time was it?

A Go quiz asks readers to predict the output of a program that prints two timestamps separated by a 10-second sleep, testing understanding of deferred function evaluation in Go.

read1 min views1 publishedJul 10, 2026

Here’s a small quiz derived from some incorrect advice from an AI coding assistant.

package main

import (
    "fmt"
    "time"
)

func main() {
    fmt.Println(time.Now())
    defer fmt.Println(time.Now())
    time.Sleep(10 * time.Second)
}

This program prints two timestamps; will they be

a. Roughly the same time (ie, the same second)

b. Roughly 10 seconds apart

c. Something else

Answer after the fold

Pages: 1

── more in #developer-tools 4 stories · sorted by recency
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
Live at https://your-agent.zahid.host
Get free account → Pricing
from €0/mo · no card required
LIVE [news/go-pop-quiz-what-tim…] indexed:0 read:1min 2026-07-10 ·