<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Standard Library on Go Basics Training</title><link>/docs/standard-library/</link><description>Recent content in Standard Library on Go Basics Training</description><generator>Hugo -- gohugo.io</generator><language>en</language><atom:link href="/docs/standard-library/index.xml" rel="self" type="application/rss+xml"/><item><title>Input/Output</title><link>/docs/standard-library/io/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>/docs/standard-library/io/</guid><description>Basics 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 package main import ( &amp;#34;fmt&amp;#34; &amp;#34;log&amp;#34; &amp;#34;os&amp;#34; ) func main() { const filename = &amp;#34;/tmp/file.txt&amp;#34; err := os.WriteFile(filename, []byte(&amp;#34;Hello, file system\n&amp;#34;), 0644) if err != nil { log.Fatal(err) } content, err := os.ReadFile(filename) if err != nil { log.Fatal(err) } fmt.Printf(&amp;#34;%s&amp;#34;, content) } Output: Hello, file system Reader/Writer The above example of reading a file loads the whole file into memory.</description></item><item><title>JSON</title><link>/docs/standard-library/json/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>/docs/standard-library/json/</guid><description>Encoding Go allows us to encode structs to json by using json.Marshal .
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 package main import ( &amp;#34;encoding/json&amp;#34; &amp;#34;fmt&amp;#34; &amp;#34;os&amp;#34; ) type User struct { Name string FullName string Followers int } func main() { user := User{ Name: &amp;#34;Alice&amp;#34;, FullName: &amp;#34;Alice Nyffenegger&amp;#34;, Followers: 44, } output, err := json.</description></item><item><title>HTTP Client</title><link>/docs/standard-library/http-client/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>/docs/standard-library/http-client/</guid><description>The Go standard library offers a HTTP package which provides a server and a client. In the following sections we learn how we can use the HTTP client.
Quick start The following example shows how we can perform a GET request and print the body to the standard output.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 package main import ( &amp;#34;fmt&amp;#34; &amp;#34;io&amp;#34; &amp;#34;net/http&amp;#34; &amp;#34;os&amp;#34; ) func main() { resp, err := http.</description></item><item><title>HTTP Server</title><link>/docs/standard-library/http-server/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>/docs/standard-library/http-server/</guid><description>Quick start Go allows us to start a simple HTTP server with minimal code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 package main import ( &amp;#34;fmt&amp;#34; &amp;#34;net/http&amp;#34; &amp;#34;os&amp;#34; ) func helloHandler(w http.ResponseWriter, r *http.Request) { fmt.Fprintln(w, &amp;#34;Hello World&amp;#34;) } func main() { http.HandleFunc(&amp;#34;/hello&amp;#34;, helloHandler) err := http.ListenAndServe(&amp;#34;:8080&amp;#34;, nil) if err != nil { fmt.Println(err) os.Exit(1) } } Now you can access http://localhost:8080/hello .</description></item><item><title>Date and Time</title><link>/docs/standard-library/time/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>/docs/standard-library/time/</guid><description>Basics Time is represented with the time.Time struct.
The output in the examples below is generated by the Go playground . The Go playground uses a static time to achieve optimal caching performance.
1 2 3 4 5 6 7 8 9 10 11 package main import ( &amp;#34;fmt&amp;#34; &amp;#34;time&amp;#34; ) func main() { time := time.Now() fmt.Println(time) } Output: 2009-11-10 23:00:00 &amp;#43;0000 UTC m=&amp;#43;0.000000001 Parsing To parse a string to time.</description></item></channel></rss>