S { _ = s[i:j:len(s)] // bounds check if i == j { return s } oldlen := len(s) s = append(s[:i], s[j:]...) clear(s[len(s):oldlen]) // zero/nil out the obsolete elements, for GC return s } j > len(s)かどうかの判 定が増えた 削除する要素が無い 場合はEarly Return 不要になった要素 をゼロ値化