fmt

The FMT package implements formatted I/O similar to the C languages printf and scanf. It is mainly divided into two parts: output content and input content.

print

Print will Print the content to the system’s standard output. The difference is that Print will Print the content directly, Printf will format the output string, and Println will add a newline at the end of the output.

Fprint

The Fprint series of functions will print the content to a variable w of type IO.Writer interface. We usually use this function to write content to a file.

Sprint

The Sprint series of functions generates and returns a string from the incoming data.

Errorf

The Errorf function generates a formatted string from the format argument and returns an error containing the string.

Time

Time package

The time package provides functions for displaying and measuring time. The calendar is calculated using the Gregorian calendar. Time to type

Time. time indicates the time. We can use time.now () to get the current time object, and then get the time object’s year, month, day, hour, minute, second, etc. The time stamp

The timestamp is the total number of milliseconds since January 1, 1970 (08:00:00GMT) to the current time. It is also known as Unix timestamp. The time interval

Time. Duration is a type defined by the time package that represents the elapsed time between two points in time in nanoseconds. Duration indicates an interval of time. The longest period of time available is about 290 years. Add

In our daily coding process, we may encounter requirements for time + time interval. Sub

Find the difference between the two times. The timer

Use time.Tick to set a timer, which is essentially a channel. Time formatting

There is a built-in Format method for formatting time types. It should be noted that in Go language, the time template for formatting time is not the common Y-m-d H: m :S, but the birth time of Go is 15:04 on January 2, 2006 (2006 1 2 3 4). Maybe that’s the romance of the techie