github.com/trim21/go-phpserialize@v0.0.22-0.20240301204449-2fca0319b3f0/internal/encoder/bool_as_string.go (about) 1 package encoder 2 3 import ( 4 "unsafe" 5 6 "github.com/trim21/go-phpserialize/internal/runtime" 7 ) 8 9 func compileBoolAsString(typ *runtime.Type) (encoder, error) { 10 return encodeBoolAsString, nil 11 } 12 13 func encodeBoolAsString(ctx *Ctx, b []byte, p uintptr) ([]byte, error) { 14 value := **(**bool)(unsafe.Pointer(&p)) 15 if value { 16 return append(b, `s:4:"true";`...), nil 17 } 18 return append(b, `s:5:"false";`...), nil 19 }