Fix some Go Lint errors

This commit is contained in:
bep 2015-03-06 15:58:14 +01:00
parent 103ea842f8
commit 224a2ddf3c
2 changed files with 10 additions and 7 deletions

View file

@ -24,10 +24,13 @@ var bufferPool = &sync.Pool{
}, },
} }
// GetBuffer returns a buffer from the pool.
func GetBuffer() (buf *bytes.Buffer) { func GetBuffer() (buf *bytes.Buffer) {
return bufferPool.Get().(*bytes.Buffer) return bufferPool.Get().(*bytes.Buffer)
} }
// PutBuffer returns a buffer to the pool.
// The buffer is reset before it is put back into circulation.
func PutBuffer(buf *bytes.Buffer) { func PutBuffer(buf *bytes.Buffer) {
buf.Reset() buf.Reset()
bufferPool.Put(buf) bufferPool.Put(buf)

View file

@ -27,8 +27,8 @@ import (
"github.com/spf13/viper" "github.com/spf13/viper"
) )
var OutputDir string var outputDir string
var Unsafe bool var unsafe bool
var convertCmd = &cobra.Command{ var convertCmd = &cobra.Command{
Use: "convert", Use: "convert",
@ -80,8 +80,8 @@ func init() {
convertCmd.AddCommand(toJSONCmd) convertCmd.AddCommand(toJSONCmd)
convertCmd.AddCommand(toTOMLCmd) convertCmd.AddCommand(toTOMLCmd)
convertCmd.AddCommand(toYAMLCmd) convertCmd.AddCommand(toYAMLCmd)
convertCmd.PersistentFlags().StringVarP(&OutputDir, "output", "o", "", "filesystem path to write files to") convertCmd.PersistentFlags().StringVarP(&outputDir, "output", "o", "", "filesystem path to write files to")
convertCmd.PersistentFlags().BoolVar(&Unsafe, "unsafe", false, "enable less safe operations, please backup first") convertCmd.PersistentFlags().BoolVar(&unsafe, "unsafe", false, "enable less safe operations, please backup first")
} }
func convertContents(mark rune) (err error) { func convertContents(mark rune) (err error) {
@ -134,10 +134,10 @@ func convertContents(mark rune) (err error) {
page.SetSourceContent(psr.Content()) page.SetSourceContent(psr.Content())
page.SetSourceMetaData(metadata, mark) page.SetSourceMetaData(metadata, mark)
if OutputDir != "" { if outputDir != "" {
page.SaveSourceAs(filepath.Join(OutputDir, page.FullFilePath())) page.SaveSourceAs(filepath.Join(outputDir, page.FullFilePath()))
} else { } else {
if Unsafe { if unsafe {
page.SaveSource() page.SaveSource()
} else { } else {
jww.FEEDBACK.Println("Unsafe operation not allowed, use --unsafe or set a different output path") jww.FEEDBACK.Println("Unsafe operation not allowed, use --unsafe or set a different output path")