一、代码
package main

import (
	"fmt"
)

func main() {
	//方法一:
	ids := []int{1, 2, 3, 4, 5}
	fmt.Println(ids)
	ids = ids[0:0]
	fmt.Println(ids)

	//方法二:
	ids1 := []int{1, 2, 3, 4, 5, 6}
	fmt.Println(ids1)
	ids1 = []int{}
	fmt.Println(ids1)

	ids2 := make([]int, 0)
	ids2 = append(ids2, 1, 2)
	fmt.Println(ids2)
	ids2 = ids2[0:0]
	fmt.Println(ids2)

	ids3 := make([]int, 0)
	ids3 = append(ids3, 2)
	ids3 = append(ids3, 3)
	ids3 = append(ids3, 4)
	fmt.Println(ids3)
	ids3 = []int{}
	fmt.Println(ids3)
}

二、结果
[1 2 3 4 5]
[]
[1 2 3 4 5 6]
[]
[1 2]
[]
[2 3 4]
[]

Process finished with exit code 0