assert_ts_toolchain_match.go 852 B

123456789101112131415161718192021222324252627
  1. // Copyright (c) Tailscale Inc & AUTHORS
  2. // SPDX-License-Identifier: BSD-3-Clause
  3. //go:build tailscale_go
  4. package tailscaleroot
  5. import (
  6. "fmt"
  7. "os"
  8. "strings"
  9. )
  10. func init() {
  11. tsRev, ok := tailscaleToolchainRev()
  12. if !ok {
  13. panic("binary built with tailscale_go build tag but failed to read build info or find tailscale.toolchain.rev in build info")
  14. }
  15. want := strings.TrimSpace(GoToolchainRev)
  16. if tsRev != want {
  17. if os.Getenv("TS_PERMIT_TOOLCHAIN_MISMATCH") == "1" {
  18. fmt.Fprintf(os.Stderr, "tailscale.toolchain.rev = %q, want %q; but ignoring due to TS_PERMIT_TOOLCHAIN_MISMATCH=1\n", tsRev, want)
  19. return
  20. }
  21. panic(fmt.Sprintf("binary built with tailscale_go build tag but Go toolchain %q doesn't match github.com/tailscale/tailscale expected value %q; override this failure with TS_PERMIT_TOOLCHAIN_MISMATCH=1", tsRev, want))
  22. }
  23. }