time.Time.AppendFormat() Function in Golang With Examples
In Go language, time packages supplies functionality for determining as well as viewing time. The Time.AppendFormat() function in Go language is like Format() method but this method also appends the stated textual representation to the stated “b”. Moreover, this function is defined under the time package. Here, you need to import the “time” package in order to use these functions.
func (t Time) AppendFormat(b byte, layout string) byte
Here, “t” is the stated time, “b” is the byte of slice and layout holds a string type.
Return value: It appends the textual representation to the “b” and then returns the buffer that is extended.
[84 104 101 32 116 105 109 101 32 105 115 58 32 48 51 58 48 48 65 77]
Here, textual representation of time is appended to the “b” then its returned as a buffer.
The time is: 3:00AM
Here, a predefined layout is used that is, time.Kitchen which is used in Time.Format. And in the above output a string is returned instead of buffer as string() method is used here to convert a buffer into the string.