github.com/kaisawind/go-swagger@v0.19.0/docs/generate/requirements.md (about)

     1  # Requirements to build generated code
     2  
     3  ### First time with golang?
     4  
     5  Golang is a powerful and enticing language, but it may sometimes confuse first timers.
     6  
     7  Before engaging further with `go-swagger`, please take a while to get comfortable with golang basics 
     8  and conventions. That will save yourself much time and frustration.
     9  
    10  ### Standard golang environment
    11  
    12  * version: we support the two latest versions of the go compiler
    13  * `GOPATH` environment variable set: all sources reside under `$GOPATH/src`
    14  * it is recommended, but not mandatory, to use the `dep` tool to manage dependencies
    15  (see [here](https://golang.github.io/dep/docs/introduction.html))
    16  
    17  The target directory for your generated code _must_ be under GOPATH/src.
    18  
    19  ## Getting dependencies
    20  
    21  Before generating code, you should make sure your target is going to properly resolve dependencies.
    22  
    23  > **NOTE**: generation makes use of the `goimports` tool and dependencies must be matched at code generation time.
    24  
    25  If your target is located under the `go-swagger` install directory (when installed from source), dependencies are directly
    26  provided by the `vendor` directory that ships with `go-swagger`.
    27  
    28  The following required dependencies may be fetched by using `go get`:
    29  
    30  - [`github.com/go-openapi/errors`](https://www.github.com/go-openapi/errors)
    31  - [`github.com/go-openapi/loads`](https://www.github.com/go-openapi/loads)
    32  - [`github.com/go-openapi/runtime`](https://www.github.com/go-openapi/runtime)
    33  - [`github.com/go-openapi/spec`](https://www.github.com/go-openapi/spec)
    34  - [`github.com/go-openapi/strfmt`](https://www.github.com/go-openapi/strfmt)
    35  - [`github.com/go-openapi/swag`](https://www.github.com/go-openapi/swag)
    36  - [`github.com/go-openapi/validate`](https://www.github.com/go-openapi/validate)
    37  
    38  You may also build a vendor directory in your planned target: a way to achieve that is to copy there an example from the
    39  `go-swagger/examples` repository then run `dep` - see [how to use dep here](https://github.com/golang/dep).
    40  This will produce `Gopkg.toml` and `Gopkg.lock` files and construct a vendor directory with all required dependencies
    41  (the ones above and all transitive dependencies). Another way is to proceed in two steps, first with `go get`, then generate code, 
    42  then build the vendor tree with `dep`.
    43  
    44  > **NOTE** : the code generation process ends with a message indicating the packages required for your generated code.
    45  
    46  
    47  ### What are the dependencies required by the generated server?
    48  
    49  Additional packages required by the (default) generated server
    50  depend on your generation options, a command line flags handling package:
    51  
    52  - [`github.com/jessevdk/go-flags`](https://www.github.com/jessevdk/go-flags), or
    53  - [`github.com/spf13/pflags`](https://www.github.com/spf13/pflags)
    54  
    55  ### What are the dependencies required by the generated client?
    56  
    57  Same as above, plus:
    58  
    59  - `golang.org/x/net/context`
    60  
    61  ### What are the dependencies required by the generated models?
    62  
    63  The generated models package depends only on:
    64  
    65  - [`github.com/go-openapi/errors`](https://www.github.com/go-openapi/errors)
    66  - [`github.com/go-openapi/strfmt`](https://www.github.com/go-openapi/strfmt)
    67  - [`github.com/go-openapi/swag`](https://www.github.com/go-openapi/swag)
    68  - [`github.com/go-openapi/validate`](https://www.github.com/go-openapi/validate)
    69  
    70  ### How about generating specs?
    71  
    72  The code that is scanned for spec generation _must_ resolve all its dependencies (i.e. must build).