|
| 1 | +# Vagrant README |
| 2 | + |
| 3 | +<!-- vim-markdown-toc GFM --> |
| 4 | + |
| 5 | +* [Getting Started](#getting-started) |
| 6 | +* [Building Your Vagrant VM](#building-your-vagrant-vm) |
| 7 | +* [Logging in to Your VM](#logging-in-to-your-vm) |
| 8 | +* [Inspecting Your Database](#inspecting-your-database) |
| 9 | +* [Refactoring Your Code](#refactoring-your-code) |
| 10 | + * [Re-creating the database](#re-creating-the-database) |
| 11 | + |
| 12 | +<!-- vim-markdown-toc --> |
| 13 | + |
| 14 | +## Getting Started |
| 15 | + |
| 16 | +A `Vagrantfile` has been provided in order to make this code more convenient to |
| 17 | +run. To get started via `Vagrant`, you'll need: |
| 18 | + |
| 19 | +* A working `Vagrant` environment |
| 20 | +* A `git checkout` of this repository |
| 21 | +* A copy of `GeoLite2-Country.mmdb` in the root of this repository |
| 22 | + |
| 23 | +## Building Your Vagrant VM |
| 24 | + |
| 25 | +After you have checked out this repository and added a `GeoLite2-Country.mmdb` to |
| 26 | +the root directory of the repository, run this command from the root directory. |
| 27 | + |
| 28 | +```bash |
| 29 | +vagrant up |
| 30 | +``` |
| 31 | + |
| 32 | +## Logging in to Your VM |
| 33 | + |
| 34 | +This will build your Vagrant VM, build your `Go` code and also run the example |
| 35 | +code for you. To log in to your container, run this command:. |
| 36 | + |
| 37 | +```bash |
| 38 | +vagrant ssh |
| 39 | +cd /vagrant |
| 40 | +``` |
| 41 | + |
| 42 | +## Inspecting Your Database |
| 43 | + |
| 44 | +Once you have logged in, you can test out your freshly created database: |
| 45 | + |
| 46 | +```bash |
| 47 | +mmdbinspect -db GeoLite2-Country.mmdb \ |
| 48 | +-db GeoLite2-Country-with-Department-Data.mmdb \ |
| 49 | +56.0.0.1 56.1.0.0/24 56.2.0.54 56.3.0.1 | less |
| 50 | +``` |
| 51 | + |
| 52 | +## Refactoring Your Code |
| 53 | + |
| 54 | +You can now freely edit the code outside of the Vagrant VM and re-run it from |
| 55 | +inside the VM. |
| 56 | + |
| 57 | +### Re-creating the database |
| 58 | + |
| 59 | +After you have edited the files, log in to your VM using the instructions above |
| 60 | +and run the following code: |
| 61 | + |
| 62 | +```bash |
| 63 | +go build && ./mmdb-from-go-blogpost |
| 64 | +``` |
0 commit comments