I'm will be demonstrating in code, some of the things you can do with slices and maps in Go.
To run this program, I will use the command go run, and then dot, which represents the current directory. Running a Go program is that simple. What if I want to compile it? go build dot.
And what I like about this, compare to other compiled languages like C and Java, is that it's much easier to compile. No need to configure your includes, or your dynamic libraries. It almost feels like an interpreted language like Python.
In the code, this is the main function where I first call sliceExample1. In the first example, I allocate a slice of length 3. It prints it using the print line function. As you can see, the numbers1 slice has three items, all zero-initialized. I can get the length of the slice like this.
You can append an item to a slice by calling append with the slice in the first argument and the item in the second argument, then reassigning it to the slice. After this, you can see that 1 has been added to th