-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
92 lines (66 loc) · 2.16 KB
/
main.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
package main
import "net/http"
// main is the function that will be called when program starts, when main function exists program exists
func main() {
// Phase 1 help:
// call parseFlags
// call list
// call merge
// Phase 2 help:
// call watch
// Phase 3 help:
// casting to MergedFile
// https://golang.org/pkg/net/http/#Handle
// https://golang.org/pkg/net/http/#ListenAndServe
// https://golang.org/pkg/sync/#WaitGroup
}
// cliParams is structure contains cli params flags
type cliParams struct {
list string // phase 1
out string // phase 1
// watch bool // phase 2
// serve int // phase 3
}
// parseFlags will parse cli program arguments into internal structure for later use
func parseFlags() (params cliParams) {
// Phase 1 help:
// https://golang.org/pkg/flag/#StringVar
// Phase 2 help:
// https://golang.org/pkg/flag/#BoolVar
// Phase 3 help:
// https://golang.org/pkg/flag/#IntVar
// help:
// https://golang.org/pkg/flag/#Parse
return
}
// list will read list of css files from list json file
func list(listFile string) (cssFilePaths []string, err error) {
// help:
// https://golang.org/pkg/io/ioutil/#ReadFile
// https://golang.org/pkg/encoding/json/#Unmarshal
return
}
// merge will merge css files into one big new file, if merged file exists it will be overwritten
func merge(cssFilePaths []string, mergedFile string) (err error) {
// help:
// https://golang.org/pkg/os/#Create
// https://golang.org/pkg/os/#File.Close
// https://golang.org/pkg/os/#Open
// https://golang.org/pkg/io/#Copy
return nil
}
// watch will watch changes in cssFilePaths files and rebuild mergedFile
func watch(cssFilePaths []string, mergedFile string) (err error) {
// help: https://golang.org/pkg/os/#Stat
return
}
// MergedFile is a custom type representing merged css file
type MergedFile string
// ServeHTTP of MergedFile type satisfy http.Handler interface making it accessible via http protocol
func (mf MergedFile) ServeHTTP(w http.ResponseWriter, req *http.Request) {
// help:
// https://golang.org/pkg/os/#Stat
// https://golang.org/pkg/os/#Open
// https://golang.org/pkg/net/http/#ServeContent
// https://golang.org/pkg/net/http/#Error
}