Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: unnecessary use of fmt.Sprintf #988

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pkg/apis/arenaclient/serving_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ func (t *ServingJobClient) TrafficRouterSplit(args *types.TrafficRouterSplitArgs
func moreThanOneInstanceHelpInfo(instances []types.ServingInstance) string {
header := fmt.Sprintf("There is %d instances have been found:", len(instances))
lines := []string{}
footer := fmt.Sprintf("please use '-i' or '--instance' to filter.")
footer := "please use '-i' or '--instance' to filter."
for _, i := range instances {
lines = append(lines, fmt.Sprintf("%v", i.Name))
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/commands/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func NewVersionCmd(cliName string) *cobra.Command {
)
versionCmd := cobra.Command{
Use: "version",
Short: fmt.Sprintf("Print version information"),
Short: "Print version information",
Run: func(cmd *cobra.Command, args []string) {
version := arena.GetVersion()
fmt.Printf("%s: %s\n", cliName, version)
Expand Down
2 changes: 1 addition & 1 deletion pkg/serving/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func ListServingJobs(namespace string, allNamespace bool, servingType types.Serv
if noPrivileges {
item := fmt.Sprintf("namespace %v", namespace)
if allNamespace {
item = fmt.Sprintf("all namespaces")
item = "all namespaces"
}
return nil, fmt.Errorf("the user has no privileges to list the serving jobs in %v", item)
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/serving/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func moreThanOneJobHelpInfo(infos []ServingJob) string {
header := fmt.Sprintf("There is %d jobs have been found:", len(infos))
tableHeader := "NAME\tTYPE\tVERSION"
lines := []string{tableHeader}
footer := fmt.Sprintf("please use '--type' or '--version' to filter.")
footer := "please use '--type' or '--version' to filter."
for _, info := range infos {
line := fmt.Sprintf("%s\t%s\t%s",
info.Name(),
Expand All @@ -36,7 +36,7 @@ func moreThanOneJobHelpInfo(infos []ServingJob) string {
func moreThanOneInstanceHelpInfo(instances []types.ServingInstance) string {
header := fmt.Sprintf("There is %d instances have been found:", len(instances))
lines := []string{}
footer := fmt.Sprintf("please use '-i' or '--instance' to filter.")
footer := "please use '-i' or '--instance' to filter."
for _, i := range instances {
lines = append(lines, fmt.Sprintf("%v", i.Name))
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/topnode/gpushare.go
Original file line number Diff line number Diff line change
Expand Up @@ -676,7 +676,7 @@ func displayGPUShareNodesCustomSummary(w *tabwriter.Writer, nodes []Node) {
if nodeInfo.TotalGPUCore > 0 {
items = append(items, fmt.Sprintf("%d/%d", nodeInfo.AllocatedGPUCore, nodeInfo.TotalGPUCore))
} else {
items = append(items, fmt.Sprintf("__"))
items = append(items, "__")
}
if isUnhealthy {
items = append(items, fmt.Sprintf("%v", nodeInfo.UnhealthyGPUs))
Expand Down
2 changes: 1 addition & 1 deletion pkg/topnode/normal.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ func displayNormalNodeSummary(w *tabwriter.Writer, nodes []Node, isUnhealthy, sh
}
}
if isUnhealthy {
items = append(items, fmt.Sprintf("0"))
items = append(items, "0")
}
PrintLine(w, items...)
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/training/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func ListTrainingJobs(namespace string, allNamespaces bool, jobType types.Traini
if strings.Contains(err.Error(), "forbidden: User") {
item := fmt.Sprintf("namespace %v", namespace)
if allNamespaces {
item = fmt.Sprintf("all namespaces")
item = "all namespaces"
}
log.Debugf("the user has no privileges to list the %v in %v,reason: %v", trainerType, item, err)
noPrivileges = true
Expand All @@ -63,7 +63,7 @@ func ListTrainingJobs(namespace string, allNamespaces bool, jobType types.Traini
if noPrivileges {
item := fmt.Sprintf("namespace %v", namespace)
if allNamespaces {
item = fmt.Sprintf("all namespaces")
item = "all namespaces"
}
return nil, fmt.Errorf("the user has no privileges to list the training jobs in %v", item)
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/training/logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ func getInstanceName(job TrainingJob) (string, error) {
func moreThanOneInstanceHelpInfo(pods []*v1.Pod) string {
header := fmt.Sprintf("There is %d instances have been found:", len(pods))
lines := []string{}
footer := fmt.Sprintf("please use '-i' or '--instance' to filter.")
footer := "please use '-i' or '--instance' to filter."
for _, p := range pods {
lines = append(lines, fmt.Sprintf("%v", p.Name))
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/util/duration.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ func ShortHumanDuration(d time.Duration) string {
// Allow deviation no more than 2 seconds(excluded) to tolerate machine time
// inconsistence, it can be considered as almost now.
if seconds := int(d.Seconds()); seconds < -1 {
return fmt.Sprintf("<invalid>")
return "<invalid>"
} else if seconds < 0 {
return fmt.Sprintf("0s")
return "0s"
} else if seconds < 60 {
return fmt.Sprintf("%ds", seconds)
} else if minutes := int(d.Minutes()); minutes < 60 {
Expand Down