The reconcile package is used for DOM reconcilation in Isomorphic Go web applications.

helper.go 1.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. // Copyright 2013 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. package ipv6
  5. import (
  6. "errors"
  7. "net"
  8. )
  9. var (
  10. errMissingAddress = errors.New("missing address")
  11. errHeaderTooShort = errors.New("header too short")
  12. errInvalidConnType = errors.New("invalid conn type")
  13. errOpNoSupport = errors.New("operation not supported")
  14. errNoSuchInterface = errors.New("no such interface")
  15. )
  16. func boolint(b bool) int {
  17. if b {
  18. return 1
  19. }
  20. return 0
  21. }
  22. func netAddrToIP16(a net.Addr) net.IP {
  23. switch v := a.(type) {
  24. case *net.UDPAddr:
  25. if ip := v.IP.To16(); ip != nil && ip.To4() == nil {
  26. return ip
  27. }
  28. case *net.IPAddr:
  29. if ip := v.IP.To16(); ip != nil && ip.To4() == nil {
  30. return ip
  31. }
  32. }
  33. return nil
  34. }
  35. func opAddr(a net.Addr) net.Addr {
  36. switch a.(type) {
  37. case *net.TCPAddr:
  38. if a == nil {
  39. return nil
  40. }
  41. case *net.UDPAddr:
  42. if a == nil {
  43. return nil
  44. }
  45. case *net.IPAddr:
  46. if a == nil {
  47. return nil
  48. }
  49. }
  50. return a
  51. }