How to create an empty slice of strings in Go

1 Answer

0 votes
package main

import (
	"fmt"
)

func main() {
	// Create an empty slice of strings
	var emptySlice []string

	// Get the size (length) of the slice
	size := len(emptySlice)

	// Print the size
	fmt.Println("Size of the slice:", size)
}



/*
run:

Size of the slice: 0

*/

 



answered Jul 22 by avibootz
...