本站源代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

56 lines
1.8KB

  1. // Copyright 2011 Google Inc. All rights reserved.
  2. // Use of this source code is governed by the Apache 2.0
  3. // license that can be found in the LICENSE file.
  4. package internal
  5. import (
  6. "os"
  7. netcontext "golang.org/x/net/context"
  8. )
  9. var (
  10. // This is set to true in identity_classic.go, which is behind the appengine build tag.
  11. // The appengine build tag is set for the first generation runtimes (<= Go 1.9) but not
  12. // the second generation runtimes (>= Go 1.11), so this indicates whether we're on a
  13. // first-gen runtime. See IsStandard below for the second-gen check.
  14. appengineStandard bool
  15. // This is set to true in identity_flex.go, which is behind the appenginevm build tag.
  16. appengineFlex bool
  17. )
  18. // AppID is the implementation of the wrapper function of the same name in
  19. // ../identity.go. See that file for commentary.
  20. func AppID(c netcontext.Context) string {
  21. return appID(FullyQualifiedAppID(c))
  22. }
  23. // IsStandard is the implementation of the wrapper function of the same name in
  24. // ../appengine.go. See that file for commentary.
  25. func IsStandard() bool {
  26. // appengineStandard will be true for first-gen runtimes (<= Go 1.9) but not
  27. // second-gen (>= Go 1.11).
  28. return appengineStandard || IsSecondGen()
  29. }
  30. // IsStandard is the implementation of the wrapper function of the same name in
  31. // ../appengine.go. See that file for commentary.
  32. func IsSecondGen() bool {
  33. // Second-gen runtimes set $GAE_ENV so we use that to check if we're on a second-gen runtime.
  34. return os.Getenv("GAE_ENV") == "standard"
  35. }
  36. // IsFlex is the implementation of the wrapper function of the same name in
  37. // ../appengine.go. See that file for commentary.
  38. func IsFlex() bool {
  39. return appengineFlex
  40. }
  41. // IsAppEngine is the implementation of the wrapper function of the same name in
  42. // ../appengine.go. See that file for commentary.
  43. func IsAppEngine() bool {
  44. return IsStandard() || IsFlex()
  45. }
上海开阖软件有限公司 沪ICP备12045867号-1