On Tuesday, March 15, 2022 at 11:35:06 PM UTC-4 Ben wrote:

> We're making a log processing program that needs to parse times from the 
> prefix of a larger string, in this case in a log line such as:
>
> 2006-01-02 15:04:05 INFO this is a log message
>
> We need to parse the "2006-01-02 15:04:05" part as a timestamp. 
> Unfortunately, time.Parse always returns an error if there's extra text 
> after the timestamp.
>
> If the timestamp were in a fixed format (like the one above) we could just 
> hard-code it to grab the first two fields, or even the first N characters. 
> However, in our case the format of the timestamp is user-controlled, so 
> we're planning to let the user specify a custom time.Parse layout for their 
> logs.
>
> Ben
>
> Ben,
 
How does the user control the format of the timestamp? How do you get the 
time.Parse layout?

Peter
  

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/2b5f0902-99a6-4478-bb70-0d3a055c52c8n%40googlegroups.com.

Reply via email to