Golang is a powerful and enticing language, but it may sometimes confuse first timers.
Before engaging further with
go-swagger, please take a while to get comfortable with golang basics
and conventions. That will save yourself much time and frustration.
- version: we support the two latest versions of the go compiler
GOPATHenvironment variable set: all sources reside under
- it is recommended, but not mandatory, to use the
deptool to manage dependencies (see here)
The target directory for your generated code must be under GOPATH/src.
Before generating code, you should make sure your target is going to properly resolve dependencies.
NOTE: generation makes use of the
goimportstool and dependencies must be matched at code generation time.
If your target is located under the
go-swagger install directory (when installed from source), dependencies are directly
provided by the
vendor directory that ships with
The following required dependencies may be fetched by using
You may also build a vendor directory in your planned target: a way to achieve that is to copy there an example from the
go-swagger/examples repository then run
dep - see how to use dep here.
This will produce
Gopkg.lock files and construct a vendor directory with all required dependencies
(the ones above and all transitive dependencies). Another way is to proceed in two steps, first with
go get, then generate code,
then build the vendor tree with
NOTE : the code generation process ends with a message indicating the packages required for your generated code.
Additional packages required by the (default) generated server:
And depending on your generation options, a command line flags handling package:
Same as above, plus:
The generated models package depends only on:
The code that is scanned for spec generation must resolve all its dependencies (i.e. must build).