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

JSON output #196

Merged
merged 3 commits into from
Feb 6, 2017
Merged

JSON output #196

merged 3 commits into from
Feb 6, 2017

Conversation

mattn
Copy link
Member

@mattn mattn commented Jan 30, 2017

implement for -json

Copy link
Contributor

@groob groob left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few nits.

@@ -65,6 +67,89 @@ type statusCommand struct {
modified bool
}

type Outputter interface {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know this is in package main, but the interface should be private.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@@ -78,10 +163,20 @@ func (cmd *statusCommand) Run(ctx *dep.Ctx, args []string) error {
sm.UseDefaultSignalHandling()
defer sm.Release()

var out Outputter
if cmd.detailed {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use a switch to set the Outputter instead of all the ifs and elses.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

}

func (out *jsonOutput) MissingFooter() {
json.NewEncoder(os.Stdout).Encode(out.missing)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be out.w instead of os.Stdout?

Copy link
Member Author

@mattn mattn Feb 2, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

right


type jsonOutput struct {
w io.Writer
basic []*BasicStatus
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do the two status slices need to be pointers?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, avoiding copies of marshal

@mattn
Copy link
Member Author

mattn commented Feb 2, 2017

@groob Thanks for your review.

@sdboyer
Copy link
Member

sdboyer commented Feb 6, 2017

Sorry for the delay on this - merging!

@sdboyer sdboyer merged commit 466bb30 into golang:master Feb 6, 2017
krisnova pushed a commit to krisnova/dep that referenced this pull request Apr 21, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants