Skip to content
This repository was archived by the owner on Sep 9, 2020. It is now read-only.
This repository was archived by the owner on Sep 9, 2020. It is now read-only.

Using dep status -f, template operations don't work #1540

Closed
@zkry

Description

@zkry

What version of dep are you using (dep version)?

❯ git describe --tags
v0.3.2-208-g3b8fbe48

Note: Running dep status normally:

❯ dep status
PROJECT                         CONSTRAINT                                 VERSION                                    REVISION  LATEST   PKGS USED
github.com/Masterminds/semver   branch parse-constraints-with-dash-in-pre  branch parse-constraints-with-dash-in-pre  a93e51b   a93e51b  1
github.com/Masterminds/vcs      ^1.11.0                                    v1.11.1                                    3084677   v1.12.0  1
github.com/armon/go-radix       branch master                              branch master                              4239b77   1fca145  1
github.com/boltdb/bolt          ^1.0.0                                     v1.3.1                                     2f1ce7a   v1.3.1   1
github.com/go-yaml/yaml         branch v2                                  branch v2                                  cd8b52f   d670f94  1
github.com/golang/protobuf      branch master                              branch master                              5afd06f   1e59b77  1
github.com/jmank88/nuts         ^0.3.0                                     v0.3.0                                     8b28145   v0.3.0   1
github.com/nightlyone/lockfile  branch master                              branch master                              e83dc5e   6a197d5  1
github.com/pelletier/go-toml    branch master                              branch master                              b8b5e76   9bf0212  1
github.com/pkg/errors           ^0.8.0                                     v0.8.0                                     645ef00   v0.8.0   1
github.com/sdboyer/constext     branch master                              branch master                              836a144   836a144  1
golang.org/x/net                branch master                              branch master                              66aacef   5ccada7  1
golang.org/x/sync               branch master                              branch master                              f52d181   fd80eb9  1
golang.org/x/sys                branch master                              branch master                              bb24a47   fff93fa  1

What dep command did you run?

First I run:

❯ dep status -f='{{.Constraint}} '
parse-constraints-with-dash-in-pre ^1.11.0 master ^1.0.0 v2 master ^0.3.0 master master ^0.8.0 master master master master

Then I want to do some logic with it:

dep status -f='{{if eq .Constraint "master"}}{{.ProjectRoot}}{{end}}'

template: status:1:5: executing "status" at <eq .Constraint "mast...>: error calling eq: invalid type for comparison

What did you expect to see?

The list of projects with constraint as master.

github.com/armon/go-radix github.com/golang/protobuf github.com/nightlyone/lockfile github.com/pelletier/go-toml github.com/sdboyer/constext golang.org/x/net golang.org/x/sync golang.org/x/sys

What did you see instead?

template: status:1:5: executing "status" at <eq .Constraint "mast...>: error calling eq: invalid type for comparison

Observations

It appears that the template fields Constraint, Version, and Latest suffer this problem becuase of their type declairation because of the type definition of BasicStatus. The fix would be to get convert these to a string before putting in the template. I can send the PR for this.

(Note: You can actually get this to work by running dep status -f='{{if eq .Constraint.String "master"}}{{.Version}}{{end}}'. This isn't that straight forward though.)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions