import "github.com/mumax/3/data" // create a new slice with 5 elements s := data.NewSlice(5) // get the length of the slice l := s.Len() // print the length fmt.Println(l)
import "github.com/mumax/3/data" // create a new slice with some elements s := data.Slice{1, 2, 3, 4, 5} // get the length of the slice l := s.Len() // loop through the slice and print its elements for i := 0; i < l; i++ { fmt.Println(s[i]) }This example creates a new slice with some elements directly using the "Slice" struct from the "data" package. It then calls the "Len" method on this slice, loops through each element, and prints it using the "fmt" package.