diff --git a/libcontainer/configs/config.go b/libcontainer/configs/config.go index 346fb9e5e..f88eb8b84 100644 --- a/libcontainer/configs/config.go +++ b/libcontainer/configs/config.go @@ -503,7 +503,7 @@ func (hooks *Hooks) MarshalJSON() ([]byte, error) { return serializableHooks } - return json.Marshal(map[string]interface{}{ + return json.Marshal(map[string]any{ "prestart": serialize((*hooks)[Prestart]), "createRuntime": serialize((*hooks)[CreateRuntime]), "createContainer": serialize((*hooks)[CreateContainer]), diff --git a/libcontainer/factory_linux_test.go b/libcontainer/factory_linux_test.go index 22dcd3412..1d822a1bd 100644 --- a/libcontainer/factory_linux_test.go +++ b/libcontainer/factory_linux_test.go @@ -81,7 +81,7 @@ func TestFactoryLoadContainer(t *testing.T) { } } -func marshal(path string, v interface{}) error { +func marshal(path string, v any) error { f, err := os.Create(path) if err != nil { return err diff --git a/libcontainer/specconv/spec_linux_test.go b/libcontainer/specconv/spec_linux_test.go index 66359f79e..0f8d1c18d 100644 --- a/libcontainer/specconv/spec_linux_test.go +++ b/libcontainer/specconv/spec_linux_test.go @@ -676,7 +676,7 @@ func TestInitSystemdProps(t *testing.T) { type expT struct { isErr bool name string - value interface{} + value any } testCases := []struct { diff --git a/libcontainer/state_linux_test.go b/libcontainer/state_linux_test.go index b57e6eff7..0b0f49958 100644 --- a/libcontainer/state_linux_test.go +++ b/libcontainer/state_linux_test.go @@ -24,7 +24,7 @@ func TestStateStatus(t *testing.T) { } func testTransitions(t *testing.T, initialState containerState, valid []containerState) { - validMap := map[reflect.Type]interface{}{} + validMap := map[reflect.Type]any{} for _, validState := range valid { validMap[reflect.TypeOf(validState)] = nil t.Run(validState.status().String(), func(t *testing.T) { diff --git a/libcontainer/sync.go b/libcontainer/sync.go index 0a54a4b81..90cf49b86 100644 --- a/libcontainer/sync.go +++ b/libcontainer/sync.go @@ -113,7 +113,7 @@ func writeSync(pipe *syncSocket, sync syncType) error { return doWriteSync(pipe, syncT{Type: sync}) } -func writeSyncArg(pipe *syncSocket, sync syncType, arg interface{}) error { +func writeSyncArg(pipe *syncSocket, sync syncType, arg any) error { argJSON, err := json.Marshal(arg) if err != nil { return fmt.Errorf("writing sync %v: marshal argument failed: %w", sync, err) diff --git a/libcontainer/utils/utils.go b/libcontainer/utils/utils.go index 23003e177..442c02685 100644 --- a/libcontainer/utils/utils.go +++ b/libcontainer/utils/utils.go @@ -27,7 +27,7 @@ func ExitStatus(status unix.WaitStatus) int { // without a trailing newline. This is used instead of json.Encoder because // there might be a problem in json decoder in some cases, see: // https://github.com/docker/docker/issues/14203#issuecomment-174177790 -func WriteJSON(w io.Writer, v interface{}) error { +func WriteJSON(w io.Writer, v any) error { data, err := json.Marshal(v) if err != nil { return err diff --git a/tty.go b/tty.go index c101aacb7..f5e940975 100644 --- a/tty.go +++ b/tty.go @@ -44,7 +44,7 @@ func setupProcessPipes(p *libcontainer.Process, rootuid, rootgid int) (*tty, err }, } // add the process's io to the post start closers if they support close - for _, cc := range []interface{}{ + for _, cc := range []any{ p.Stdin, p.Stdout, p.Stderr, diff --git a/types/events.go b/types/events.go index ed7d2408f..fc741d2d9 100644 --- a/types/events.go +++ b/types/events.go @@ -7,9 +7,9 @@ import ( // Event struct for encoding the event data to json. type Event struct { - Type string `json:"type"` - ID string `json:"id"` - Data interface{} `json:"data,omitempty"` + Type string `json:"type"` + ID string `json:"id"` + Data any `json:"data,omitempty"` } // Stats is the runc specific stats structure for stability when encoding and decoding stats.