Coming from a python/django world, it'd be great to have something like a requirements.txt equivalent for go/revel. How can I do this? I know I can just write a requirements.txt file and then do something like
cat requirements | xargs go get
But what if my requirements ALSO have requirements? The above command would attempt to "go get" them, and then they'd fail to build, since I don't have those requirements installed.
Is there something I'm missing?
Simply open a terminal and navigate to the folder you want your requirements file to be in. You can then activate a virtual environment using venv or conda. It will take every package you have installed on that environment.
Requirements files serve as a list of items to be installed by pip, when using pip install. Files that use this format are often called “pip requirements. txt files”, since requirements. txt is usually what these files are named (although, that is not a requirement).
With your chosen environment selected using the Python: Select Interpreter command, run the Terminal: Create New Terminal command (Ctrl+Shift+`)) to open a terminal with that environment activated. In the terminal, run pip freeze > requirements. txt to create the requirements. txt file in your project folder.
The command go get
does exactly what you need: It finds all dependencies and downloads and installs the missing ones. Focus on "all": go get
really traverses your dependency graph.
Have a look at the documentation:
https://golang.org/cmd/go/#hdr-Add_dependencies_to_current_module_and_install_them
The Go documentation is really clean, short and well written. I would recommend always to have a look at the documentation first before making assumptions which are based on experience with other tools or tool-chains.
They also provide useful blog posts, https://blog.golang.org/using-go-modules
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With