-
Notifications
You must be signed in to change notification settings - Fork 18.8k
Description
Please answer these questions before submitting your issue. Thanks!
What version of Go are you using (go version)?
go version go1.10.3 linux/amd64
Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (go env)?
Ubuntu 18.04, amd64
What did you do?
Attempted to time.Parse the result of 'date --utc --rfc-3339=ns':
time.Parse(time.RFC3339Nano, "2018-06-18 10:19:31.800140702+00:00")package main
import (
"fmt"
"os/exec"
"strings"
"time"
)
func main() {
raw, err := exec.Command("date", "--utc", "--rfc-3339=ns").Output()
if err != nil {
panic(fmt.Sprintf("failed to run date: %v", err))
}
from_ubuntu := strings.TrimSpace(string(raw))
t, err := time.Parse(time.RFC3339Nano, from_ubuntu)
if err != nil {
fmt.Printf("Unparsable: %q\n", string(from_ubuntu))
} else {
fmt.Printf("Parsed: %v\n", t)
}
}What did you expect to see?
Parsing to succeed
What did you see instead?
Failure, due to an old disagreement about the RFC: http://lists.gnu.org/archive/html/bug-coreutils/2006-05/msg00019.html
GNU coreutils team maintain whitespace is allowed, but the Go library requires the 'T' separator between the date and time components of the string representation.
Options to allow interoperability between GNU style and Go style RFC-3339 complient strings would be to either relax the Go parsing, or provide alternative predefined styles in the time package (time.RFC3339GNU and time.RFC3339NanoGNU, or time.GNU3339 and time.GNU3339Nano, or similar)