-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpushFile.go
More file actions
39 lines (33 loc) · 745 Bytes
/
pushFile.go
File metadata and controls
39 lines (33 loc) · 745 Bytes
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
36
37
38
39
package main
import (
// "github.com/davecgh/go-spew/spew"
"io/ioutil"
"log"
)
type Gist struct {
Files map[string]GistFile `json:"files"`
Public bool `json:"public"`
Description string `json:"description"`
}
type GistFile struct {
Content string `json:"content"`
}
func pushFile(filename string, tag string, description string) {
println("pushing file....")
files := map[string]GistFile{}
content, err := ioutil.ReadFile(filename)
if err != nil {
log.Fatal("Read file error: ", err)
}
files[filename] = GistFile{string(content)}
gist := Gist{
files,
true,
description,
}
// spew.Dump(gist)
id := pushGist(gist)
if id != "" {
pushToDB(id, filename, tag, description)
}
}