599 Internal Exception, https://fastapi.metacpan.org/v1/release/_search, Can't verify SSL peers without knowing which Certificate Authorities to trust This problem can be fixed by either setting the PERL_LWP_SSL_CA_FILE envirionment variable or by installing the Mozilla::CA module. To disable verification of SSL peers set the PERL_LWP_SSL_VERIFY_HOSTNAME envirionment variable to 0. If you do this you can't be sure that you communicate with the expected peer.
type IntPtr struct {
v *int
}
func (p IntPtr) Format(f fmt.State, c rune) {
if p.v == nil {
fmt.Fprintf(f, "<nil>")
return
}
format := "%"if f.Flag('0') {
format += "0"
}
if wid, ok := f.Width(); ok {
format += fmt.Sprintf("%d", wid)
}
if prec, ok := f.Precision(); ok {
format += fmt.Sprintf(".%d", prec)
}
format += string(c)
fmt.Fprintf(f, format, *p.v)
}
func main() {
i := 10
p := IntPtr{&i}
fmt.Printf("%[1]d %04[1]x\n", p)
// Output: 10 000a
}
なぜIntPtrを構造体にしているか
Go言語仕様で、メソッドレシーバの基本型(base type)にポインタやインターフェイスを使えません。基本型というのは、メソッドのレシーバ型は T または *T が使えるけれども、両方における T のことです。これはMethod declarationsに書かれています。
Its type must be of the form T or *T (possibly using parentheses) where T is a type name. The type denoted by T is called the receiver base type; it must not be a pointer or interface type and it must be defined in the same package as the method.
なので、
type IntPtr *intfunc (p IntPtr) String(f fmt.State, c rune) {
}
上のコードは、
invalid receiver type IntPtr (IntPtr is a pointer type)