// utils package main import ( "io" "os" "os/user" "path" ) func gethomedir() string { u, _ := user.Current() return u.HomeDir } func gethistfile() string { const fname = ".bash_history" return path.Join(gethomedir(), fname) } func mktmpfile() string { const fname = ".bash_history" return path.Join("/tmp", fname) } func CopyFile(src, dst string) (int64, error) { sf, err := os.Open(src) if err != nil { return 0, err } defer sf.Close() df, err := os.Create(dst) if err != nil { return 0, err } defer df.Close() return io.Copy(df, sf) }