-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathignores.go
35 lines (28 loc) · 825 Bytes
/
ignores.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package gitgen
import (
"io"
)
// GetIgnoreText returns the text of a git ignore
// file as a string. The git ignore file is identified by the
// name. All files come from Github
func GetIgnoreText(key string) string {
// Get raw embeded bytes
raw, _ := asset("ignores/" + key + ".gitignore")
// Make them a string
return string(raw)
}
// WriteIgnore writes a .gitignore template to an
// io.Writer. It can be a file, a http response, etc
func WriteIgnore(key string, w io.Writer) (n int, err error) {
// get the data from the embeded file
data, err := asset("ignores/" + key + ".gitignore")
if err != nil {
return
}
return w.Write(data)
}
// ListIgnores returns a slice of strings containing
// the names of all available git ignore templates
func ListIgnores() []string {
return listAssets("ignores")
}