Comments (10)
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.
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.
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.
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.
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.
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.
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.
Yeah, I've had #40 open for a while :D... but just haven't found the motivation to write it.
from goda.
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.
I added goda help format
, this has more information. I'll also add your proposed example.
from goda.
Related Issues (20)
- Allow removing transitive edges
- help: write documentation about `-f` (templates) HOT 1
- graph: collapsing modules, internal and arbitrary keywords HOT 2
- Use tabwriter in output HOT 1
- Add "goda why" or similar command HOT 4
- stat: add `ModuleCount`
- graph: add node sizing and coloring
- graph: add digraph format (mod graph)
- graph: dark mode
- expr: provide a way to select main packages HOT 1
- make it easier to select tests HOT 2
- avoid test packages in cut output HOT 1
- Exclude several URLs HOT 1
- expr: support `()` as empty package set
- README needs updating HOT 1
- panic: runtime error: invalid memory address or nil pointer dereference HOT 3
- internal/pkgset: avoid loading all std packages
- goda weight: unable to find type in sym HOT 2
- goda complains about needing a go mod tidy that is never enough HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from goda.