Skip to content

Instantly share code, notes, and snippets.

@kaneshin
Last active January 15, 2016 12:04
Show Gist options
  • Save kaneshin/71ef4a2488959fc2c810 to your computer and use it in GitHub Desktop.
Save kaneshin/71ef4a2488959fc2c810 to your computer and use it in GitHub Desktop.
package foo
import (
"bytes"
"encoding/json"
"fmt"
)
func buildArrayBodyVerKojima(v []interface{}) string {
var str string
for _, j := range v {
jsonByte, _ := json.Marshal(j)
str = fmt.Sprintf("%s%s\n", str, string(jsonByte))
}
return str
}
func buildArrayBodyVerKaneshin(v []interface{}) string {
var buf bytes.Buffer
for _, j := range v {
jsonByte, _ := json.Marshal(j)
buf.Write(jsonByte)
buf.WriteString("\n")
}
return buf.String()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment