golang.org/x/build@v0.0.0-20240506185731-218518f32b70/devapp/devapp.go (about) 1 // Copyright 2016 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 // Devapp is the server running dev.golang.org. It shows open bugs and code 6 // reviews and other useful dashboards for Go developers. 7 package main 8 9 import ( 10 "context" 11 "flag" 12 "log" 13 "math/rand" 14 "net/http" 15 "os" 16 "time" 17 18 "golang.org/x/build/internal/https" 19 ) 20 21 var ( 22 staticDir = flag.String("static-dir", "./static/", "location of static directory relative to binary location") 23 templateDir = flag.String("template-dir", "./templates/", "location of templates directory relative to binary location") 24 reload = flag.Bool("reload", false, "reload content on each page load") 25 ) 26 27 func init() { 28 flag.Usage = func() { 29 os.Stderr.WriteString("devapp generates the dashboard that powers dev.golang.org.\n") 30 flag.PrintDefaults() 31 } 32 } 33 34 func main() { 35 https.RegisterFlags(flag.CommandLine) 36 flag.Parse() 37 rand.Seed(time.Now().UnixNano()) 38 39 s := newServer(http.NewServeMux(), *staticDir, *templateDir, *reload) 40 ctx := context.Background() 41 if err := s.initCorpus(ctx); err != nil { 42 log.Fatalf("Could not init corpus: %v", err) 43 } 44 go s.corpusUpdateLoop(ctx) 45 46 log.Fatalln(https.ListenAndServe(ctx, s)) 47 }