Skip to content

Commit

Permalink
lxc/project: use strings.Cut() instead of SplitN()
Browse files Browse the repository at this point in the history
Signed-off-by: Simon Deziel <[email protected]>
  • Loading branch information
simondeziel committed Sep 26, 2024
1 parent 780bb09 commit d01194f
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lxc/project.go
Original file line number Diff line number Diff line change
Expand Up @@ -960,7 +960,7 @@ func (c *cmdProjectInfo) run(cmd *cobra.Command, args []string) error {
byteLimits := []string{"disk", "memory"}
data := [][]string{}
for k, v := range projectState.Resources {
shortKey := strings.SplitN(k, ".", 2)[0]
shortKey, _, _ := strings.Cut(k, ".")

limit := i18n.G("UNLIMITED")
if v.Limit >= 0 {
Expand All @@ -979,9 +979,9 @@ func (c *cmdProjectInfo) run(cmd *cobra.Command, args []string) error {
}

columnName := strings.ToUpper(k)
fields := strings.SplitN(columnName, ".", 2)
if len(fields) == 2 {
columnName = fmt.Sprintf("%s (%s)", fields[0], fields[1])
before, after, found := strings.Cut(columnName, ".")
if found {
columnName = fmt.Sprintf("%s (%s)", before, after)
}

data = append(data, []string{columnName, limit, usage})
Expand Down

0 comments on commit d01194f

Please sign in to comment.