Перепиши на Golang
```js
const EventSource = require('eventsource');

function generateHash() {
    return Math.random().toString(36).substring(2);
}

class GptChat{
  constructor(){
    this.messages = [];
    this.$events = {};
    this.$hash = generateHash();
  }
  get hash(){
    return this.$hash;
  }
  async register(){
    const es = new EventSource(`https://yuntian-deng-o1mini.hf.space/heartbeat/${this.$hash}`);
    let resolveFunc, rejectFunc;
    const promise = new Promise((resolve, reject) => {
      resolveFunc = resolve;
      rejectFunc = reject;
    });
    
    es.onopen = async () => {
      resolveFunc();
      
      const s = await fetch("https://yuntian-deng-o1mini.hf.space/run/predict?__theme=light", {
        "headers": {
            "content-type": "application/json",
        },
        "body": JSON.stringify({
          "data":[],
          "event_data":null,
          "fn_index":4,
          "trigger_id":9,
          "session_hash":this.$hash,
        }),
        "method": "POST",
      });
      console.log(s);
      
    }
    es.onmessage = (event)=>{
      console.log(event.data);
    }
    es.onerror = (err) => {
      console.error(err);
      rejectFunc(err);
      es.close();
    }
    
    return await promise
  }
  async listenSocket(){
    const es = new EventSource(`https://yuntian-deng-o1mini.hf.space/queue/data?session_hash=${this.$hash}`, {
      headers: {
        "content-type": "application/json",
        "TE": "trailers",
        "DNT": "1",
      }
    });
    
    let resolveFunc, rejectFunc;
    const promise = new Promise((resolve, reject) => {
      resolveFunc = resolve;
      rejectFunc = reject;
    })

    es.onopen = () => {
      resolveFunc();
    }
    
    es.onmessage = (event) => {
      const data = JSON.parse(event.data);
      const msg = data.msg;

      switch(msg){
          case "heartbeat": {
            console.log('HEARTBEAT')
            break;
          }
          case "estimation": {
            const event = this.$events[data.event_id];
            if(event){
              console.log(`[${data.event_id}]: Quene size: ${data.queue_size}/1`);
            }
            break;
          }
          case "process_starts": {
            const event = this.$events[data.event_id];
            if(event){
              console.log(`[${data.event_id}]: Process starts!`);
            }
            break;
          }
          case "process_generating": {
            const event = this.$events[data.event_id];
            if(event){
              console.log(`[${data.event_id}]: `, data);
            }
            break;
          }
      }
      console.log(data);
      
    }
    es.onerror = (err) => {
      console.error(err);
      rejectFunc();
      es.close();
    }
    return await promise;
  }
  async send(){
    const fe = await fetch("https://yuntian-deng-o1mini.hf.space/queue/join?__theme=light", {
        "credentials": "omit",
        "headers": {
            "content-type": "application/json",
            "TE": "trailers",
            "DNT": "1",
        },
        "body": JSON.stringify({}),
        "method": "POST",
        "mode": "cors"
    });
    const data = await fe.json();
    const eventId = data.event_id;
    let resolveFunc, rejectFunc;
    const defer = new Promise((resolve, reject)=>{
      resolveFunc = resolve;
      rejectFunc = reject;
    })
    this.$events[eventId] = {
      resolve: resolveFunc,
      reject: rejectFunc,
    };    
    return await defer;
  }
}

(async ()=>{
  const gpt = new GptChat();
  console.log(gpt.hash);
  
  console.log(await gpt.register());
  await gpt.listenSocket();

  
  
})();
```