MCPcopy
hub / github.com/syncthing/syncthing / main

Function main

script/genassets.go:114–147  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

112}
113
114func main() {
115 outfile := flag.String("o", "", "Name of output file (default stdout)")
116 flag.Parse()
117
118 filepath.Walk(flag.Arg(0), walkerFor(flag.Arg(0)))
119 var buf bytes.Buffer
120
121 // Generated time is now, except if the SOURCE_DATE_EPOCH environment
122 // variable is set (for reproducible builds).
123 generated := time.Now().Unix()
124 if s, _ := strconv.ParseInt(os.Getenv("SOURCE_DATE_EPOCH"), 10, 64); s > 0 {
125 generated = s
126 }
127
128 tpl.Execute(&buf, templateVars{
129 Assets: assets,
130 Generated: generated,
131 })
132 bs, err := format.Source(buf.Bytes())
133 if err != nil {
134 fmt.Fprintln(os.Stderr, err)
135 os.Exit(1)
136 }
137
138 out := io.Writer(os.Stdout)
139 if *outfile != "" {
140 out, err = os.Create(*outfile)
141 if err != nil {
142 fmt.Fprintln(os.Stderr, err)
143 os.Exit(1)
144 }
145 }
146 out.Write(bs)
147}

Callers

nothing calls this directly

Calls 8

ParseMethod · 0.80
BytesMethod · 0.80
walkerForFunction · 0.70
StringMethod · 0.65
WalkMethod · 0.65
NowMethod · 0.65
CreateMethod · 0.65
WriteMethod · 0.45

Tested by

no test coverage detected