Insert Value at Index

Examples Filter
package main

import (
	"fmt"
)

func main() {
	s := []int{1, 2, 3, 4, 5}

	insertAtIdx := 2
	s = append(s[:insertAtIdx], append([]int{999}, s[insertAtIdx:]...)...)
	fmt.Println(s)
}
Last Run  :
[1 2 999 3 4 5]