cmd/podman: replace strings.Split with strings.Cut

Suggested by latest modernize.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
This commit is contained in:
Kir Kolyshkin 2026-05-22 12:36:26 -07:00
parent b4d0747baa
commit 63166293c8
6 changed files with 7 additions and 7 deletions

View file

@ -28,8 +28,8 @@ func TestPodOptions(t *testing.T) {
for j := 0; j < cc.NumField(); j++ {
containerField := cc.FieldByIndex([]int{j})
containerType := reflect.TypeFor[entities.ContainerCreateOptions]().Field(j)
tagPod := strings.Split(podType.Tag.Get("json"), ",")[0]
tagContainer := strings.Split(containerType.Tag.Get("json"), ",")[0]
tagPod, _, _ := strings.Cut(podType.Tag.Get("json"), ",")
tagContainer, _, _ := strings.Cut(containerType.Tag.Get("json"), ",")
if tagPod == tagContainer && (tagPod != "" && tagContainer != "") {
areEqual := true
if containerField.Kind() == podField.Kind() {

View file

@ -101,7 +101,7 @@ func kill(_ *cobra.Command, args []string) error {
if err != nil {
return fmt.Errorf("reading CIDFile: %w", err)
}
id := strings.Split(string(content), "\n")[0]
id, _, _ := strings.Cut(string(content), "\n")
args = append(args, id)
}

View file

@ -95,7 +95,7 @@ func pause(_ *cobra.Command, args []string) error {
if err != nil {
return fmt.Errorf("reading CIDFile: %w", err)
}
id := strings.Split(string(content), "\n")[0]
id, _, _ := strings.Cut(string(content), "\n")
args = append(args, id)
}

View file

@ -107,7 +107,7 @@ func restart(cmd *cobra.Command, args []string) error {
if err != nil {
return fmt.Errorf("reading CIDFile: %w", err)
}
id := strings.Split(string(content), "\n")[0]
id, _, _ := strings.Cut(string(content), "\n")
args = append(args, id)
}

View file

@ -121,7 +121,7 @@ func stop(cmd *cobra.Command, args []string) error {
}
return fmt.Errorf("reading CIDFile: %w", err)
}
id := strings.Split(string(content), "\n")[0]
id, _, _ := strings.Cut(string(content), "\n")
args = append(args, id)
}

View file

@ -93,7 +93,7 @@ func unpause(_ *cobra.Command, args []string) error {
if err != nil {
return fmt.Errorf("reading CIDFile: %w", err)
}
id := strings.Split(string(content), "\n")[0]
id, _, _ := strings.Cut(string(content), "\n")
args = append(args, id)
}