1. github.com/jumpjumpbean/go-activiti-rest
// NewRequest constructs a request
// Convert payload to a JSON
func (c *ActClient) NewRequest(method, url string, payload interface{}) (*http.Request, error) {
	var buf io.Reader
	if payload != nil {
		var b []byte
		b, err := json.Marshal(&payload)
		if err != nil {
			return nil, err
		}
		buf = bytes.NewBuffer(b)
	}
	return http.NewRequest(method, url, buf)
}

此处json.Marshal(&payload)个人认为不需要&取地址符号
经过查阅资料得到一个说法,只不过指针更快,且能节省内存空间

  1. github.com/Leizhenpeng/feishu-chatGpt
if response.StatusCode/2 != 100 {
    return "", fmt.Errorf("gtp api %s", response.Status)
}

除2xx外均认为是失败,巧妙使用int除法特性找齐2xx状态码