9. Basic Debugging
Activity 9.01: Building a Program to Validate Social Security Numbers
Solution:
All directories and files created should be within your $GOPATH
:
- Create a directory called
Activity9.01
inside theChapter09
directory. - Create a file called
main.go
inside theChapter09/Activity9.01/
directory. - Using Visual Studio Code, open the
main.go
file. - Add the following code to
main.go
.Here is the
main
function to build from:package main import ( Â Â Â Â "errors" Â Â Â Â "fmt" Â Â Â Â "log" Â Â Â Â "strconv" Â Â Â Â "strings" )
- Add the following custom error types. The custom errors that we will be using to log in to our program. These custom errors will be returned by their respective functions. They will appear in the log where applicable:
var ( Â Â Â Â ErrInvalidSSNLength = errors.New("ssn is not...