Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display output using template #68

Closed
wants to merge 1 commit into from
Closed

Display output using template #68

wants to merge 1 commit into from

Conversation

utkarshmani1997
Copy link
Contributor

  • Local variable naming as prescribed by the Golang community.
  • Displays output using Template.

data, err := json.MarshalIndent(annotation, "", "\t")

// Printing using template
tmpl, err := template.New("test").Parse("IQN : {{.IQN}}\nVolume : {{.Volume}}\nPortal : {{.Portal}}\nSize : {{.Size}}")

Choose a reason for hiding this comment

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

Use typed string constant for the string used in template.
Eventually this typed string will be used to define many more templates.

panic(err)
}

os.Stdout.Write(data)

// Printing in tabular form
q := tabwriter.NewWriter(os.Stdout, minwidth, maxwidth, padding, ' ', tabwriter.AlignRight|tabwriter.Debug)

fmt.Fprintf(q, "\n\nReplica\tStatus\tDataUpdateIndex\t\n")

Choose a reason for hiding this comment

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

Why are we not using template feature vs. fmt.Fprintf ?

Copy link
Contributor Author

@utkarshmani1997 utkarshmani1997 Jul 26, 2017

Choose a reason for hiding this comment

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

This is required to print the output in tabular format (syntax of text/tabwriter package) as suggested by @prateekpandey14.

@codecov
Copy link

codecov bot commented Jul 26, 2017

Codecov Report

Merging #68 into master will decrease coverage by 0.05%.
The diff coverage is 94.11%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #68      +/-   ##
==========================================
- Coverage   14.04%   13.98%   -0.06%     
==========================================
  Files          31       31              
  Lines        5085     5083       -2     
==========================================
- Hits          714      711       -3     
  Misses       4329     4329              
- Partials       42       43       +1
Impacted Files Coverage Δ
command/vsm_stats.go 38.18% <94.11%> (-0.72%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ad3ad2b...76677c6. Read the comment docs.

@utkarshmani1997
Copy link
Contributor Author

the changes are merged in #83 .Closing this PR

@utkarshmani1997 utkarshmani1997 deleted the vsm_stats_refactoring branch September 20, 2017 05:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants