Join Miki Tebeka for an in-depth discussion in this video Solution: Files MD5 signature, part of Go Essential Training.
- [Instructor] Let's start with…a function to parse the signature file.…As a reminder, the signature files looks like this.…We have a line, and after the line,…there's a signature, and the name of the file.…Parse signatures file gets a path…which is a string and we return a map…from the string, which is the path…to the expected signature, and also an error…if an error happened.…At first, we try to open the file,…and if there is an error, we return the error,…and nil for the map itself.…
We use defer to make sure the file is closed,…and then we create the map and use a scanner…to go over the file.…We use a for loop, we say that the line number is one,…and as long as the scanner.Scan returns something true,…we increment the line number.…Use a strings.Fields to split the line into several fields,…and we get the line from scanner.Text.…If the length of the fields is not two,…there is something wrong in the file.…
So, we return nil, and an error saying…that this was a bad line.…It's important to add as much information…
- Go basic types, conditionals, and loops
- Go functions
- Object-oriented programming with Go
- Error handling
- Concurrent programming with channels
- Testing and project management
- Networking with JSON and HTTP
Skill Level Beginner
Programming Foundations: Fuzzy Logicwith Erin Colvin41m 50s Intermediate
Getting started1m 34s
1. Getting Started
2. Go Basics
5. Error Handling
7. Project Management
Next steps1m 12s
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.