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

Add csv renderer #17

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Add csv renderer #17

wants to merge 1 commit into from

Conversation

joelmdesouza
Copy link
Contributor

Resolves: prest/prest#360

@sourcelevel-bot
Copy link

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.

}
w.Header().Set("Content-Type", "text/plain")
w.WriteHeader(recorder.Code)
w.Write(result)

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)

}
sort.Strings(keys)
var strOut bytes.Buffer
line := strings.Join(keys, ";") + "\n"
Copy link
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/

return strOut.Bytes(), nil
}

func decodeLine(keys []string, data map[string]interface{}) []string {
Copy link
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