Changes in Go 1.20.

<p>I was asked to look into Golang 1.20 to present the changes, not expecting to find much after the huge release of Go 1.18.</p> <p>Aside from some exciting changes, I&rsquo;ve also learned about many features that I wasn&rsquo;t aware of before reading the release notes meticulously.</p> <p>In order to actually show that these changes provide value, I will present issues and show how the new features solve these issues.</p> <h2><strong>Issue 1:</strong>&nbsp;<strong>I want to format the date or time in a string form And it&rsquo;s a hassle and error-prone.</strong></h2> <p>I am going to write how to print out the current date:</p> <pre> now := time.Now() formatted := now.Format(&quot;2007-01-02&quot;) fmt.Println(formatted)</pre> <p>This will print out:</p> <pre> 21007-03-21</pre> <p>????????</p> <p>If you are sharp and read the code you can see I made a mistake.</p> <p>The format is incorrect and should be: &ldquo;2006&ndash;01&ndash;02&quot; instead of &ldquo;2007&ndash;01&ndash;02&rdquo;.</p> <p>Now, I never remember dates and always look it up and the cost of a mistake is huge.</p> <p><a href="https://betterprogramming.pub/changes-in-go-1-20-b0a82d4b6c44">Read More</a></p>
Tags: Coding Golang