douche5961 2017-01-21 22:49
浏览 287
已采纳

如何在golang中以UTF-8编码gob?

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"

  • 写回答

1条回答 默认 最新

  • dtw52353 2017-01-22 00:20
    关注

    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
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?