This repository contains ready-to-use Vagrant environment for Go development.
Before starting, make sure you have the following installed on your machine:
- Vagrant (version 2.2.10 or higher)
- VMware Desktop
- macOS: VMware Fusion Pro 13
- Windows: VMware Workstation Pro 17
- Vagrant VMware Utility
- vagrant-vmware-desktop plugin
- Ruby Gem dotenv plugin
Download and install Vagrant from the official website.
Download and install VMware Workstation Pro 17 (for Linux/Windows) or VMware Fusion Pro 13 (for macOS) from the official VMware website.
Follow the installation instructions for the Vagrant VMware Utility appropriate for your operating system.
Install the plugin by running the following command:
vagrant plugin install vagrant-vmware-desktop
Install the Ruby Gem dotenv
to load environment variables from a .env
file:
vagrant plugin install dotenv
To start the virtual machine, run the following command in the directory containing the Vagrantfile:
vagrant up
Once the virtual machine is up and running, you can connect to it via SSH with the following command:
vagrant ssh
To stop the virtual machine, run:
vagrant halt
To destroy the virtual machine and free up resources, run:
vagrant destroy
This environment uses a .env
file to manage environment variables. The following variables can be configured in the .env
file:
GO_VERSION
: The version of Go to install (defaults to 1.20).VAGRANT_CONFIG_CPU
: The number of CPUs to allocate to the virtual machine (defaults to 1).VAGRANT_CONFIG_MEMORY
: The amount of memory (in MB) to allocate to the virtual machine (defaults to 1024).VAGRANT_CONFIG_SYNCED_FOLDERS_FILE
: The path to the JSON file containing the synced folder configuration (defaults to./volumes.json
).
Example .env
file:
GO_VERSION="1.20"
VAGRANT_CONFIG_CPU="2"
VAGRANT_CONFIG_MEMORY="2048"
VAGRANT_CONFIG_SYNCED_FOLDERS_FILE="./volumes.json"
This Vagrant environment uses a dynamic synced folder configuration. The synced folders are defined in a JSON file specified by the VAGRANT_CONFIG_SYNCED_FOLDERS_FILE
environment variable in the .env
file.
The JSON file should contain an array of objects, where each object represents a synced folder with the following properties:
host
: The path to the folder on the host machine.guest
: The path to the folder on the guest machine.type
: The type of synced folder (e.g., rsync, virtualbox).id
: An optional ID for the synced folder.
Example volumes.json
:
[
{
"host": "/path/on/host/1",
"guest": "/path/on/guest/1",
"type": "rsync",
"id": "folder1"
},
{
"host": "/path/on/host/2",
"guest": "/path/on/guest/2",
"type": "rsync",
"id": "folder2"
}
]
Notes:
- Replace
/path/on/host/1
,/path/on/guest/1
, etc. with your actual paths. - The
type
property can be set to rsync for faster syncing performance, especially for larger projects. - The
id
property is optional and can be used to identify the synced folder.
Contributions are welcome and encouraged! Here's how you can contribute to this project:
- Report issues: If you encounter any problems or have suggestions for improvements, please open an issue on the GitHub repository.
- Fork the repository: Feel free to fork the repository and make changes.
- Submit pull requests: If you have made improvements or bug fixes, please submit a pull request.