version_go112.go 566 B

123456789101112131415161718192021222324252627
  1. // Copyright 2019 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. // +build go1.12
  5. package acme
  6. import "runtime/debug"
  7. func init() {
  8. // Set packageVersion if the binary was built in modules mode and x/crypto
  9. // was not replaced with a different module.
  10. info, ok := debug.ReadBuildInfo()
  11. if !ok {
  12. return
  13. }
  14. for _, m := range info.Deps {
  15. if m.Path != "golang.org/x/crypto" {
  16. continue
  17. }
  18. if m.Replace == nil {
  19. packageVersion = m.Version
  20. }
  21. break
  22. }
  23. }