Maps
Write the test first
package main
import "testing"
func TestSearch(t *testing.T) {
dictionary := map[string]string{"test": "this is just a test"}
got := Search(dictionary, "test")
want := "this is just a test"
if got != want {
t.Errorf("got %q want %q given, %q", got, want, "test")
}
}Try to run the test
Write the minimal amount of code for the test to run and check the output
Write enough code to make it pass
Refactor
Using a custom type
Write the test first
Try and run the test
Write the minimal amount of code for the test to run and check the output
Write enough code to make it pass
Refactor
Write the test first
Write the minimal amount of code for the test to run and check output
Write enough code to make it pass
Reference Types
Refactor
Write the test first
Try to run test
Write the minimal amount of code for the test to run and check the output
Write enough code to make it pass
Refactor
Write the test first
Try and run the test
Write minimal amount of code for the test to run and check the failing test output
Write enough code to make it pass
Write the test first
Try and run the test
Write the minimal amount of code for the test to run and check the failing test output
Write enough code to make it pass
Note on declaring a new error for Update
Write the test first
Try to run the test
Write the minimal amount of code for the test to run and check the failing test output
Write enough code to make it pass
Wrapping up
Last updated