Query your Google Drive with a Go command-line tool
Programming Snapshot – Google Drive Search Tool
To help him check his Google Drive files with three different pattern matchers, Mike builds a command-line tool in Go to maintain a meta cache.
My digital library of scanned paper books is stashed away as PDF files in an account on Google Drive. So far, Google has done an exemplary job of keeping my data available, but I just can't make friends with their search interface. In typical Google style, the browser shows you a search field that can be used to quickly browse the indexed full text of all the files in all the folders. However, getting a simple answer to the question of whether I already have a certain book in my archive is more difficult. To do this, I have to select the file names only and restrict the search to specific folders.
Fortunately, though, Google provides an intuitive API [1] to access user data in the Google Drive cloud. For quick checks, a command-line tool comes in handy. While we're at it, it's worth taking a trip into the world of pattern matchers, of which there are, as we all know, a wide variety. For example, the shell relies on a glob mechanism for matching, while programming languages typically rely on regular expressions (regexes). And sometimes, a simple string matcher like the grep
command is the most practical solution.
Parallel Regex Worlds
If you type ls *.jpg
on the command line, you expect the shell's match mechanism to find all files with a .jpg
extension. This pattern matching is fundamentally different from Perl Compatible Regular Expressions (PCRE) [2] used in programming languages. Funnily enough, they originated with the Perl scripting language many years ago, but all modern languages from Python to Java and C++ to Go support them as well.
[...]
Buy this article as PDF
(incl. VAT)