Video Coming Soon...

Created by Zed A. Shaw Updated 2025-10-23 14:49:14

35: date

This exercise is pending. Quick notes about this exercise:

The Code

View Source file go-coreutils/date/main.go Only

package main

import (
  "fmt"
  "time"
  "flag"
)

func main() {
  var result string
  var universal bool

  it_is := time.Now()

  flag.BoolVar(&universal, "u", false, "UTC time.")
  flag.Parse()

  if universal {
    it_is = it_is.UTC()
  }

  if flag.NArg() == 1 {
    result = it_is.Format(flag.Args()[0])
  } else {
    result = it_is.String()
  }

  fmt.Println(result)
}
Previous Lesson Next Lesson

Register for Learn Go the Hard Way

Register today for the course and get the all currently available videos and lessons, plus all future modules for no extra charge.