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