-
Notifications
You must be signed in to change notification settings - Fork 200
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
Display output using template #68
Conversation
utkarshmani1997
commented
Jul 26, 2017
- 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}}") |
There was a problem hiding this comment.
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") |
There was a problem hiding this comment.
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 ?
There was a problem hiding this comment.
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 Report
@@ 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
Continue to review full report at Codecov.
|
the changes are merged in #83 .Closing this PR |