Skip to content

Commit

Permalink
gen.go: allow to customise the URL when generating
Browse files Browse the repository at this point in the history
"go run gen.go" now takes the URL from the command line.
That URL is persisted in the go:generate line produced in certifi.go, so
"go generate" will reuse that URL forever.

This allows to easily fork the project to use a different URL (such as
the original Mozilla) if someone doesn't trust mkcert.org.
  • Loading branch information
dolmen committed Feb 11, 2020
1 parent a6d78f3 commit ac88b96
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion certifi.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 7 additions & 2 deletions gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,17 @@ import (
"log"
"net/http"
"os"
"strings"
"text/template"
"time"
)

func main() {
const url = "https://mkcert.org/generate/"
if len(os.Args) != 2 || !strings.HasPrefix(os.Args[1], "https://") {
log.Fatal("usage: go run gen.go <url>")
}
url := os.Args[1]

resp, err := http.Get(url)
if err != nil {
log.Fatal(err)
Expand Down Expand Up @@ -53,7 +58,7 @@ var tmpl = template.Must(template.New("").Parse(`// Code generated by go generat
package gocertifi
//go:generate go run gen.go
//go:generate go run gen.go "{{ .URL }}"
import "crypto/x509"
Expand Down

0 comments on commit ac88b96

Please sign in to comment.