Last active
April 11, 2017 15:59
-
-
Save mpppk/7103b22db28b4b2fbaff0c650ee153ed to your computer and use it in GitHub Desktop.
go concat
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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