all repos — goget @ ccd27eaeb455cda3fee124357ab331eb2776e250

returns a go-import meta tag

Configure git URL
Anirudh Oppiliappan x@icyphox.sh
Wed, 30 Nov 2022 10:46:34 +0530
commit

ccd27eaeb455cda3fee124357ab331eb2776e250

parent

6e3f009983098a9f5d199dbcd16d047a9f60934a

1 files changed, 5 insertions(+), 3 deletions(-)

jump to
M main.gomain.go

@@ -11,6 +11,7 @@ )

type config struct { prettyurl string + giturl string } func logger(h http.Handler) http.Handler {

@@ -27,7 +28,7 @@ func (c *config) goget(w http.ResponseWriter, r *http.Request) {

w.Header().Set("content-type", "text/html") pretty := path.Join(c.prettyurl, r.URL.Path) - content := path.Join(r.Host, r.URL.Path) + content := path.Join(c.giturl, r.URL.Path) fmt.Fprintf( w, `<head><meta name="go-import" content="%s git https://%s"></head>`, pretty, content,

@@ -38,10 +39,11 @@

func main() { cfg := config{} flag.StringVar(&cfg.prettyurl, "pretty-url", "", "pretty url for your go module") + flag.StringVar(&cfg.giturl, "git-url", "", "actual git url of your go module") flag.Parse() - if cfg.prettyurl == "" { - fmt.Println("goget: required flag --pretty-url") + if flag.NFlag() != 2 { + fmt.Println("goget: required options --pretty-url and --git-url") os.Exit(1) }