Merge pull request #428 from ooni/sandbox-sbs

refactor(netxlite): move generator in a subpackage
This commit is contained in:
Simone Basso 2021-07-02 14:37:45 +02:00 committed by GitHub
commit b13c7bf8fb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 12 deletions

View File

@ -1,10 +1,10 @@
// Code generated by go generate; DO NOT EDIT. // Code generated by go generate; DO NOT EDIT.
// 2021-06-25 12:32:42.759674 +0200 CEST m=+0.458880709 // 2021-07-02 14:26:19.300018 +0200 CEST m=+0.978891751
// https://curl.haxx.se/ca/cacert.pem // https://curl.haxx.se/ca/cacert.pem
package netxlite package netxlite
//go:generate go run certifigen.go "https://curl.haxx.se/ca/cacert.pem" //go:generate go run ./generator/ "https://curl.haxx.se/ca/cacert.pem"
const pemcerts string = ` const pemcerts string = `
## ##

View File

@ -1,5 +1,3 @@
// +build ignore
// This Source Code Form is subject to the terms of the Mozilla Public // This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this // License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/. // file, You can obtain one at https://mozilla.org/MPL/2.0/.
@ -30,7 +28,7 @@ var tmpl = template.Must(template.New("").Parse(`// Code generated by go generat
package netxlite package netxlite
//go:generate go run certifigen.go "{{ .URL }}" //{{ .GoGenerate }} go run ./generator/ "{{ .URL }}"
const pemcerts string = ` + "`" + ` const pemcerts string = ` + "`" + `
{{ .Bundle }} {{ .Bundle }}
@ -39,7 +37,7 @@ const pemcerts string = ` + "`" + `
func main() { func main() {
if len(os.Args) != 2 || !strings.HasPrefix(os.Args[1], "https://") { if len(os.Args) != 2 || !strings.HasPrefix(os.Args[1], "https://") {
log.Fatal("usage: go run generate.go <url>") log.Fatal("usage: go run ./generator/ <url>")
} }
url := os.Args[1] url := os.Args[1]
@ -68,13 +66,15 @@ func main() {
} }
err = tmpl.Execute(fp, struct { err = tmpl.Execute(fp, struct {
Timestamp time.Time Bundle string
URL string GoGenerate string
Bundle string Timestamp time.Time
URL string
}{ }{
Timestamp: time.Now(), Bundle: string(bundle),
URL: url, GoGenerate: "go:generate",
Bundle: string(bundle), Timestamp: time.Now(),
URL: url,
}) })
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)