internal/godoc/golangorgenv: delete
Now that all the references are internal
(the direct playground reference is gone),
we can use internal/env instead.
Change-Id: I10d323a5e08bee153bd921cffe79fb4eb9e8b29c
Reviewed-on: https://go-review.googlesource.com/c/website/+/293426
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
diff --git a/internal/env/env.go b/internal/env/env.go
index c078626..80575a3 100644
--- a/internal/env/env.go
+++ b/internal/env/env.go
@@ -10,11 +10,11 @@
"log"
"os"
"strconv"
-
- "golang.org/x/website/internal/godoc/golangorgenv"
)
var (
+ checkCountry = boolEnv("GOLANGORG_CHECK_COUNTRY")
+ enforceHosts = boolEnv("GOLANGORG_ENFORCE_HOSTS")
requireDLSecretKey = boolEnv("GOLANGORG_REQUIRE_DL_SECRET_KEY")
)
@@ -25,24 +25,14 @@
return requireDLSecretKey
}
-// Use the golangorgenv package for common configuration, instead
-// of duplicating it. This reduces the risk of divergence between
-// the environment variables that this env package uses, and ones
-// that golangorgenv uses.
-//
-// TODO(dmitshur): When the golang.org/x/tools/playground package becomes unused,
-// and golang.org/x/tools/godoc is modified to accept configuration explicitly,
-// the golang.org/x/tools/godoc/golangorgenv package can be deleted.
-// At that time, its implementation can be inlined into this package, as needed.
-
// CheckCountry reports whether country restrictions should be enforced.
func CheckCountry() bool {
- return golangorgenv.CheckCountry()
+ return checkCountry
}
// EnforceHosts reports whether host filtering should be enforced.
func EnforceHosts() bool {
- return golangorgenv.EnforceHosts()
+ return enforceHosts
}
func boolEnv(key string) bool {
diff --git a/internal/godoc/golangorgenv/golangorgenv.go b/internal/godoc/golangorgenv/golangorgenv.go
deleted file mode 100644
index 0b96eec..0000000
--- a/internal/godoc/golangorgenv/golangorgenv.go
+++ /dev/null
@@ -1,42 +0,0 @@
-// Copyright 2018 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-// Package golangorgenv provides environment information for programs running at
-// golang.org and its subdomains.
-package golangorgenv
-
-import (
- "log"
- "os"
- "strconv"
-)
-
-var (
- checkCountry = boolEnv("GOLANGORG_CHECK_COUNTRY")
- enforceHosts = boolEnv("GOLANGORG_ENFORCE_HOSTS")
-)
-
-// CheckCountry reports whether country restrictions should be enforced.
-func CheckCountry() bool {
- return checkCountry
-}
-
-// EnforceHosts reports whether host filtering should be enforced.
-func EnforceHosts() bool {
- return enforceHosts
-}
-
-func boolEnv(key string) bool {
- v := os.Getenv(key)
- if v == "" {
- // TODO(dmitshur): In the future, consider detecting if running in App Engine,
- // and if so, making the environment variables mandatory rather than optional.
- return false
- }
- b, err := strconv.ParseBool(v)
- if err != nil {
- log.Fatalf("environment variable %s (%q) must be a boolean", key, v)
- }
- return b
-}