Video Coming Soon...
35: date
This exercise is pending. Quick notes about this exercise:
- My implemention is at https://lcthw.dev/go/go-coreutils
- https://www.gnu.org/software/coreutils/manual/html_node/date-invocation.html
- time -- https://pkg.go.dev/time@go1.25.3
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)
}
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.