I have searched around and have not found another example of this being done but I inadvertently discovered that I was able to create a slice from a fragment of another slice by simply passing that fragment to a function that accepts a slice and returning that slice.
Example:
package main
import "fmt"
func makeSliceFrom(s []int) []int {
return s
}
func main() {
s := []int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
newS := makeSliceFrom(s[1:7])
fmt.Println(newS)
}
I am not asking if this works, because I know it works and seems to work well, I am asking if this is supported or has some unforeseen cost that I am not aware of. It seems odd that I have not seen any examples of this being done.