func (s *Startup) FillMessage(m *femebe.Message) { buf := bytes.NewBuffer(make([]byte, 0, 1024)) // Startup-message type word buf.Write([]byte{0x00, 0x03, 0x00, 0x00}) for name, value := range s.Params { femebe.WriteCString(buf, name) femebe.WriteCString(buf, value) } buf.Write([]byte{'\000'}) m.InitFromBytes(femebe.MSG_TYPE_FIRST, buf.Bytes()) }
func TestBackendKeyReading(t *testing.T) { buf := bytes.Buffer{} const PID = 1234 const KEY = 5768 femebe.WriteInt32(&buf, PID) femebe.WriteInt32(&buf, KEY) var m femebe.Message m.InitFromBytes(MSG_BACKEND_KEY_DATA_K, buf.Bytes()) kd, err := ReadBackendKeyData(&m) if err != nil { t.Fatal() } if kd.pid != PID { t.Fatal() } if kd.key != KEY { t.Fatal() } }