简体   繁体   中英

How to encode gob in UTF-8 in golang ?

I am using gob.NewEncoder to encode string message msg but need to do it in utf-8.

err= gob.NewEncoder(conn).Encode(msg)

I am getting warning in Ruby receiver (Logstash) saying that Received an event that has a different character encoding than you configured ...:expected_charset=>"UTF-8"

When you call Encode(msg) , you are not sending UTF-8 plain text.

To send plain text:

conn.Write([]byte(msg)) // suppose msg is string

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM