Skip to content

Commit

Permalink
fix(main): fix misused return statement
Browse files Browse the repository at this point in the history
  • Loading branch information
heiruwu committed Jan 3, 2024
1 parent 8ec74e3 commit 5cbfc3d
Showing 1 changed file with 16 additions and 18 deletions.
34 changes: 16 additions & 18 deletions cmd/main/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -254,27 +254,25 @@ func main() {
panic(err)
}

var userUID string
if !strings.HasPrefix(config.Config.Server.Edition, "cloud") ||
strings.HasSuffix(config.Config.Server.Edition, "test") {
if resp, err := mgmtPrivateServiceClient.GetUserAdmin(ctx, &mgmtPB.GetUserAdminRequest{Name: constant.CoreDefaultUserID}); err == nil {
userUID = resp.GetUser().GetUid()
} else {
logger.Error(err.Error())
return
}
} else {
if resp, err := mgmtPrivateServiceClient.GetUserAdmin(ctx, &mgmtPB.GetUserAdminRequest{Name: constant.CloudDefaultUserID}); err == nil {
userUID = resp.GetUser().GetUid()
} else {
logger.Error(err.Error())
return
}
}

// Start usage reporter
var usg usage.Usage
if config.Config.Server.Usage.Enabled {
var userUID string
if !strings.HasPrefix(config.Config.Server.Edition, "cloud") ||
strings.HasSuffix(config.Config.Server.Edition, "test") {
if resp, err := mgmtPrivateServiceClient.GetUserAdmin(ctx, &mgmtPB.GetUserAdminRequest{Name: constant.CoreDefaultUserID}); err == nil {
userUID = resp.GetUser().GetUid()
} else {
logger.Error(err.Error())
}
} else {
if resp, err := mgmtPrivateServiceClient.GetUserAdmin(ctx, &mgmtPB.GetUserAdminRequest{Name: constant.CloudDefaultUserID}); err == nil {
userUID = resp.GetUser().GetUid()
} else {
logger.Error(err.Error())
}
}

usageServiceClient, usageServiceClientConn := external.InitUsageServiceClient(ctx)
defer usageServiceClientConn.Close()
logger.Info("try to start usage reporter")
Expand Down

0 comments on commit 5cbfc3d

Please sign in to comment.