Introduction When a CPU needs to access a piece of data, the data needs to travel into the processor from main memory.
The architecture looks something like this:
Figure 1: CPU Cache
Figure 1 shows the different layers of memory a piece of data has to travel to be accessible by the processor. Each CPU has its own L1 and L2 cache, and the L3 cache is shared among all CPUs.
Continue readingApril 3, 2023Ardan Labs
From the Ardan Community
Introduction In episode 9, Miki discussed how a command flag can be decoded into a user defined type with the Value interface. As a recap, the Value interface consists of two methods: one for serializing the underlying concrete type and one for deserializing a string into an object. To put this interface to the test, Miki wrote a command that had a flag to specify a network address. While implementing the Set method of the Value interface, Miki demonstrated how to add validation for your program’s flags.
Continue reading March 27, 2023Ardan Labs
From the Ardan Community
Introduction In episode 8, Miki developed a Go HTTP client that had a method to check the health of a theoretical API. The method would construct the request URL and return an error based on the response code received from the server. Miki then created a type that would mock Go’s http.RoundTripper interface and replace his client’s transport with said type to test it. To improve the efficacy, Miki’s stub will simulate an erroneous response to see if his client’s Health method is working as intended.
Continue reading March 20, 2023Ardan Labs
From the Ardan Community
Introduction In episode 7, Miki discussed design considerations to keep in mind while creating interfaces in Go with the first idea he proposed being that an interface should represent what we need from a type, and not what is stored on the type. To add some clarity to this thought, Miki explained how the io.Reader and io.Writer interfaces each require one method to be implemented although the underlying concrete type may store more information.
Continue reading March 13, 2023Ardan Labs
From the Ardan Community
Introduction In episode 6, Miki built a logger package with the aim of making it as versatile as possible. To achieve this, he constructed his logger object with a function that would: accept the io.Writer interface as a parameter and perform type assertions to retrieve other interface types as needed. By building this, Miki demonstrated how polymorphism is achieved with Go by changing the type of a variable with type assertions.
Continue reading Introduction One of the exercises I give to students is to download a single big file over HTTP concurrently using several goroutines using HTTP Range requests. An extra part of the exercise is to validate the downloaded file from a known MD5 signature. This extra part turns out to be interesting, let’s have a look.
Getting Download Information Let’s make an HTTP HEAD request to get information about a file located in a public dataset stored on Google Cloud Storage (GCS).
Continue readingwith Cheikh Seck
Introduction This is the first in a series of posts that will explore the Rust programming language. I am going to take the same approach I did with Go and write little programs that explore the different features of the language. Before I begin that work, I thought it would be fun to write a program that does something fun.
In this post and my first ever Rust program, I’m going to use a Rust library called bracket-lib that provides a cross-platform terminal emulator.
Continue readingMarch 7, 2023Ardan Labs
From the Ardan Community
Introduction In episode 5, Miki wrote a function that counted the number of lines in a file with interfaces. The first thing his function did was to open a file with Go’s os.Open function. Miki chose this method because the variable returned by said function implements the io.Reader interface which is crucial for the next step. The remaining parts of this function consisted of a primitive type alias that satisfied the io.
Continue reading February 27, 2023Ardan Labs
From the Ardan Community
Introduction In episode 4, Miki defined an enumerated type that satisfied Go’s fmt.Stringer interface. By implementing the fmt.Stringer interface, Miki can specify how his enumerators were printed within a formatted string and in this case, he expected the values to be displayed as a predetermined text value. Miki also pointed out how using the value of the method’s receiver within the Stringer method can result in a recursive loop.
In this video, Miki will define an unusual function that returns the number of lines in a file with the io.
Continue reading February 21, 2023Ardan Labs
From the Ardan Community
Introduction In episode 3, Miki implemented a type that satisfied Go’s error interface. The odd thing about his type was it would be considered not-nil although no value was set for it. To get a better understanding of the situation, Miki gives a brief explanation of how Go determines if an error value is nil, and in this case, Miki specified the type of the variable returned to be a pointer of his custom error type which blindsided Go’s mechanism to determine a nil value.
Continue reading