plane_user.go 528 B

12345678910111213141516171819202122232425
  1. package plane_v1
  2. import (
  3. "fmt"
  4. "go.uber.org/zap"
  5. )
  6. // ==================== User API ====================
  7. // GetMe 获取当前用户信息
  8. func GetMe() ([]byte, error) {
  9. resp, err := planeHttpGet("/api/v1/users/me/")
  10. if err != nil {
  11. zap.L().Error("[Plane] GetMe 请求失败", zap.Error(err))
  12. return nil, err
  13. }
  14. if !isSuccess(resp.StatusCode) {
  15. zap.L().Error("[Plane] GetMe 返回错误", zap.String("status", resp.Status))
  16. return nil, fmt.Errorf("GetMe 失败: %s", resp.Status)
  17. }
  18. return resp.Body, nil
  19. }