如何将Java注释转换为代码?

I'm changing my java project to golang. I'm using a java annotation and want to convert it into go code. I want to know the best data structure in go to convert this annotation.

My code is as follows:

package main

import (
    "bytes"
    "encoding/json"
    "fmt"
    "io/ioutil"
    "net/http"
    "strconv"
    "time"
)

func getBody(method string, Id string, auth string, body []byte,timeStamp int64) ([]byte, error) {

    url := "****************"+Id+"***********"+strconv.FormatInt(timeStamp,10)
    client := &http.Client{}
    req, err := http.NewRequest(method, url, bytes.NewReader(body))

    if err != nil {
        return nil, err
    }

    var header = make(map[string]string,2)
    header["Accept"]="*******************"
    header["Authorization"]=auth

    for key, value := range header {
        req.Header.Add(key, value)
    }

    res, err := client.Do(req)
    defer res.Body.Close()

    if err != nil {
        return nil, err
    }

    var bodyBytes []byte

    if res.StatusCode == 200 {
        bodyBytes, err = ioutil.ReadAll(res.Body)
    } else if err != nil {
        return nil, err
    } else {
        return nil, fmt.Errorf("The remote end did not return a HTTP 200 (OK) response.")
    }

    return bodyBytes, nil

}

func main() {

    method := "GET"
    auth:="************"
    var timeStamp int64 = 1441689793403
    Id:="***********"
    fmt.Println(timeStamp)
    var cs int64 = time.Now().UnixNano()/1000000
    for{
        cs = time.Now().UnixNano()/1000000
        bodyBytes, err := getBody(method, Id, auth, nil,timeStamp)
        if err != nil {
            fmt.Errorf("unable to retrieve the response body from the Glance API server: %v", err)
        }

        var obj []interface{}
        err = json.Unmarshal(bodyBytes, &obj)

        if err != nil {
            fmt.Errorf("unable to parse the JSON response:", err)
        }

        for i,_:=range obj{
            m := obj[i].(map[string]interface{})
            fmt.Println(m["text"])

         /* @OnKeyWord("hi")
          public void HelloWorld(TeamchatAPI api) {
          System.out.println("Hello word");
                );  */


        }

        timeStamp = cs
    }
}

I want to convert the commented java code into go code.

Alternatively you can take your own example to explain, if you want.

After you have done the translation as @icza explained, you wish probably to move the functionality to a middleware (example) that gets run for all your requests. That way you can add the assisting logic (the "if" part) out of your business methods.

There is also no need to implement middlewares for HTTP frameworks yourself. Most web frameworks include one by default.