arnaucube
arnaucube/blogoPublic Self-hosted repository
blogo/files.go
files.goRaw
 1package main
 2
 3import (
 4	"io/ioutil"
 5	"os/exec"
 6	"strings"
 7
 8	"github.com/fatih/color"
 9)
10
11func readFile(path string) string {
12	dat, err := ioutil.ReadFile(path)
13	if err != nil {
14		color.Red(path)
15	}
16	check(err)
17	return string(dat)
18}
19
20func writeFile(path string, newContent string) {
21	err := ioutil.WriteFile(path, []byte(newContent), 0644)
22	check(err)
23
24	color.Green(path)
25	//color.Blue(newContent)
26}
27
28func getLines(text string) []string {
29	lines := strings.Split(text, "\n")
30	return lines
31}
32
33func concatStringsWithJumps(lines []string) string {
34	var r string
35	for _, l := range lines {
36		r = r + l + "\n"
37	}
38	return r
39}
40
41func copyRaw(original string, destination string) {
42	color.Green(destination)
43	_, err := exec.Command("cp", "-r", original, destination).Output()
44	check(err)
45}