94 return v.unmarshal(func(v interface{}) error { return json.Unmarshal(data, v) })
95}
96
97func (v *versionTLS) UnmarshalYAML(unmarshal func(interface{}) error) error { 98 return v.unmarshal(unmarshal)
99}
100
90 return v.String(), nil
91}
92
93func (v *versionTLS) UnmarshalJSON(data []byte) error { 94 return v.unmarshal(func(v interface{}) error { return json.Unmarshal(data, v) })
95}
96
24 versionTLS13
25)
26
27func (v versionTLS) String() string { 28 switch v {
29 case versionTLSUnknown:
30 return "unknown"
42}
43
44// CryptoTLSVersion return native tls.Version* from crypto/tls package.
45func (v versionTLS) CryptoTLSVersion() uint16 { 46 switch v {
47 case versionTLSUnknown:
48 return defaultVersionTLS.CryptoTLSVersion()
59 }
60}
61
62func (v versionTLS) orDefault() versionTLS { 63 if v == versionTLSUnknown {
64 return defaultVersionTLS
65 }
(Go's FAQ)[https://go.dev/doc/faq#methodsonvaluesorpointers] recommends that method receivers should be consistent. If some of the methods of the type must have pointer receivers, the rest should too, so the method set is consistent regardless of how the type is used. This is because value and pointer receivers have different method sets.
package main
type foo struct {
a int
}
func (f foo) a() {}
func (f *foo) b() {
f.a = 10
}
package main
type foo struct {
a int
}
func (f *foo) a() {}
func (f *foo) b() {
f.a = 10
}