guid_windows.go 674 B

123456789101112131415161718192021222324
  1. // Copyright (c) 2022 Tailscale Inc & 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. package wingoes
  5. import (
  6. "fmt"
  7. "golang.org/x/sys/windows"
  8. )
  9. type GUID = windows.GUID
  10. // MustGetGUID parses s, a string containing a GUID and returns a pointer to the
  11. // parsed GUID. s must be specified in the format "{XXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX}".
  12. // If there is an error parsing s, MustGetGUID panics.
  13. func MustGetGUID(s string) *windows.GUID {
  14. guid, err := windows.GUIDFromString(s)
  15. if err != nil {
  16. panic(fmt.Sprintf("wingoes.MustGetGUID(%q) error %v", s, err))
  17. }
  18. return &guid
  19. }