Coder Social home page Coder Social logo

Comments (10)

iskunk avatar iskunk commented on June 10, 2024 1

Looks good! This is a definite improvement, and will help others as it would have helped me.

(One typo I noticed: "...and it's statistics.")

from goda.

egonelbre avatar egonelbre commented on June 10, 2024

You can now use .Module.Version to get the package version information.

As an example:

goda list -f "{{ printf \"%v %v\" .ID .Module.Version }}" ./...:all
goda list -f "{{.ID}}{{with .Module.Version}}@{{.}}{{end}}" ./...:all

from goda.

iskunk avatar iskunk commented on June 10, 2024

Many thanks!

I've confirmed that the second formatting example you gave is needed when a module version isn't always available (notably for the main project).

I do notice one oddity: I've been using just all for the package expression, which seems to work. When I use ./...:all, I get this:

$ goda graph -type edges -f '{{.ID}}{{with .Module.Version}}@{{.}}{{end}}' ./...:all >goda.out
template error: template: :1:21: executing "" at <.Module.Version>: nil pointer evaluating *packages.Module.Version
template error: template: :1:21: executing "" at <.Module.Version>: nil pointer evaluating *packages.Module.Version
template error: template: :1:21: executing "" at <.Module.Version>: nil pointer evaluating *packages.Module.Version
...

(The output that does get written out is slightly different from all, however, which makes me suspect I'm missing some subtlety in the package selection...)

from goda.

egonelbre avatar egonelbre commented on June 10, 2024

You may need to add additional: goda graph -type edges -f '{{.ID}}{{if .Module}}{{with .Module.Version}}@{{.}}{{end}}{{end}}' ./...:all.

I haven't yet encountered this myself, but I guess it's possible that in some cases .Module is nil.

from goda.

iskunk avatar iskunk commented on June 10, 2024

Ah, I see what you mean. I've confirmed that invocation works cleanly on the same project, a relatively large and complex one.

I hope there can be better documentation on the formatting syntax eventually, but for now, this example of it should do the trick for me. Thank you again!

from goda.

egonelbre avatar egonelbre commented on June 10, 2024

It uses https://pkg.go.dev/text/template for formatting. You can use goda list -f '{{ printf "%#v\n" . }}' ., To see what is available. Each package usually gets https://github.com/loov/goda/blob/master/internal/pkggraph/graph.go#L22 as package. Depending on the subcommand it may have some additional / fewer things.

from goda.

iskunk avatar iskunk commented on June 10, 2024

That's very good information. I don't know if the template syntax is recognizable to seasoned gophers, but as I come from outside the community, the absence of any references in the README.md or help output left me unenlightened.

I would suggest adding this, and perhaps a table listing some of the available attributes. The availability of .Module.Version isn't obvious from the location you linked above, for example---just from the brevity of the above commit, it appears that many of the attributes are populated implicitly.

from goda.

egonelbre avatar egonelbre commented on June 10, 2024

Yeah, I've had #40 open for a while :D... but just haven't found the motivation to write it.

from goda.

iskunk avatar iskunk commented on June 10, 2024

I sympathize! Just the link you provided above would be plenty... and adding e.g.

# list dependency graph in same format as "go mod graph"
goda graph -type edges -f '{{.ID}}{{if .Module}}{{with .Module.Version}}@{{.}}{{end}}{{end}}' ./...:all

as a usage example would address a significant use case. Longer-form documentation would be nice, but this should be quite helpful low-hanging fruit.

from goda.

egonelbre avatar egonelbre commented on June 10, 2024

I added goda help format, this has more information. I'll also add your proposed example.

from goda.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.