Skip to content
This repository was archived by the owner on Jul 29, 2020. It is now read-only.

Add csv renderer#17

Open
joelmdesouza wants to merge 1 commit intomasterfrom
csv-renderer
Open

Add csv renderer#17
joelmdesouza wants to merge 1 commit intomasterfrom
csv-renderer

Conversation

@joelmdesouza
Copy link
Copy Markdown
Contributor

Resolves: prest/prest#360

@sourcelevel-bot
Copy link
Copy Markdown

SourceLevel has finished reviewing this Pull Request and has found:

  • 1 possible new issue (including those that may have been commented here).

See more details about this review.

Comment thread utils.go
}
w.Header().Set("Content-Type", "text/plain")
w.WriteHeader(recorder.Code)
w.Write(result)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Error return value of w.Write is not checked (from errcheck)

Comment thread csv.go
}
sort.Strings(keys)
var strOut bytes.Buffer
line := strings.Join(keys, ";") + "\n"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

You're writing csv on hand, there's the encoding/csv[1] package to do that job

[1] https://golang.org/pkg/encoding/csv/

Comment thread csv.go
return strOut.Bytes(), nil
}

func decodeLine(keys []string, data map[string]interface{}) []string {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

encoding/csv does this job for you
https://golang.org/src/encoding/csv/writer.go#L48

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement csv renderer

3 participants