August 2019
Beginner to intermediate
798 pages
17h 2m
English
In this section, you will learn how to change the format of a string that contains both a date and a time. A very common place for finding such strings is the log files of web servers such as Apache and Nginx. As we do not know how to read a text file line by line, the text will be hard coded in the program; however, this fact does not change the functionality of the program.
The Go code of timeDate.go will be presented in four parts. The first part is the expected preamble:
package main
import (
"fmt"
"regexp"
"time"
)
You need the regexp standard Go package for supporting regular expressions.
The second code portion of timeDate.go is the following:
func main() { logs := []string{"127.0.0.1 - - [16/Nov/2017:10:49:46 ...Read now
Unlock full access