github.com/golazy/golazy@v0.0.7-0.20221012133820-968fe65a0b65/lazydev/lazydev.go (about)

     1  package lazydev
     2  
     3  import (
     4  	"log"
     5  	"net/http"
     6  	"os"
     7  )
     8  
     9  const childEnvKey = "GOLAZY_CHILDPROCESS"
    10  
    11  func isChild() bool {
    12  	log.Println("is child", os.Getenv("GOLAZY_CHILDPROCESS") != "")
    13  	return os.Getenv("GOLAZY_CHILDPROCESS") != ""
    14  }
    15  
    16  func Serve(handler http.Handler) error {
    17  	if isChild() {
    18  		return (&child{}).Serve(handler)
    19  	}
    20  	return (&parent{}).Serve(handler)
    21  
    22  }