Updating the AddressBook
As we are going to work with the application we wrote in Chapter 7, let’s copy it over to the chapter9
directory:
$ cp -R ../chapter7/cmd/addressbook cmd $ cp -R ../chapter7/pkg/addressbook pkg $ cp ../chapter7/main.go . $ cp ../chapter7/proto/addressbook.proto proto
Now, because we were using a Go module name including chapter7
, we will need to replace all the occurrences by chapter9.
On Linux/Mac, we can run the following command:
$ find . -type f -exec sh -c "sed -i '' -e 's/chapter7/chapter9/g' {}" ";"
And on Windows (Powershell), we can run the following:
$ Get-ChildItem -Recurse -File -Include *.proto,*.go,go.mod | ForEach { (Get-Content $_ | ForEach { $_ -replace ‘chapter7’, ‘chapter9’ }) | Set-Content $_ }
We are now all set up to start.
The first step is to update our proto file to use our custom option. To do that, we will import our validate.proto...