Skip to content

Instantly share code, notes, and snippets.

@mpppk
Last active April 11, 2017 15:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mpppk/7103b22db28b4b2fbaff0c650ee153ed to your computer and use it in GitHub Desktop.
Save mpppk/7103b22db28b4b2fbaff0c650ee153ed to your computer and use it in GitHub Desktop.
go concat
package main
import (
"io/ioutil"
"fmt"
)
func main(){
addHeader("a,b,c", "test.csv")
}
func addHeader(header string, filePath string) error {
data, err := ioutil.ReadFile(filePath)
ioutil.WriteFile(filePath, append([]byte(fmt.Sprintln(header)), data...), 0777)
return err
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment