我的Java代码如下:

    public static byte[] gzip(String str) throws Exception{
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    GZIPOutputStream gos = new GZIPOutputStream(baos);
    gos.write(str.getBytes("UTF-8"));
    gos.close();
    return baos.toByteArray();
}

java-如何在golang中gzip字符串并在golang中返回字节数组?