Skip to content

Generating code for go modules is much slower than under GOPATH #1826

@nickform

Description

@nickform

Problem statement

Generating server code for a Go module is much slower than doing so for the non-module equivalent.

Swagger specification

Reproducible with Petstore example.

Steps to reproduce

  1. In a directory outside of $GOPATH, download petstore example swagger as swagger.yaml.
  2. From that directory, run go mod init github.com/anything/whatever.
  3. Run swagger generate server -f .\swagger.yaml --name petstore.
    1. Note time difference between first and last log entry timestamps.
  4. Create a directory at $GOPATH/src/github.com/anything/whatever/petstore and copy the swagger.yaml (only) from step 1 there.
  5. From that directory, run swagger generate server -f .\swagger.yaml --name petstore.
    1. Note time difference between first and last log entry timestamp.

Difference for me

Step # Measurement
3.i 236 s
5.i 8 s

Not that the go.mod does not at any point in the above steps list any requirements - its presence is enough to cause the substantial slowdown.

Environment

swagger version: 0.17.2
go version: x.x.x go version go1.11 windows/amd64
OS: Windows 10

The slowdown has been observed to be even worse when running under docker.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions