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 Oct 22, 2019
1 parent 0944d24 commit 902606d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
4 changes: 2 additions & 2 deletions 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 902606d

Please sign in to comment.