[website] internal/godoc/golangorgenv: delete

4 views
Skip to first unread message

Russ Cox (Gerrit)

unread,
Mar 12, 2021, 2:58:03 PM3/12/21
to Russ Cox, goph...@pubsubhelper.golang.org, golang-...@googlegroups.com, Go Bot, Dmitri Shuralyov, golang-co...@googlegroups.com

Russ Cox submitted this change.

View Change

Approvals: Dmitri Shuralyov: Looks good to me, approved Russ Cox: Trusted; Run TryBots Go Bot: TryBots succeeded
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 <r...@golang.org>
Run-TryBot: Russ Cox <r...@golang.org>
TryBot-Result: Go Bot <go...@golang.org>
Reviewed-by: Dmitri Shuralyov <dmit...@golang.org>
---
M internal/env/env.go
D internal/godoc/golangorgenv/golangorgenv.go
2 files changed, 4 insertions(+), 56 deletions(-)

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
-}

7 is the latest approved patch-set. The change was submitted with unreviewed changes in the following files: The name of the file: internal/env/env.go Insertions: 0, Deletions: 10. ``` @@ -27:37 @@ - // 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. - ```

To view, visit change 293426. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: website
Gerrit-Branch: master
Gerrit-Change-Id: I10d323a5e08bee153bd921cffe79fb4eb9e8b29c
Gerrit-Change-Number: 293426
Gerrit-PatchSet: 9
Gerrit-Owner: Russ Cox <r...@golang.org>
Gerrit-Reviewer: Dmitri Shuralyov <dmit...@golang.org>
Gerrit-Reviewer: Go Bot <go...@golang.org>
Gerrit-Reviewer: Russ Cox <r...@golang.org>
Gerrit-MessageType: merged
Reply all
Reply to author
Forward
0 new messages